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;
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;
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;
+#else /* HAVE_HOST_IN_UTMP */
+ buf[0] = 0;
+#endif /* HAVE_HOST_IN_UTMP */
}
}
} while (t == 0);
return t;
-#endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
}
/*
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;
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. */
close(fd);
}
}
-#endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */
+#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
}
/* Records that the user has logged out. */