summaryrefslogtreecommitdiff
path: root/loginrec.c
diff options
context:
space:
mode:
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 bca959707..6f655cb16 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -207,6 +207,7 @@ int syslogin_write_entry(struct logininfo *li);
207 207
208int getlast_entry(struct logininfo *li); 208int getlast_entry(struct logininfo *li);
209int lastlog_get_entry(struct logininfo *li); 209int lastlog_get_entry(struct logininfo *li);
210int utmpx_get_entry(struct logininfo *li);
210int wtmp_get_entry(struct logininfo *li); 211int wtmp_get_entry(struct logininfo *li);
211int wtmpx_get_entry(struct logininfo *li); 212int wtmpx_get_entry(struct logininfo *li);
212 213
@@ -508,6 +509,10 @@ getlast_entry(struct logininfo *li)
508#ifdef USE_LASTLOG 509#ifdef USE_LASTLOG
509 return(lastlog_get_entry(li)); 510 return(lastlog_get_entry(li));
510#else /* !USE_LASTLOG */ 511#else /* !USE_LASTLOG */
512#if defined(USE_UTMPX) && defined(HAVE_SETUTXDB) && \
513 defined(UTXDB_LASTLOGIN) && defined(HAVE_GETUTXUSER)
514 return (utmpx_get_entry(li));
515#endif
511 516
512#if defined(DISABLE_LASTLOG) 517#if defined(DISABLE_LASTLOG)
513 /* On some systems we shouldn't even try to obtain last login 518 /* On some systems we shouldn't even try to obtain last login
@@ -1608,6 +1613,32 @@ lastlog_get_entry(struct logininfo *li)
1608#endif /* HAVE_GETLASTLOGXBYNAME */ 1613#endif /* HAVE_GETLASTLOGXBYNAME */
1609#endif /* USE_LASTLOG */ 1614#endif /* USE_LASTLOG */
1610 1615
1616#if defined(USE_UTMPX) && defined(HAVE_SETUTXDB) && \
1617 defined(UTXDB_LASTLOGIN) && defined(HAVE_GETUTXUSER)
1618int
1619utmpx_get_entry(struct logininfo *li)
1620{
1621 struct utmpx *utx;
1622
1623 if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0)
1624 return (0);
1625 utx = getutxuser(li->username);
1626 if (utx == NULL) {
1627 endutxent();
1628 return (0);
1629 }
1630
1631 line_fullname(li->line, utx->ut_line,
1632 MIN_SIZEOF(li->line, utx->ut_line));
1633 strlcpy(li->hostname, utx->ut_host,
1634 MIN_SIZEOF(li->hostname, utx->ut_host));
1635 li->tv_sec = utx->ut_tv.tv_sec;
1636 li->tv_usec = utx->ut_tv.tv_usec;
1637 endutxent();
1638 return (1);
1639}
1640#endif /* USE_UTMPX && HAVE_SETUTXDB && UTXDB_LASTLOGIN && HAVE_GETUTXUSER */
1641
1611#ifdef USE_BTMP 1642#ifdef USE_BTMP
1612 /* 1643 /*
1613 * Logs failed login attempts in _PATH_BTMP if that exists. 1644 * Logs failed login attempts in _PATH_BTMP if that exists.