diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | configure.ac | 36 | ||||
-rw-r--r-- | defines.h | 4 | ||||
-rw-r--r-- | loginrec.c | 31 | ||||
-rw-r--r-- | logintest.c | 2 |
5 files changed, 40 insertions, 35 deletions
@@ -4,6 +4,8 @@ | |||
4 | - (dtucker) [configure.ac] Bug #1744: use pkg-config for libedit flags if we | 4 | - (dtucker) [configure.ac] Bug #1744: use pkg-config for libedit flags if we |
5 | have it and the path is not provided to --with-libedit. Based on a patch | 5 | have it and the path is not provided to --with-libedit. Based on a patch |
6 | from Iain Morgan. | 6 | from Iain Morgan. |
7 | - (dtucker) [configure.ac defines.h loginrec.c logintest.c] Bug #1732: enable | ||
8 | utmpx support on FreeBSD where possible. Patch from Ed Schouten, ok djm@ | ||
7 | 9 | ||
8 | 20100326 | 10 | 20100326 |
9 | - (djm) [openbsd-compat/bsd-arc4random.c] Fix preprocessor detection | 11 | - (djm) [openbsd-compat/bsd-arc4random.c] Fix preprocessor detection |
diff --git a/configure.ac b/configure.ac index 4e232c7e0..a564c1340 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: configure.ac,v 1.447 2010/04/09 04:04:36 dtucker Exp $ | 1 | # $Id: configure.ac,v 1.448 2010/04/09 08:13:27 dtucker Exp $ |
2 | # | 2 | # |
3 | # Copyright (c) 1999-2004 Damien Miller | 3 | # Copyright (c) 1999-2004 Damien Miller |
4 | # | 4 | # |
@@ -15,7 +15,7 @@ | |||
15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | ||
17 | AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) | 17 | AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) |
18 | AC_REVISION($Revision: 1.447 $) | 18 | AC_REVISION($Revision: 1.448 $) |
19 | AC_CONFIG_SRCDIR([ssh.c]) | 19 | AC_CONFIG_SRCDIR([ssh.c]) |
20 | 20 | ||
21 | AC_CONFIG_HEADER(config.h) | 21 | AC_CONFIG_HEADER(config.h) |
@@ -1557,8 +1557,8 @@ dnl Checks for utmp functions | |||
1557 | AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent) | 1557 | AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent) |
1558 | AC_CHECK_FUNCS(utmpname) | 1558 | AC_CHECK_FUNCS(utmpname) |
1559 | dnl Checks for utmpx functions | 1559 | dnl Checks for utmpx functions |
1560 | AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline ) | 1560 | AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline getutxuser pututxline) |
1561 | AC_CHECK_FUNCS(setutxent utmpxname) | 1561 | AC_CHECK_FUNCS(setutxdb setutxent utmpxname) |
1562 | dnl Checks for lastlog functions | 1562 | dnl Checks for lastlog functions |
1563 | AC_CHECK_FUNCS(getlastlogxbyname) | 1563 | AC_CHECK_FUNCS(getlastlogxbyname) |
1564 | 1564 | ||
@@ -4087,34 +4087,6 @@ if test -n "$conf_wtmp_location"; then | |||
4087 | fi | 4087 | fi |
4088 | 4088 | ||
4089 | 4089 | ||
4090 | dnl utmpx detection - I don't know any system so perverse as to require | ||
4091 | dnl utmpx, but not define UTMPX_FILE (ditto wtmpx.) No doubt it's out | ||
4092 | dnl there, though. | ||
4093 | AC_MSG_CHECKING([if your system defines UTMPX_FILE]) | ||
4094 | AC_TRY_COMPILE([ | ||
4095 | #include <sys/types.h> | ||
4096 | #include <utmp.h> | ||
4097 | #ifdef HAVE_UTMPX_H | ||
4098 | #include <utmpx.h> | ||
4099 | #endif | ||
4100 | #ifdef HAVE_PATHS_H | ||
4101 | # include <paths.h> | ||
4102 | #endif | ||
4103 | ], | ||
4104 | [ char *utmpx = UTMPX_FILE; ], | ||
4105 | [ AC_MSG_RESULT(yes) ], | ||
4106 | [ AC_MSG_RESULT(no) | ||
4107 | system_utmpx_path=no ] | ||
4108 | ) | ||
4109 | if test -z "$conf_utmpx_location"; then | ||
4110 | if test x"$system_utmpx_path" = x"no" ; then | ||
4111 | AC_DEFINE(DISABLE_UTMPX) | ||
4112 | fi | ||
4113 | else | ||
4114 | AC_DEFINE_UNQUOTED(CONF_UTMPX_FILE, "$conf_utmpx_location", | ||
4115 | [Define if you want to specify the path to your utmpx file]) | ||
4116 | fi | ||
4117 | |||
4118 | dnl wtmpx detection | 4090 | dnl wtmpx detection |
4119 | AC_MSG_CHECKING([if your system defines WTMPX_FILE]) | 4091 | AC_MSG_CHECKING([if your system defines WTMPX_FILE]) |
4120 | AC_TRY_COMPILE([ | 4092 | AC_TRY_COMPILE([ |
@@ -25,7 +25,7 @@ | |||
25 | #ifndef _DEFINES_H | 25 | #ifndef _DEFINES_H |
26 | #define _DEFINES_H | 26 | #define _DEFINES_H |
27 | 27 | ||
28 | /* $Id: defines.h,v 1.159 2010/01/13 23:44:34 tim Exp $ */ | 28 | /* $Id: defines.h,v 1.160 2010/04/09 08:13:27 dtucker Exp $ */ |
29 | 29 | ||
30 | 30 | ||
31 | /* Constants */ | 31 | /* Constants */ |
@@ -674,7 +674,7 @@ struct winsize { | |||
674 | #else | 674 | #else |
675 | /* Simply select your favourite login types. */ | 675 | /* Simply select your favourite login types. */ |
676 | /* Can't do if-else because some systems use several... <sigh> */ | 676 | /* Can't do if-else because some systems use several... <sigh> */ |
677 | # if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX) | 677 | # if !defined(DISABLE_UTMPX) |
678 | # define USE_UTMPX | 678 | # define USE_UTMPX |
679 | # endif | 679 | # endif |
680 | # if defined(UTMP_FILE) && !defined(DISABLE_UTMP) | 680 | # if defined(UTMP_FILE) && !defined(DISABLE_UTMP) |
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 | ||
208 | int getlast_entry(struct logininfo *li); | 208 | int getlast_entry(struct logininfo *li); |
209 | int lastlog_get_entry(struct logininfo *li); | 209 | int lastlog_get_entry(struct logininfo *li); |
210 | int utmpx_get_entry(struct logininfo *li); | ||
210 | int wtmp_get_entry(struct logininfo *li); | 211 | int wtmp_get_entry(struct logininfo *li); |
211 | int wtmpx_get_entry(struct logininfo *li); | 212 | int 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) | ||
1618 | int | ||
1619 | utmpx_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. |
diff --git a/logintest.c b/logintest.c index 7e9fbbfbb..4897ae0f9 100644 --- a/logintest.c +++ b/logintest.c | |||
@@ -264,7 +264,7 @@ showOptions(void) | |||
264 | printf("\tUSE_UTMP (UTMP_FILE=%s)\n", UTMP_FILE); | 264 | printf("\tUSE_UTMP (UTMP_FILE=%s)\n", UTMP_FILE); |
265 | #endif | 265 | #endif |
266 | #ifdef USE_UTMPX | 266 | #ifdef USE_UTMPX |
267 | printf("\tUSE_UTMPX (UTMPX_FILE=%s)\n", UTMPX_FILE); | 267 | printf("\tUSE_UTMPX\n"); |
268 | #endif | 268 | #endif |
269 | #ifdef USE_WTMP | 269 | #ifdef USE_WTMP |
270 | printf("\tUSE_WTMP (WTMP_FILE=%s)\n", WTMP_FILE); | 270 | printf("\tUSE_WTMP (WTMP_FILE=%s)\n", WTMP_FILE); |