]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
- (dtucker) [configure.ac defines.h loginrec.c logintest.c] Bug #1732: enable
authorDarren Tucker <dtucker@zip.com.au>
Fri, 9 Apr 2010 08:13:27 +0000 (18:13 +1000)
committerDarren Tucker <dtucker@zip.com.au>
Fri, 9 Apr 2010 08:13:27 +0000 (18:13 +1000)
   utmpx support on FreeBSD where possible.  Patch from Ed Schouten, ok djm@

ChangeLog
configure.ac
defines.h
loginrec.c
logintest.c

index 89180d15b001fbefded61614897363fe22b2a64a..eca278f2fa823ccf8141e2a137430e347fd67e87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
  - (dtucker) [configure.ac] Bug #1744: use pkg-config for libedit flags if we
    have it and the path is not provided to --with-libedit.  Based on a patch
    from Iain Morgan.
+ - (dtucker) [configure.ac defines.h loginrec.c logintest.c] Bug #1732: enable
+   utmpx support on FreeBSD where possible.  Patch from Ed Schouten, ok djm@
 
 20100326
  - (djm) [openbsd-compat/bsd-arc4random.c] Fix preprocessor detection
index 4e232c7e05922c3b081937e7886f4e8a04210cfe..a564c13404cb3d99422cf50dedd9c4c52dd454ef 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.447 2010/04/09 04:04:36 dtucker Exp $
+# $Id: configure.ac,v 1.448 2010/04/09 08:13:27 dtucker Exp $
 #
 # Copyright (c) 1999-2004 Damien Miller
 #
@@ -15,7 +15,7 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
-AC_REVISION($Revision: 1.447 $)
+AC_REVISION($Revision: 1.448 $)
 AC_CONFIG_SRCDIR([ssh.c])
 
 AC_CONFIG_HEADER(config.h)
@@ -1557,8 +1557,8 @@ dnl    Checks for utmp functions
 AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
 AC_CHECK_FUNCS(utmpname)
 dnl    Checks for utmpx functions
-AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )
-AC_CHECK_FUNCS(setutxent utmpxname)
+AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline getutxuser pututxline)
+AC_CHECK_FUNCS(setutxdb setutxent utmpxname)
 dnl    Checks for lastlog functions
 AC_CHECK_FUNCS(getlastlogxbyname)
 
@@ -4087,34 +4087,6 @@ if test -n "$conf_wtmp_location"; then
 fi
 
 
-dnl utmpx detection - I don't know any system so perverse as to require
-dnl  utmpx, but not define UTMPX_FILE (ditto wtmpx.) No doubt it's out
-dnl  there, though.
-AC_MSG_CHECKING([if your system defines UTMPX_FILE])
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <utmp.h>
-#ifdef HAVE_UTMPX_H
-#include <utmpx.h>
-#endif
-#ifdef HAVE_PATHS_H
-#  include <paths.h>
-#endif
-       ],
-       [ char *utmpx = UTMPX_FILE; ],
-       [ AC_MSG_RESULT(yes) ],
-       [ AC_MSG_RESULT(no)
-         system_utmpx_path=no ]
-)
-if test -z "$conf_utmpx_location"; then
-       if test x"$system_utmpx_path" = x"no" ; then
-               AC_DEFINE(DISABLE_UTMPX)
-       fi
-else
-       AC_DEFINE_UNQUOTED(CONF_UTMPX_FILE, "$conf_utmpx_location",
-               [Define if you want to specify the path to your utmpx file])
-fi
-
 dnl wtmpx detection
 AC_MSG_CHECKING([if your system defines WTMPX_FILE])
 AC_TRY_COMPILE([
index c9b93bf7139b6eed33ca1ec95c7624ef5324e745..fe25170e61880281318fee0f21cb35b307598c48 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -25,7 +25,7 @@
 #ifndef _DEFINES_H
 #define _DEFINES_H
 
-/* $Id: defines.h,v 1.159 2010/01/13 23:44:34 tim Exp $ */
+/* $Id: defines.h,v 1.160 2010/04/09 08:13:27 dtucker Exp $ */
 
 
 /* Constants */
@@ -674,7 +674,7 @@ struct winsize {
 #else
 /* Simply select your favourite login types. */
 /* Can't do if-else because some systems use several... <sigh> */
-#  if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX)
+#  if !defined(DISABLE_UTMPX)
 #    define USE_UTMPX
 #  endif
 #  if defined(UTMP_FILE) && !defined(DISABLE_UTMP)
index bca95970711e57caa17ee764ff2e2068336a8a40..6f655cb16cd58d1a21486b84bbdf8a7a9905f186 100644 (file)
@@ -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.
index 7e9fbbfbbdc1e5a6cac726af7de233410e9438d8..4897ae0f9e11048f7327adbab81e5584b48310ae 100644 (file)
@@ -264,7 +264,7 @@ showOptions(void)
        printf("\tUSE_UTMP (UTMP_FILE=%s)\n", UTMP_FILE);
 #endif
 #ifdef USE_UTMPX
-       printf("\tUSE_UTMPX (UTMPX_FILE=%s)\n", UTMPX_FILE);
+       printf("\tUSE_UTMPX\n");
 #endif
 #ifdef USE_WTMP
        printf("\tUSE_WTMP (WTMP_FILE=%s)\n", WTMP_FILE);