summaryrefslogtreecommitdiffstats
path: root/loginrec.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2010-04-28 08:37:00 +0000
committerdes <des@FreeBSD.org>2010-04-28 08:37:00 +0000
commit5b59cc3b67d2a22a3874b6d0cbfb58b972e243e8 (patch)
treef6bc9905e05497f1cb98b09c2e6df135d3c6abbf /loginrec.c
parent57baac6b030508c9bcd74f3b995bd6a4a4f79211 (diff)
downloadFreeBSD-src-5b59cc3b67d2a22a3874b6d0cbfb58b972e243e8.zip
FreeBSD-src-5b59cc3b67d2a22a3874b6d0cbfb58b972e243e8.tar.gz
Vendor import of OpenSSH 5.5p1
Diffstat (limited to 'loginrec.c')
-rw-r--r--loginrec.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/loginrec.c b/loginrec.c
index bca9597..6f655cb 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -207,6 +207,7 @@ int syslogin_write_entry(struct logininfo *li);
int getlast_entry(struct logininfo *li);
int lastlog_get_entry(struct logininfo *li);
+int utmpx_get_entry(struct logininfo *li);
int wtmp_get_entry(struct logininfo *li);
int wtmpx_get_entry(struct logininfo *li);
@@ -508,6 +509,10 @@ getlast_entry(struct logininfo *li)
#ifdef USE_LASTLOG
return(lastlog_get_entry(li));
#else /* !USE_LASTLOG */
+#if defined(USE_UTMPX) && defined(HAVE_SETUTXDB) && \
+ defined(UTXDB_LASTLOGIN) && defined(HAVE_GETUTXUSER)
+ return (utmpx_get_entry(li));
+#endif
#if defined(DISABLE_LASTLOG)
/* On some systems we shouldn't even try to obtain last login
@@ -1608,6 +1613,32 @@ lastlog_get_entry(struct logininfo *li)
#endif /* HAVE_GETLASTLOGXBYNAME */
#endif /* USE_LASTLOG */
+#if defined(USE_UTMPX) && defined(HAVE_SETUTXDB) && \
+ defined(UTXDB_LASTLOGIN) && defined(HAVE_GETUTXUSER)
+int
+utmpx_get_entry(struct logininfo *li)
+{
+ struct utmpx *utx;
+
+ if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0)
+ return (0);
+ utx = getutxuser(li->username);
+ if (utx == NULL) {
+ endutxent();
+ return (0);
+ }
+
+ line_fullname(li->line, utx->ut_line,
+ MIN_SIZEOF(li->line, utx->ut_line));
+ strlcpy(li->hostname, utx->ut_host,
+ MIN_SIZEOF(li->hostname, utx->ut_host));
+ li->tv_sec = utx->ut_tv.tv_sec;
+ li->tv_usec = utx->ut_tv.tv_usec;
+ endutxent();
+ return (1);
+}
+#endif /* USE_UTMPX && HAVE_SETUTXDB && UTXDB_LASTLOGIN && HAVE_GETUTXUSER */
+
#ifdef USE_BTMP
/*
* Logs failed login attempts in _PATH_BTMP if that exists.
OpenPOWER on IntegriCloud