diff options
author | ed <ed@FreeBSD.org> | 2010-01-13 18:43:32 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2010-01-13 18:43:32 +0000 |
commit | 495b1a6bbd3ae0cee3bc1959edb0d6f01ddd3227 (patch) | |
tree | 582388b87dda9b9d56ac79cf29bf2e330b0bb942 /crypto/openssh | |
parent | bd3422d93eddc1f484fd38473c90e9551c58c647 (diff) | |
download | FreeBSD-src-495b1a6bbd3ae0cee3bc1959edb0d6f01ddd3227.zip FreeBSD-src-495b1a6bbd3ae0cee3bc1959edb0d6f01ddd3227.tar.gz |
Make OpenSSH work with utmpx.
- Partially revert r184122 (sshd.c). Our ut_host is now big enough to
fit proper hostnames.
- Change config.h to match reality.
- defines.h requires UTMPX_FILE to be set by <utmpx.h> before it allows
the utmpx code to work. This makes no sense to me. I've already
mentioned this upstream.
- Add our own platform-specific handling of lastlog. The version I will
send to the OpenSSH folks will use proper autoconf generated
definitions instead of `#if 1'.
Diffstat (limited to 'crypto/openssh')
-rw-r--r-- | crypto/openssh/config.h | 44 | ||||
-rw-r--r-- | crypto/openssh/defines.h | 2 | ||||
-rw-r--r-- | crypto/openssh/loginrec.c | 34 | ||||
-rw-r--r-- | crypto/openssh/sshd.c | 3 |
4 files changed, 56 insertions, 27 deletions
diff --git a/crypto/openssh/config.h b/crypto/openssh/config.h index 5430244..2240a37 100644 --- a/crypto/openssh/config.h +++ b/crypto/openssh/config.h @@ -85,13 +85,13 @@ /* #undef CONF_UTMPX_FILE */ /* Define if you want to specify the path to your utmp file */ -#define CONF_UTMP_FILE "/var/run/utmp" +/* #undef CONF_UTMP_FILE */ /* Define if you want to specify the path to your wtmpx file */ /* #undef CONF_WTMPX_FILE */ /* Define if you want to specify the path to your wtmp file */ -#define CONF_WTMP_FILE "/var/log/wtmp" +/* #undef CONF_WTMP_FILE */ /* Define if your platform needs to skip post auth file descriptor passing */ /* #undef DISABLE_FD_PASSING */ @@ -112,13 +112,13 @@ /* #undef DISABLE_SHADOW */ /* Define if you don't want to use utmp */ -/* #undef DISABLE_UTMP */ +#define DISABLE_UTMP 1 /* Define if you don't want to use utmpx */ -#define DISABLE_UTMPX 1 +/* #undef DISABLE_UTMPX */ /* Define if you don't want to use wtmp */ -/* #undef DISABLE_WTMP */ +#define DISABLE_WTMP 1 /* Define if you don't want to use wtmpx */ #define DISABLE_WTMPX 1 @@ -319,7 +319,7 @@ /* #undef HAVE_ENDUTENT */ /* Define to 1 if you have the `endutxent' function. */ -/* #undef HAVE_ENDUTXENT */ +#define HAVE_ENDUTXENT 1 /* Define if your system has /etc/default/login */ /* #undef HAVE_ETC_DEFAULT_LOGIN */ @@ -445,13 +445,13 @@ /* #undef HAVE_GETUTLINE */ /* Define to 1 if you have the `getutxent' function. */ -/* #undef HAVE_GETUTXENT */ +#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. */ -/* #undef HAVE_GETUTXLINE */ +#define HAVE_GETUTXLINE 1 /* Define to 1 if you have the `get_default_context_with_level' function. */ /* #undef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL */ @@ -484,10 +484,10 @@ #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 */ -/* #undef HAVE_HOST_IN_UTMPX */ +#define HAVE_HOST_IN_UTMPX 1 /* Define to 1 if you have the <iaf.h> header file. */ /* #undef HAVE_IAF_H */ @@ -499,7 +499,7 @@ /* #undef HAVE_ID_IN_UTMP */ /* Define if you have ut_id in utmpx.h */ -/* #undef HAVE_ID_IN_UTMPX */ +#define HAVE_ID_IN_UTMPX 1 /* Define to 1 if you have the `inet_aton' function. */ #define HAVE_INET_ATON 1 @@ -574,7 +574,7 @@ /* #undef HAVE_LINUX_IF_TUN_H */ /* Define if your libraries define login() */ -#define HAVE_LOGIN 1 +/* #undef HAVE_LOGIN */ /* Define to 1 if you have the <login_cap.h> header file. */ #define HAVE_LOGIN_CAP_H 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 @@ -704,7 +704,7 @@ /* #undef HAVE_PUTUTLINE */ /* Define to 1 if you have the `pututxline' function. */ -/* #undef HAVE_PUTUTXLINE */ +#define HAVE_PUTUTXLINE 1 /* Define if your password has a pw_change field */ #define HAVE_PW_CHANGE_IN_PASSWD 1 @@ -800,7 +800,7 @@ /* #undef HAVE_SETUTENT */ /* Define to 1 if you have the `setutxent' function. */ -/* #undef HAVE_SETUTXENT */ +#define HAVE_SETUTXENT 1 /* Define to 1 if you have the `setvbuf' function. */ #define HAVE_SETVBUF 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 */ @@ -1043,13 +1043,13 @@ /* #undef HAVE_TV_IN_UTMP */ /* Define if you have ut_tv in utmpx.h */ -/* #undef HAVE_TV_IN_UTMPX */ +#define HAVE_TV_IN_UTMPX 1 /* Define if you have ut_type in utmp.h */ /* #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 <ucred.h> header file. */ /* #undef HAVE_UCRED_H */ @@ -1091,10 +1091,10 @@ /* #undef HAVE_UTMPXNAME */ /* Define to 1 if you have the <utmpx.h> header file. */ -/* #undef HAVE_UTMPX_H */ +#define HAVE_UTMPX_H 1 /* Define to 1 if you have the <utmp.h> header file. */ -#define HAVE_UTMP_H 1 +/* #undef HAVE_UTMP_H */ /* define if you have u_char data type */ #define HAVE_U_CHAR 1 diff --git a/crypto/openssh/defines.h b/crypto/openssh/defines.h index 2ddfd96..827e92d 100644 --- a/crypto/openssh/defines.h +++ b/crypto/openssh/defines.h @@ -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) diff --git a/crypto/openssh/loginrec.c b/crypto/openssh/loginrec.c index f4af067..6ab9c5f 100644 --- a/crypto/openssh/loginrec.c +++ b/crypto/openssh/loginrec.c @@ -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); @@ -509,6 +510,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 */ @@ -758,8 +763,8 @@ construct_utmpx(struct logininfo *li, struct utmpx *utx) utx->ut_pid = li->pid; /* strncpy(): Don't necessarily want null termination */ - strncpy(utx->ut_name, li->username, - MIN_SIZEOF(utx->ut_name, li->username)); + strncpy(utx->ut_user, li->username, + MIN_SIZEOF(utx->ut_user, li->username)); if (li->type == LTYPE_LOGOUT) return; @@ -1608,6 +1613,31 @@ 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, + 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 + #ifdef USE_BTMP /* * Logs failed login attempts in _PATH_BTMP if that exists. diff --git a/crypto/openssh/sshd.c b/crypto/openssh/sshd.c index 422f0cb..166f42b 100644 --- a/crypto/openssh/sshd.c +++ b/crypto/openssh/sshd.c @@ -73,7 +73,6 @@ __RCSID("$FreeBSD$"); #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <utmp.h> #include <openssl/dh.h> #include <openssl/bn.h> @@ -240,7 +239,7 @@ u_char *session_id2 = NULL; u_int session_id2_len = 0; /* record remote hostname or ip */ -u_int utmp_len = UT_HOSTSIZE; +u_int utmp_len = MAXHOSTNAMELEN; /* options.max_startup sized array of fd ints */ int *startup_pipes = NULL; |