diff options
author | des <des@FreeBSD.org> | 2010-04-28 08:37:00 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2010-04-28 08:37:00 +0000 |
commit | 5b59cc3b67d2a22a3874b6d0cbfb58b972e243e8 (patch) | |
tree | f6bc9905e05497f1cb98b09c2e6df135d3c6abbf /loginrec.c | |
parent | 57baac6b030508c9bcd74f3b995bd6a4a4f79211 (diff) | |
download | FreeBSD-src-5b59cc3b67d2a22a3874b6d0cbfb58b972e243e8.zip FreeBSD-src-5b59cc3b67d2a22a3874b6d0cbfb58b972e243e8.tar.gz |
Vendor import of OpenSSH 5.5p1
Diffstat (limited to 'loginrec.c')
-rw-r--r-- | loginrec.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -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. |