lastlog.patch   [plain text]


--- loginrec.c.orig	2004-04-07 23:16:06.000000000 -0700
+++ loginrec.c	2005-12-21 18:10:44.000000000 -0800
@@ -1395,6 +1395,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
@@ -1551,4 +1583,5 @@
 	/* NOTREACHED */
 	return (0);
 }
+#endif /* __APPLE_UTMPX__ */
 #endif /* USE_LASTLOG */