PATCH: Fixing last/utmpx for Solaris

William R. Knox wknox at mitre.org
Wed Nov 21 06:29:01 EST 2001


In case it is any help, here is the patch against openssh-3.0.1p1 that
corrects the problem with last reporting on Solaris that I sent to the
list a week or so ago against 3.0p1. There was no conversation about this
aside from Rip Loomis' comment about including it to support BSM auditing
- does this present a problem for other OSes to include the ut_name field
in the utmpx entry? Should this patch be changed to only apply to Solaris
hosts? Thoughts?

			Bill Knox
			Senior Operating Systems Programmer/Analyst
			The MITRE Corporation
-------------- next part --------------
--- loginrec.c~	Mon Oct 29 21:50:40 2001
+++ loginrec.c	Mon Nov 19 12:08:34 2001
@@ -701,6 +701,7 @@
 	line_stripname(utx->ut_line, li->line, sizeof(utx->ut_line));
 	set_utmpx_time(li, utx);
 	utx->ut_pid = li->pid;
+	strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username));
 
 	if (li->type == LTYPE_LOGOUT)
 		return;
@@ -711,7 +712,6 @@
 	 */
 
 	/* strncpy(): Don't necessarily want null termination */
-	strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username));
 # ifdef HAVE_HOST_IN_UTMPX
 	strncpy(utx->ut_host, li->hostname, MIN_SIZEOF(utx->ut_host, li->hostname));
 # endif
@@ -942,9 +942,7 @@
 {
 	struct utmpx utx;
 
-	memset(&utx, '\0', sizeof(utx));
-	set_utmpx_time(li, &utx);
-	line_stripname(utx.ut_line, li->line, sizeof(utx.ut_line));
+	construct_utmpx(li, &utx);
 # ifdef HAVE_ID_IN_UTMPX
 	line_abbrevname(utx.ut_id, li->line, sizeof(utx.ut_id));
 # endif
--- session.c~	Tue Nov 13 07:46:19 2001
+++ session.c	Mon Nov 19 12:08:34 2001
@@ -1863,7 +1863,7 @@
 
 	/* Record that the user has logged out. */
 	if (s->pid != 0)
-		record_logout(s->pid, s->tty);
+		record_logout(s->pid, s->tty, s->pw->pw_name);
 
 	/* Release the pseudo-tty. */
 	pty_release(s->tty);
--- sshlogin.c~	Tue May  8 16:33:06 2001
+++ sshlogin.c	Mon Nov 19 12:08:34 2001
@@ -94,11 +94,11 @@
 /* Records that the user has logged out. */
 
 void
-record_logout(pid_t pid, const char *ttyname)
+record_logout(pid_t pid, const char *ttyname, const char *user)
 {
   struct logininfo *li;
 
-  li = login_alloc_entry(pid, NULL, NULL, ttyname);
+  li = login_alloc_entry(pid, user, NULL, ttyname);
   login_logout(li);
   login_free_entry(li);
 }
--- sshlogin.h~	Wed Jul  4 00:46:58 2001
+++ sshlogin.h	Mon Nov 19 12:08:34 2001
@@ -17,7 +17,7 @@
 void
 record_login(pid_t, const char *, const char *, uid_t,
     const char *, struct sockaddr *);
-void   record_logout(pid_t, const char *);
+void   record_logout(pid_t, const char *, const char *);
 u_long         get_last_login_time(uid_t, const char *, char *, u_int);
 
 #endif


More information about the openssh-unix-dev mailing list