*** empty log message ***
authorroot <root>
Tue, 17 Jan 2006 06:06:42 +0000 (06:06 +0000)
committerroot <root>
Tue, 17 Jan 2006 06:06:42 +0000 (06:06 +0000)
src/logging.C
src/logging.h
src/main.C
src/rxvt.h
src/rxvtlib.h.in

index 4b2eed0e27a3e50b30e8c71a4f9412a28c47564c..c3d73962cfc43ca1d740a03133a58e1f677798d2 100644 (file)
  * 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"
@@ -65,8 +57,11 @@ static void             rxvt_update_lastlog              (const char *fname, con
  * make and write utmp and wtmp entries
  */
 void
-rxvt_term::makeutent (const char *pty, const char *hostname)
+rxvt_session::login (const char *pty, int cmd_pid, bool login_shell, const char *hostname)
 {
+  this->cmd_pid     = cmd_pid;
+  this->login_shell = login_shell;
+
 #ifdef HAVE_STRUCT_UTMP
   struct utmp *ut = &this->ut;
 #endif
@@ -201,7 +196,7 @@ rxvt_term::makeutent (const char *pty, const char *hostname)
 
 #ifdef WTMP_SUPPORT
 # ifdef WTMP_ONLY_ON_LOGIN
-  if (OPTION (Opt_loginShell))
+  if (login_shell)
 # endif
     {
 # ifdef HAVE_STRUCT_UTMP
@@ -217,7 +212,7 @@ rxvt_term::makeutent (const char *pty, const char *hostname)
     }
 #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
 }
@@ -227,7 +222,7 @@ rxvt_term::makeutent (const char *pty, const char *hostname)
  * remove utmp and wtmp entries
  */
 void
-rxvt_term::cleanutent ()
+rxvt_session::logout ()
 {
 #ifdef HAVE_STRUCT_UTMP
   struct utmp *ut = &this->ut;
@@ -278,7 +273,7 @@ rxvt_term::cleanutent ()
    */
 #ifdef WTMP_SUPPORT
 # ifdef WTMP_ONLY_ON_LOGIN
-  if (OPTION (Opt_loginShell))
+  if (login_shell)
 # endif
     {
 # ifdef HAVE_STRUCT_UTMP
index 4b173d9b2d03414bc5b91bc266c2ed753afda63c..7bb9ebd884e36a66b00f6d9d4c5398a69064ce5e 100644 (file)
@@ -2,6 +2,22 @@
 #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 <utmpx.h>
+# endif
+# ifdef HAVE_UTMP_H
+#  include <utmp.h>
+# endif
+
 # if ! defined(HAVE_STRUCT_UTMPX) && ! defined(HAVE_STRUCT_UTMP)
 #  error cannot build with utmp support - no utmp or utmpx struct found
 # endif
@@ -9,6 +25,7 @@
 # ifdef HAVE_LASTLOG_H
 #  include <lastlog.h>
 # endif
+
 # include <pwd.h>
 
 # ifdef RXVT_UTMP_SYSV
 #  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_ */
index 08b622af23f4367eb394c2ed836231c8e49c8f31..01898c3bfb2389679b3e7b87508ea8a9d3d3f134 100644 (file)
@@ -726,9 +726,9 @@ rxvt_term::privileged_utmp (rxvt_privaction action)
   rxvt_privileges (RESTORE);
 
   if (action == SAVE)
-    makeutent (pty.name, rs[Rs_display_name]);
+    session.login (pty.name, cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]);
   else
-    cleanutent ();
+    session.logout ();
 
   rxvt_privileges (IGNORE);
 }
index 208f3527e00d7f01156740207c3c46bd1e52a68c..9736d61b390f83092888c8f510447f0beb0abd84 100644 (file)
@@ -791,24 +791,6 @@ enum {
 # define XPMClearArea(a, b, c, d, e, f, g)
 #endif
 
-#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 <utmpx.h>
-# endif
-# ifdef HAVE_UTMP_H
-#  include <utmp.h>
-# endif
-#endif
-
 #ifdef DEBUG_CMD
 # define D_CMD(x)               fprintf x ; fputc('\n', stderr)
 #else
@@ -1100,18 +1082,6 @@ struct rxvt_term : zero_initialized, rxvt_vars {
   struct mouse_event MEvent;
   XComposeStatus  compose;
   ttymode_t       tio;
-#ifdef UTMP_SUPPORT
-# 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
-  int             utmp_pos;
-#endif
   row_col_t       oldcursor;
 #ifdef XPM_BACKGROUND
   bgPixmap_t      bgPixmap;
@@ -1154,6 +1124,9 @@ struct rxvt_term : zero_initialized, rxvt_vars {
   char           *cmdbuf_ptr, *cmdbuf_endp;
   char            cmdbuf_base[CBUFSIZ];
 
+  rxvt_ptytty     pty;
+  rxvt_session    session;
+
   rxvt_salloc    *talloc;             // text line allocator
   rxvt_salloc    *ralloc;             // rend line allocator
 
@@ -1331,9 +1304,6 @@ struct rxvt_term : zero_initialized, rxvt_vars {
   // init.C
   void Get_Colours ();
   void get_ourmods ();
-  // logging.C
-  void makeutent (const char *pty, const char *hostname);
-  void cleanutent ();
   // main.C
   void privileged_utmp (rxvt_privaction action);
   bool set_fonts ();
index fdc7d6cdd217cd0c6896ae9eff01719370acc974..60c32312307e53fb9ab1311bfae5365e270ca881 100644 (file)
@@ -31,6 +31,7 @@
 #endif
 
 #include "ptytty.h"
+#include "logging.h"
 
 extern "C" {
 #include <X11/Intrinsic.h>      /* Xlib, Xutil, Xresource, Xfuncproto */
@@ -245,7 +246,6 @@ struct rxvt_vars : TermWin_t {
   short           numpix_colors;
   Cursor          TermWin_cursor;       /* cursor for vt window */
   int             sb_shadow;    /* scrollbar shadow width                    */
-  rxvt_ptytty     pty;
   int             numlock_state;
   line_t         *row_buf;      // all lines, scrollback + terminal, circular, followed by temp_buf
   line_t         *drawn_buf;    // text on screen