ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/logging.C
(Generate patch)

Comparing rxvt-unicode/src/logging.C (file contents):
Revision 1.22 by root, Sun Jan 15 05:14:12 2006 UTC vs.
Revision 1.27 by root, Tue Jan 17 10:14:26 2006 UTC

28 * 28 *
29 * You should have received a copy of the GNU General Public License 29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software 30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 *----------------------------------------------------------------------*/ 32 *----------------------------------------------------------------------*/
33/*----------------------------------------------------------------------*
34 * Public:
35 * extern void cleanutent (void);
36 * extern void makeutent (const char * pty, const char * hostname);
37 *
38 * Private:
39 * rxvt_update_wtmp ();
40 *----------------------------------------------------------------------*/
41 33
42#include "../config.h" 34#include "../config.h"
43#include "rxvt.h" 35#include "rxvt.h"
44#include "logging.h" 36#include "ptytty.h"
45 37
46#ifdef UTMP_SUPPORT 38#if UTMP_SUPPORT
47 39
48#if HAVE_STRUCT_UTMP 40#if HAVE_STRUCT_UTMP
49static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); 41static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
50static void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); 42static void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
51#endif 43#endif
63 55
64/* 56/*
65 * make and write utmp and wtmp entries 57 * make and write utmp and wtmp entries
66 */ 58 */
67void 59void
68rxvt_term::makeutent (const char *pty, const char *hostname) 60rxvt_ptytty::login (int cmd_pid, bool login_shell, const char *hostname)
69{ 61{
62 this->cmd_pid = cmd_pid;
63 this->login_shell = login_shell;
64
65 const char *pty = name;
66
70#ifdef HAVE_STRUCT_UTMP 67#ifdef HAVE_STRUCT_UTMP
71 struct utmp *ut = &this->ut; 68 struct utmp *ut = &this->ut;
72#endif 69#endif
73#ifdef HAVE_STRUCT_UTMPX 70#ifdef HAVE_STRUCT_UTMPX
74 struct utmpx *utx = &this->utx; 71 struct utmpx *utx = &this->utx;
194 i++; 191 i++;
195 } 192 }
196 fclose (fd0); 193 fclose (fd0);
197 } 194 }
198# endif 195# endif
199
200 } 196 }
201#endif 197#endif
202 198
203#ifdef WTMP_SUPPORT 199#ifdef WTMP_SUPPORT
204# ifdef WTMP_ONLY_ON_LOGIN 200# ifdef WTMP_ONLY_ON_LOGIN
205 if (OPTION (Opt_loginShell)) 201 if (login_shell)
206# endif 202# endif
207 { 203 {
208# ifdef HAVE_STRUCT_UTMP 204# ifdef HAVE_STRUCT_UTMP
209# ifdef HAVE_UPDWTMP 205# ifdef HAVE_UPDWTMP
210 updwtmp (RXVT_WTMP_FILE, ut); 206 updwtmp (RXVT_WTMP_FILE, ut);
211# else 207# else
212 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 208 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
213# endif 209# endif
214# endif 210# endif
215# ifdef HAVE_STRUCT_UTMPX 211# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX)
216# if HAVE_UPDWTMPX
217 updwtmpx (RXVT_WTMPX_FILE, utx); 212 updwtmpx (RXVT_WTMPX_FILE, utx);
218# else
219 pututxline (utx);
220# endif
221# endif 213# endif
222 } 214 }
223#endif 215#endif
224#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) 216#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
225 if (OPTION (Opt_loginShell)) 217 if (login_shell)
226 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); 218 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname);
227#endif 219#endif
228} 220}
229 221
230/* ------------------------------------------------------------------------- */ 222/* ------------------------------------------------------------------------- */
231/* 223/*
232 * remove utmp and wtmp entries 224 * remove utmp and wtmp entries
233 */ 225 */
234void 226void
235rxvt_term::cleanutent () 227rxvt_ptytty::logout ()
236{ 228{
237#ifdef HAVE_STRUCT_UTMP 229#ifdef HAVE_STRUCT_UTMP
238 struct utmp *ut = &this->ut; 230 struct utmp *tmput, *ut = &this->ut;
239#endif 231#endif
240#ifdef HAVE_STRUCT_UTMPX 232#ifdef HAVE_STRUCT_UTMPX
241 struct utmpx *tmputx, *utx = &this->utx; 233 struct utmpx *tmputx, *utx = &this->utx;
242#endif 234#endif
243 235
245# ifdef HAVE_UTMP_PID 237# ifdef HAVE_UTMP_PID
246 memset (ut, 0, sizeof (struct utmp)); 238 memset (ut, 0, sizeof (struct utmp));
247 setutent (); 239 setutent ();
248 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id)); 240 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id));
249 ut->ut_type = USER_PROCESS; 241 ut->ut_type = USER_PROCESS;
250 {
251 struct utmp *tmput = getutid (ut);
252
253 if (tmput) /* position to entry in utmp file */ 242 if ((tmput = getutid (ut))) /* position to entry in utmp file */
254 ut = tmput; 243 ut = tmput;
255 }
256 ut->ut_type = DEAD_PROCESS; 244 ut->ut_type = DEAD_PROCESS;
257# else 245# else
258 memset (ut->ut_name, 0, sizeof (ut->ut_name)); 246 memset (ut->ut_name, 0, sizeof (ut->ut_name));
259# ifdef HAVE_UTMP_HOST 247# ifdef HAVE_UTMP_HOST
260 memset (ut->ut_host, 0, sizeof (ut->ut_host)); 248 memset (ut->ut_host, 0, sizeof (ut->ut_host));
281 /* 269 /*
282 * Write ending wtmp entry 270 * Write ending wtmp entry
283 */ 271 */
284#ifdef WTMP_SUPPORT 272#ifdef WTMP_SUPPORT
285# ifdef WTMP_ONLY_ON_LOGIN 273# ifdef WTMP_ONLY_ON_LOGIN
286 if (OPTION (Opt_loginShell)) 274 if (login_shell)
287# endif 275# endif
288 { 276 {
289# ifdef HAVE_STRUCT_UTMP 277# ifdef HAVE_STRUCT_UTMP
290# ifdef HAVE_UPDWTMP 278# ifdef HAVE_UPDWTMP
291 updwtmp (RXVT_WTMP_FILE, ut); 279 updwtmp (RXVT_WTMP_FILE, ut);
292# else 280# else
293 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 281 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
294# endif 282# endif
295# endif 283# endif
296# ifdef HAVE_STRUCT_UTMPX 284# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX)
297# if HAVE_UPDWTMPX
298 updwtmpx (RXVT_WTMPX_FILE, utx); 285 updwtmpx (RXVT_WTMPX_FILE, utx);
299# else
300 pututxline (utx);
301# endif
302# endif 286# endif
303 } 287 }
304#endif 288#endif
305 289
306 /* 290 /*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines