lastlog.patch   [plain text]


diff -uNr ../openssh-5.0p1.orig/loginrec.c ./loginrec.c
--- ../openssh-5.0p1.orig/loginrec.c	2007-04-28 19:10:58.000000000 -0700
+++ ./loginrec.c	2008-04-17 12:43:18.000000000 -0700
@@ -1456,6 +1456,38 @@
  **/
 
 #ifdef USE_LASTLOG
+#ifdef __APPLE_UTMPX__
+int
+lastlog_write_entry(struct logininfo *li)
+{
+	switch(li->type) {
+	case LTYPE_LOGIN:
+		return 1; /* lastlog written by pututxline */
+	default:
+		logit("lastlog_write_entry: Invalid type field");
+		return 0;
+	}
+}
+
+int
+lastlog_get_entry(struct logininfo *li)
+{
+	struct lastlogx l, *ll;
+
+	if ((ll = getlastlogxbyname(li->username, &l)) == NULL) {
+		memset(&l, '\0', sizeof(l));
+		ll = &l;
+	}
+	line_fullname(li->line, ll->ll_line, sizeof(li->line));
+	strlcpy(li->hostname, ll->ll_host,
+		MIN_SIZEOF(li->hostname, ll->ll_host));
+	li->tv_sec = ll->ll_tv.tv_sec;
+	li->tv_usec = ll->ll_tv.tv_usec;
+	return (1);
+}
+
+#else /* !__APPLE_UTMPX__ */
+
 #define LL_FILE 1
 #define LL_DIR 2
 #define LL_OTHER 3
@@ -1613,6 +1645,7 @@
 	/* NOTREACHED */
 	return (0);
 }
+#endif /* __APPLE_UTMPX__ */
 #endif /* USE_LASTLOG */
 
 #ifdef USE_BTMP