diff options
author | Darren Tucker <dtucker@zip.com.au> | 2009-08-17 09:40:00 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2009-08-17 09:40:00 +1000 |
commit | b5d5ee1ab0a2df1d5c6aea7ac8dadc4e8782bdd0 (patch) | |
tree | cb73f65759a1f3d268015bd8688e6c987b9442e6 | |
parent | 83d8f2833611c8bb3646eeae918788e946e4e190 (diff) |
- (dtucker) [sshlogin.c openbsd-compat/port-aix.{c,h}] Bug #1595: make
PrintLastLog work on AIX. Based in part on a patch from Miguel Sanders.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | openbsd-compat/port-aix.c | 19 | ||||
-rw-r--r-- | openbsd-compat/port-aix.h | 4 | ||||
-rw-r--r-- | sshlogin.c | 8 |
4 files changed, 27 insertions, 6 deletions
@@ -2,6 +2,8 @@ - (dtucker) [configure.ac] Check for headers before libraries for openssl an zlib, which should make the errors slightly more meaningful on platforms where there's separate "-devel" packages for those. + - (dtucker) [sshlogin.c openbsd-compat/port-aix.{c,h}] Bug #1595: make + PrintLastLog work on AIX. Based in part on a patch from Miguel Sanders. 20090729 - (tim) [contrib/cygwin/ssh-user-config] Change script to call correct error diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c index 5b1cb738..d9c0876f 100644 --- a/openbsd-compat/port-aix.c +++ b/openbsd-compat/port-aix.c @@ -57,6 +57,8 @@ #include "port-aix.h" +static char *lastlogin_msg = NULL; + # ifdef HAVE_SETAUTHDB static char old_registry[REGISTRY_SIZE] = ""; # endif @@ -276,23 +278,30 @@ sys_auth_record_login(const char *user, const char *host, const char *ttynm, Buffer *loginmsg) { char *msg = NULL; - static int msg_done = 0; int success = 0; aix_setauthdb(user); if (loginsuccess((char *)user, (char *)host, (char *)ttynm, &msg) == 0) { success = 1; - if (msg != NULL && loginmsg != NULL && !msg_done) { + if (msg != NULL) { debug("AIX/loginsuccess: msg %s", msg); - buffer_append(loginmsg, msg, strlen(msg)); - xfree(msg); - msg_done = 1; + if (lastlogin_msg == NULL) + lastlogin_msg = msg; } } aix_restoreauthdb(); return (success); } +char * +sys_auth_get_lastlogin_msg(const char *user, uid_t uid) +{ + char *msg = lastlogin_msg; + + lastlogin_msg = NULL; + return msg; +} + # ifdef CUSTOM_FAILED_LOGIN /* * record_failed_login: generic "login failed" interface function diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h index ecb9feae..967bc723 100644 --- a/openbsd-compat/port-aix.h +++ b/openbsd-compat/port-aix.h @@ -1,4 +1,4 @@ -/* $Id: port-aix.h,v 1.29 2008/03/09 05:36:55 dtucker Exp $ */ +/* $Id: port-aix.h,v 1.30 2009/08/16 23:40:00 dtucker Exp $ */ /* * @@ -87,6 +87,8 @@ void aix_usrinfo(struct passwd *); int sys_auth_allowed_user(struct passwd *, Buffer *); # define CUSTOM_SYS_AUTH_RECORD_LOGIN 1 int sys_auth_record_login(const char *, const char *, const char *, Buffer *); +# define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG +char *sys_auth_get_lastlogin_msg(const char *, uid_t); # define CUSTOM_FAILED_LOGIN 1 #endif @@ -93,6 +93,13 @@ store_lastlog_message(const char *user, uid_t uid) if (!options.print_lastlog) return; +# ifdef CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG + time_string = sys_auth_get_lastlogin_msg(user, uid); + if (time_string != NULL) { + buffer_append(&loginmsg, time_string, strlen(time_string)); + xfree(time_string); + } +# else last_login_time = get_last_login_time(uid, user, hostname, sizeof(hostname)); @@ -107,6 +114,7 @@ store_lastlog_message(const char *user, uid_t uid) time_string, hostname); buffer_append(&loginmsg, buf, strlen(buf)); } +# endif /* CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG */ #endif /* NO_SSH_LASTLOG */ } |