From a3ace2589b1f71fea031c1fda0e1eec958f16b42 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 17 Jan 2006 10:14:26 +0000 Subject: [PATCH] *** empty log message *** --- MANIFEST | 1 - src/Makefile.in | 4 +-- src/logging.C | 12 +++++++-- src/logging.h | 67 ------------------------------------------------ src/main.C | 3 +-- src/ptytty.C | 4 +++ src/ptytty.h | 62 ++++++++++++++++++++++++++++++++++++++++++++ src/rxvt.h | 1 - src/rxvtlib.h.in | 1 - 9 files changed, 79 insertions(+), 76 deletions(-) delete mode 100644 src/logging.h diff --git a/MANIFEST b/MANIFEST index 6ed3c212..ac6657fb 100644 --- a/MANIFEST +++ b/MANIFEST @@ -77,7 +77,6 @@ src/iom_conf.h src/keyboard.C src/keyboard.h src/logging.C -src/logging.h src/main.C src/misc.C src/netdisp.C diff --git a/src/Makefile.in b/src/Makefile.in index fc348324..f42779f9 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -195,7 +195,7 @@ keyboard.o: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h keyboard.h keyboard.o: command.h logging.o: ../config.h rxvt.h rxvtlib.h ptytty.h feature.h optinc.h logging.o: encoding.h rxvtfont.h rxvtutil.h rxvttoolkit.h iom.h iom_conf.h -logging.o: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h logging.h +logging.o: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h main.o: ../config.h rxvt.h rxvtlib.h ptytty.h feature.h optinc.h encoding.h main.o: rxvtfont.h rxvtutil.h rxvttoolkit.h iom.h iom_conf.h callback.h main.o: salloc.h rxvtperl.h hookinc.h rsinc.h keyboard.h @@ -290,7 +290,7 @@ keyboard.lo: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h keyboard.h keyboard.lo: command.h logging.lo: ../config.h rxvt.h rxvtlib.h ptytty.h feature.h optinc.h logging.lo: encoding.h rxvtfont.h rxvtutil.h rxvttoolkit.h iom.h iom_conf.h -logging.lo: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h logging.h +logging.lo: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h main.lo: ../config.h rxvt.h rxvtlib.h ptytty.h feature.h optinc.h encoding.h main.lo: rxvtfont.h rxvtutil.h rxvttoolkit.h iom.h iom_conf.h callback.h main.lo: salloc.h rxvtperl.h hookinc.h rsinc.h keyboard.h diff --git a/src/logging.C b/src/logging.C index 4c0fd9ae..733884c0 100644 --- a/src/logging.C +++ b/src/logging.C @@ -59,11 +59,14 @@ static void rxvt_update_lastlog (const char *fname, con void rxvt_ptytty::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; - const char *pty = name; - #ifdef HAVE_STRUCT_UTMP struct utmp *ut = &this->ut; #endif @@ -226,6 +229,9 @@ rxvt_ptytty::login (int cmd_pid, bool login_shell, const char *hostname) void rxvt_ptytty::logout () { + if (!cmd_pid) + return; + #ifdef HAVE_STRUCT_UTMP struct utmp *tmput, *ut = &this->ut; #endif @@ -305,6 +311,8 @@ rxvt_ptytty::logout () pututxline (utx); endutxent (); #endif + + cmd_pid = 0; } /* ------------------------------------------------------------------------- */ diff --git a/src/logging.h b/src/logging.h deleted file mode 100644 index 7bb9ebd8..00000000 --- a/src/logging.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef LOGGING_H_ -#define LOGGING_H_ - -#ifdef UTMP_SUPPORT -# if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) -# undef HAVE_UTMPX_H -# undef HAVE_STRUCT_UTMPX -# endif -# if !defined(RXVT_UTMP_FILE) || !defined(HAVE_STRUCT_UTMP) -# undef HAVE_UTMP_H -# undef HAVE_STRUCT_UTMP -# endif - -# ifdef HAVE_UTMPX_H -# include -# endif -# ifdef HAVE_UTMP_H -# include -# endif - -# if ! defined(HAVE_STRUCT_UTMPX) && ! defined(HAVE_STRUCT_UTMP) -# error cannot build with utmp support - no utmp or utmpx struct found -# endif - -# ifdef HAVE_LASTLOG_H -# include -# endif - -# include - -# ifdef RXVT_UTMP_SYSV -# ifndef USER_PROCESS -# define USER_PROCESS 7 -# endif -# ifndef DEAD_PROCESS -# define DEAD_PROCESS 8 -# endif -# endif - -# ifdef __QNX__ -# include -# define ut_name ut_user -# endif - -struct rxvt_session -{ - int utmp_pos; - int cmd_pid; - bool login_shell; - -#ifdef HAVE_STRUCT_UTMP - struct utmp ut; -#endif -#ifdef HAVE_STRUCT_UTMPX - struct utmpx utx; -#endif -#if (defined(HAVE_STRUCT_UTMP) && defined(HAVE_UTMP_PID)) || defined(HAVE_STRUCT_UTMPX) - char ut_id[5]; -#endif - - void login (const char *pty, int cmd_pid, bool login_shell, const char *hostname); - void logout (); -}; - -#endif - -#endif /* _LOGGING_H_ */ diff --git a/src/main.C b/src/main.C index 2c9bdd1d..9a488f2c 100644 --- a/src/main.C +++ b/src/main.C @@ -719,8 +719,7 @@ rxvt_privileges (rxvt_privaction action) void rxvt_term::privileged_utmp (rxvt_privaction action) { - if (OPTION (Opt_utmpInhibit) - || !pty.name || !*pty.name) + if (OPTION (Opt_utmpInhibit)) return; rxvt_privileges (RESTORE); diff --git a/src/ptytty.C b/src/ptytty.C index 6210230e..0e27097c 100644 --- a/src/ptytty.C +++ b/src/ptytty.C @@ -374,10 +374,14 @@ rxvt_ptytty::rxvt_ptytty () #ifndef NO_SETOWNER_TTYDEV saved = false; #endif +#if UTMP_SUPPORT + cmd_pid = 0; +#endif } rxvt_ptytty::~rxvt_ptytty () { + logout (); put (); } diff --git a/src/ptytty.h b/src/ptytty.h index a79ac8bb..90dd6492 100644 --- a/src/ptytty.h +++ b/src/ptytty.h @@ -12,6 +12,49 @@ # define NO_SETOWNER_TTYDEV 1 #endif +#if UTMP_SUPPORT +# if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) +# undef HAVE_UTMPX_H +# undef HAVE_STRUCT_UTMPX +# endif +# if !defined(RXVT_UTMP_FILE) || !defined(HAVE_STRUCT_UTMP) +# undef HAVE_UTMP_H +# undef HAVE_STRUCT_UTMP +# endif + +# ifdef HAVE_UTMPX_H +# include +# endif +# ifdef HAVE_UTMP_H +# include +# endif + +# if ! defined(HAVE_STRUCT_UTMPX) && ! defined(HAVE_STRUCT_UTMP) +# error cannot build with utmp support - no utmp or utmpx struct found +# endif + +# ifdef HAVE_LASTLOG_H +# include +# endif + +# include + +# ifdef RXVT_UTMP_SYSV +# ifndef USER_PROCESS +# define USER_PROCESS 7 +# endif +# ifndef DEAD_PROCESS +# define DEAD_PROCESS 8 +# endif +# endif + +# ifdef __QNX__ +# include +# define ut_name ut_user +# endif + +#endif + enum rxvt_privaction { IGNORE = 'i', SAVE = 's', RESTORE = 'r' }; struct rxvt_ptytty { @@ -37,6 +80,25 @@ public: bool make_controlling_tty (); void set_utf8_mode (bool on); + +#if UTMP_SUPPORT + int utmp_pos; + int cmd_pid; + bool login_shell; + +#ifdef HAVE_STRUCT_UTMP + struct utmp ut; +#endif +#ifdef HAVE_STRUCT_UTMPX + struct utmpx utx; +#endif +#if (defined(HAVE_STRUCT_UTMP) && defined(HAVE_UTMP_PID)) || defined(HAVE_STRUCT_UTMPX) + char ut_id[5]; +#endif + + void login (int cmd_pid, bool login_shell, const char *hostname); + void logout (); +#endif }; #endif diff --git a/src/rxvt.h b/src/rxvt.h index 9736d61b..aa12f09e 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -1125,7 +1125,6 @@ struct rxvt_term : zero_initialized, rxvt_vars { char cmdbuf_base[CBUFSIZ]; rxvt_ptytty pty; - rxvt_session session; rxvt_salloc *talloc; // text line allocator rxvt_salloc *ralloc; // rend line allocator diff --git a/src/rxvtlib.h.in b/src/rxvtlib.h.in index 60c32312..0a8bd7ff 100644 --- a/src/rxvtlib.h.in +++ b/src/rxvtlib.h.in @@ -31,7 +31,6 @@ #endif #include "ptytty.h" -#include "logging.h" extern "C" { #include /* Xlib, Xutil, Xresource, Xfuncproto */ -- 2.34.1