[PATCH] PrintLastLog option

Chip Salzenberg chip at valinux.com
Sat Mar 3 11:09:11 EST 2001


Some time ago, Ben wrote about a PrintLastLog patch:
> If the person who originally submitted it wants to write a complete
> patch and submit it.  Then we would be happy to debate if it will be
> included.

Well, here it is, because: "You Asked For It!"

PS: I'm tired of maintaining my own version of Debian's ssh just to
    have this option available, so I hope you find it acceptable.
-- 
Chip Salzenberg              - a.k.a. -             <chip at valinux.com>
 "We have no fuel on board, plus or minus 8 kilograms."  -- NEAR tech
-------------- next part --------------

Index: servconf.h
--- servconf.h.prev
+++ servconf.h	Thu Feb 22 20:59:45 2001
@@ -52,4 +52,5 @@
 						 * for RhostsRsaAuth */
 	int     print_motd;	/* If true, print /etc/motd. */
+	int	print_lastlog;	/* If true, print lastlog */
 	int     check_mail;	/* If true, check for new mail. */
 	int     x11_forwarding;	/* If true, permit inet (spoofing) X11 fwd. */

Index: servconf.c
--- servconf.c.prev
+++ servconf.c	Thu Feb 22 20:59:45 2001
@@ -56,4 +56,5 @@ initialize_server_options(ServerOptions 
 	options->ignore_user_known_hosts = -1;
 	options->print_motd = -1;
+	options->print_lastlog = -1;
 	options->check_mail = -1;
 	options->x11_forwarding = -1;
@@ -133,4 +134,6 @@ fill_default_server_options(ServerOption
 	if (options->print_motd == -1)
 		options->print_motd = 1;
+	if (options->print_lastlog == -1)
+		options->print_lastlog = 1;
 	if (options->x11_forwarding == -1)
 		options->x11_forwarding = 0;
@@ -209,5 +212,6 @@ typedef enum {
 	sChallengeResponseAuthentication,
 	sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
-	sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset,
+	sPrintMotd, sPrintLastLog, sIgnoreRhosts,
+	sX11Forwarding, sX11DisplayOffset,
 	sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail,
 	sUseLogin, sAllowTcpForwarding,
@@ -254,4 +258,5 @@ static struct {
 	{ "listenaddress", sListenAddress },
 	{ "printmotd", sPrintMotd },
+	{ "printlastlog", sPrintLastLog },
 	{ "ignorerhosts", sIgnoreRhosts },
 	{ "ignoreuserknownhosts", sIgnoreUserKnownHosts },
@@ -555,4 +560,8 @@ parse_flag:
 		case sPrintMotd:
 			intptr = &options->print_motd;
+			goto parse_flag;
+
+		case sPrintLastLog:
+			intptr = &options->print_lastlog;
 			goto parse_flag;
 

Index: session.c
--- session.c.prev
+++ session.c	Thu Feb 22 20:59:45 2001
@@ -708,8 +708,10 @@ do_login(Session *s, const char *command
 	}
 
-	/* Get the time and hostname when the user last logged in. */
-	hostname[0] = '\0';
-	last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name,
-	    hostname, sizeof(hostname));
+	if (options.print_lastlog) {
+	    /* Get the time and hostname when the user last logged in. */
+	    hostname[0] = '\0';
+	    last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name,
+		hostname, sizeof(hostname));
+	}
 
 	/* Record that there was a login on that tty from the remote host. */
@@ -748,5 +750,5 @@ do_login(Session *s, const char *command
 #endif /* WITH_AIXAUTHENTICATE */
 
-	if (last_login_time != 0) {
+	if (options.print_lastlog && last_login_time != 0) {
 		time_string = ctime(&last_login_time);
 		if (strchr(time_string, '\n'))

Index: sshd.8
--- sshd.8.prev
+++ sshd.8	Thu Feb 22 20:59:46 2001
@@ -350,4 +350,20 @@
 The default is
 .Dq no .
+.Pp
+Note: These messages can also be generated by PAM, so if you find that
+you are getting the message twice, switch this one
+.Dq off
+and let PAM handle it.
+.It Cm PrintLastLogin
+Specifies whether
+.Nm
+should print the date and tty of last login when a user logs in
+interactively.  The default is
+.Dq no .
+.Pp
+Note: These messages can also be generated by PAM, so if you find that
+you are getting the message twice, switch this one
+.Dq off
+and let PAM handle it.
 .It Cm DenyGroups
 This keyword can be followed by a number of group names, separated

Index: sshd_config
--- sshd_config.prev
+++ sshd_config	Thu Feb 22 20:59:46 2001
@@ -19,4 +19,5 @@
 X11DisplayOffset 10
 PrintMotd yes
+PrintLastLog yes
 KeepAlive yes
 


More information about the openssh-unix-dev mailing list