From owner-svn-src-user@FreeBSD.ORG Wed Jan 6 22:15:26 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A838106566C; Wed, 6 Jan 2010 22:15:26 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8AC9A8FC15; Wed, 6 Jan 2010 22:15:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o06MFQOI055609; Wed, 6 Jan 2010 22:15:26 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o06MFQSL055606; Wed, 6 Jan 2010 22:15:26 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201001062215.o06MFQSL055606@svn.freebsd.org> From: Ed Schouten Date: Wed, 6 Jan 2010 22:15:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201682 - user/ed/utmpx/crypto/openssh X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jan 2010 22:15:26 -0000 Author: ed Date: Wed Jan 6 22:15:26 2010 New Revision: 201682 URL: http://svn.freebsd.org/changeset/base/201682 Log: Improve hacks on OpenSSH: - Reduce the diff against config.h generated by openssh-portable. - Add some bits to make Last login: work. This should eventually be sent upstream. Modified: user/ed/utmpx/crypto/openssh/config.h user/ed/utmpx/crypto/openssh/loginrec.c Modified: user/ed/utmpx/crypto/openssh/config.h ============================================================================== --- user/ed/utmpx/crypto/openssh/config.h Wed Jan 6 22:14:05 2010 (r201681) +++ user/ed/utmpx/crypto/openssh/config.h Wed Jan 6 22:15:26 2010 (r201682) @@ -448,7 +448,7 @@ #define HAVE_GETUTXENT 1 /* Define to 1 if you have the `getutxid' function. */ -/* #undef HAVE_GETUTXID */ +#define HAVE_GETUTXID 1 /* Define to 1 if you have the `getutxline' function. */ #define HAVE_GETUTXLINE 1 @@ -484,7 +484,7 @@ #define HAVE_HEADER_AD 1 /* Define if you have ut_host in utmp.h */ -#define HAVE_HOST_IN_UTMP 1 +/* #undef HAVE_HOST_IN_UTMP */ /* Define if you have ut_host in utmpx.h */ #define HAVE_HOST_IN_UTMPX 1 @@ -586,10 +586,10 @@ /* #undef HAVE_LOGIN_H */ /* Define to 1 if you have the `logout' function. */ -#define HAVE_LOGOUT 1 +/* #undef HAVE_LOGOUT */ /* Define to 1 if you have the `logwtmp' function. */ -#define HAVE_LOGWTMP 1 +/* #undef HAVE_LOGWTMP */ /* Define to 1 if the system has the type `long double'. */ #define HAVE_LONG_DOUBLE 1 @@ -1025,7 +1025,7 @@ #define HAVE_TIME_H 1 /* Define if you have ut_time in utmp.h */ -#define HAVE_TIME_IN_UTMP 1 +/* #undef HAVE_TIME_IN_UTMP */ /* Define if you have ut_time in utmpx.h */ /* #undef HAVE_TIME_IN_UTMPX */ @@ -1049,7 +1049,7 @@ /* #undef HAVE_TYPE_IN_UTMP */ /* Define if you have ut_type in utmpx.h */ -/* #undef HAVE_TYPE_IN_UTMPX */ +#define HAVE_TYPE_IN_UTMPX 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_UCRED_H */ @@ -1175,7 +1175,7 @@ /* #undef KRB5 */ /* Define if pututxline updates lastlog too */ -#define LASTLOG_WRITE_PUTUTXLINE 1 +/* #undef LASTLOG_WRITE_PUTUTXLINE */ /* Define if you want TCP Wrappers support */ #define LIBWRAP 1 Modified: user/ed/utmpx/crypto/openssh/loginrec.c ============================================================================== --- user/ed/utmpx/crypto/openssh/loginrec.c Wed Jan 6 22:14:05 2010 (r201681) +++ user/ed/utmpx/crypto/openssh/loginrec.c Wed Jan 6 22:15:26 2010 (r201682) @@ -509,6 +509,10 @@ getlast_entry(struct logininfo *li) return(lastlog_get_entry(li)); #else /* !USE_LASTLOG */ +#if 1 + return (utmpx_get_entry(li)); +#endif + #if defined(DISABLE_LASTLOG) /* On some systems we shouldn't even try to obtain last login * time, e.g. AIX */ @@ -1608,6 +1612,30 @@ lastlog_get_entry(struct logininfo *li) #endif /* HAVE_GETLASTLOGXBYNAME */ #endif /* USE_LASTLOG */ +#if 1 +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, sizeof(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 + #ifdef USE_BTMP /* * Logs failed login attempts in _PATH_BTMP if that exists.