--- rxvt-unicode/src/logging.C 2006/01/15 05:14:12 1.22 +++ rxvt-unicode/src/logging.C 2006/01/17 10:59:32 1.29 @@ -30,20 +30,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------* - * Public: - * extern void cleanutent (void); - * extern void makeutent (const char * pty, const char * hostname); - * - * Private: - * rxvt_update_wtmp (); - *----------------------------------------------------------------------*/ #include "../config.h" #include "rxvt.h" -#include "logging.h" +#include "ptytty.h" -#ifdef UTMP_SUPPORT +#if UTMP_SUPPORT #if HAVE_STRUCT_UTMP static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); @@ -65,8 +57,16 @@ * make and write utmp and wtmp entries */ void -rxvt_term::makeutent (const char *pty, const char *hostname) +rxvt_ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname) { + const char *pty = name; + + if (!pty || !*pty) + return; + + this->cmd_pid = cmd_pid; + this->login_shell = login_shell; + #ifdef HAVE_STRUCT_UTMP struct utmp *ut = &this->ut; #endif @@ -196,13 +196,12 @@ fclose (fd0); } # endif - } #endif #ifdef WTMP_SUPPORT # ifdef WTMP_ONLY_ON_LOGIN - if (OPTION (Opt_loginShell)) + if (login_shell) # endif { # ifdef HAVE_STRUCT_UTMP @@ -212,17 +211,13 @@ rxvt_update_wtmp (RXVT_WTMP_FILE, ut); # endif # endif -# ifdef HAVE_STRUCT_UTMPX -# if HAVE_UPDWTMPX +# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX) updwtmpx (RXVT_WTMPX_FILE, utx); -# else - pututxline (utx); -# endif # endif } #endif #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) - if (OPTION (Opt_loginShell)) + if (login_shell) rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); #endif } @@ -232,10 +227,13 @@ * remove utmp and wtmp entries */ void -rxvt_term::cleanutent () +rxvt_ptytty_unix::logout () { + if (!cmd_pid) + return; + #ifdef HAVE_STRUCT_UTMP - struct utmp *ut = &this->ut; + struct utmp *tmput, *ut = &this->ut; #endif #ifdef HAVE_STRUCT_UTMPX struct utmpx *tmputx, *utx = &this->utx; @@ -247,12 +245,8 @@ setutent (); strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id)); ut->ut_type = USER_PROCESS; - { - struct utmp *tmput = getutid (ut); - - if (tmput) /* position to entry in utmp file */ - ut = tmput; - } + if ((tmput = getutid (ut))) /* position to entry in utmp file */ + ut = tmput; ut->ut_type = DEAD_PROCESS; # else memset (ut->ut_name, 0, sizeof (ut->ut_name)); @@ -283,7 +277,7 @@ */ #ifdef WTMP_SUPPORT # ifdef WTMP_ONLY_ON_LOGIN - if (OPTION (Opt_loginShell)) + if (login_shell) # endif { # ifdef HAVE_STRUCT_UTMP @@ -293,12 +287,8 @@ rxvt_update_wtmp (RXVT_WTMP_FILE, ut); # endif # endif -# ifdef HAVE_STRUCT_UTMPX -# if HAVE_UPDWTMPX +# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX) updwtmpx (RXVT_WTMPX_FILE, utx); -# else - pututxline (utx); -# endif # endif } #endif @@ -321,6 +311,8 @@ pututxline (utx); endutxent (); #endif + + cmd_pid = 0; } /* ------------------------------------------------------------------------- */