Better login.c patch

Damien Miller djm at mindrot.org
Wed Dec 22 13:24:41 EST 1999


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Apply this patch to login.c if you are having difficulty compiling.
This replaces the previous patch I sent.

Regards,
Damien Miller

- --
| "Bombay is 250ms from New York in the new world order" - Alan Cox
| Damien Miller - http://www.mindrot.org/
| Email: djm at mindrot.org (home) -or- djm at ibs.com.au (work)


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.0 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE4YDZsormJ9RG1dI8RAhvkAJwJOUteyZBqQTkMOFeRg/wZh8HjbACdFgsE
+WAB91OJF+TLuG8uOcNhrt8=
=Rj1b
-----END PGP SIGNATURE-----
-------------- next part --------------
Index: login.c
===================================================================
RCS file: /var/cvs/openssh/login.c,v
retrieving revision 1.9
diff -u -r1.9 login.c
--- login.c	1999/12/21 10:30:56	1.9
+++ login.c	1999/12/22 02:22:38
@@ -53,7 +53,7 @@
 get_last_login_time(uid_t uid, const char *logname,
 		    char *buf, unsigned int bufsize)
 {
-#if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG)
+#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
 	struct lastlog ll;
 	char *lastlog;
 	int fd;
@@ -76,7 +76,7 @@
 	buf[bufsize - 1] = 0;
 	return ll.ll_time;
 
-#else /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#else /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
 	/* Look in wtmp for the last login */
 	struct utmp  wt;
 	char        *wt_file = _PATH_WTMP;
@@ -101,10 +101,14 @@
 		if ( wt.ut_type == USER_PROCESS) {
 			if ( !strncmp(logname, wt.ut_user, 8) ) {
 				t = (unsigned long) wt.ut_time;
+#ifdef HAVE_HOST_IN_UTMP
 				if (bufsize > sizeof(wt.ut_host) + 1)
 				bufsize = sizeof(wt.ut_host) + 1;
 				strncpy(buf, wt.ut_host, bufsize - 1);
 				buf[bufsize - 1] = 0;
+#endif /* HAVE_HOST_IN_UTMP */
+				buf[0] = 0;
+#endif /* HAVE_HOST_IN_UTMP */
 			}
 		}
 
@@ -113,7 +117,7 @@
 	} while (t == 0);
 
 	return t;
-#endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
 }
 
 /*
@@ -125,10 +129,10 @@
 record_login(int pid, const char *ttyname, const char *user, uid_t uid,
 	     const char *host, struct sockaddr_in * addr)
 {
-#if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG)
+#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
 	struct lastlog ll;
 	char *lastlog;
-#endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
 	struct UTMP_STR u;
 	const char *utmp, *wtmp;
 
@@ -152,7 +156,7 @@
 
 	login(&u);
 
-#if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG)
+#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
 	lastlog = _PATH_LASTLOG;
 
 	/* Update lastlog unless actually recording a logout. */
@@ -176,7 +180,7 @@
 			close(fd);
 		}
 	}
-#endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
 }
 
 /* Records that the user has logged out. */


More information about the openssh-unix-dev mailing list