- (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.
This commit is contained in:
Darren Tucker 2009-08-17 09:40:00 +10:00
parent 83d8f28336
commit b5d5ee1ab0
4 changed files with 27 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 */
}