summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--openbsd-compat/port-aix.c19
-rw-r--r--openbsd-compat/port-aix.h4
-rw-r--r--sshlogin.c8
4 files changed, 27 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index fc42b5785..61ba1ed7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
2 - (dtucker) [configure.ac] Check for headers before libraries for openssl an 2 - (dtucker) [configure.ac] Check for headers before libraries for openssl an
3 zlib, which should make the errors slightly more meaningful on platforms 3 zlib, which should make the errors slightly more meaningful on platforms
4 where there's separate "-devel" packages for those. 4 where there's separate "-devel" packages for those.
5 - (dtucker) [sshlogin.c openbsd-compat/port-aix.{c,h}] Bug #1595: make
6 PrintLastLog work on AIX. Based in part on a patch from Miguel Sanders.
5 7
620090729 820090729
7 - (tim) [contrib/cygwin/ssh-user-config] Change script to call correct error 9 - (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 5b1cb7387..d9c0876f3 100644
--- a/openbsd-compat/port-aix.c
+++ b/openbsd-compat/port-aix.c
@@ -57,6 +57,8 @@
57 57
58#include "port-aix.h" 58#include "port-aix.h"
59 59
60static char *lastlogin_msg = NULL;
61
60# ifdef HAVE_SETAUTHDB 62# ifdef HAVE_SETAUTHDB
61static char old_registry[REGISTRY_SIZE] = ""; 63static char old_registry[REGISTRY_SIZE] = "";
62# endif 64# endif
@@ -276,23 +278,30 @@ sys_auth_record_login(const char *user, const char *host, const char *ttynm,
276 Buffer *loginmsg) 278 Buffer *loginmsg)
277{ 279{
278 char *msg = NULL; 280 char *msg = NULL;
279 static int msg_done = 0;
280 int success = 0; 281 int success = 0;
281 282
282 aix_setauthdb(user); 283 aix_setauthdb(user);
283 if (loginsuccess((char *)user, (char *)host, (char *)ttynm, &msg) == 0) { 284 if (loginsuccess((char *)user, (char *)host, (char *)ttynm, &msg) == 0) {
284 success = 1; 285 success = 1;
285 if (msg != NULL && loginmsg != NULL && !msg_done) { 286 if (msg != NULL) {
286 debug("AIX/loginsuccess: msg %s", msg); 287 debug("AIX/loginsuccess: msg %s", msg);
287 buffer_append(loginmsg, msg, strlen(msg)); 288 if (lastlogin_msg == NULL)
288 xfree(msg); 289 lastlogin_msg = msg;
289 msg_done = 1;
290 } 290 }
291 } 291 }
292 aix_restoreauthdb(); 292 aix_restoreauthdb();
293 return (success); 293 return (success);
294} 294}
295 295
296char *
297sys_auth_get_lastlogin_msg(const char *user, uid_t uid)
298{
299 char *msg = lastlogin_msg;
300
301 lastlogin_msg = NULL;
302 return msg;
303}
304
296# ifdef CUSTOM_FAILED_LOGIN 305# ifdef CUSTOM_FAILED_LOGIN
297/* 306/*
298 * record_failed_login: generic "login failed" interface function 307 * record_failed_login: generic "login failed" interface function
diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h
index ecb9feae8..967bc7235 100644
--- a/openbsd-compat/port-aix.h
+++ b/openbsd-compat/port-aix.h
@@ -1,4 +1,4 @@
1/* $Id: port-aix.h,v 1.29 2008/03/09 05:36:55 dtucker Exp $ */ 1/* $Id: port-aix.h,v 1.30 2009/08/16 23:40:00 dtucker Exp $ */
2 2
3/* 3/*
4 * 4 *
@@ -87,6 +87,8 @@ void aix_usrinfo(struct passwd *);
87int sys_auth_allowed_user(struct passwd *, Buffer *); 87int sys_auth_allowed_user(struct passwd *, Buffer *);
88# define CUSTOM_SYS_AUTH_RECORD_LOGIN 1 88# define CUSTOM_SYS_AUTH_RECORD_LOGIN 1
89int sys_auth_record_login(const char *, const char *, const char *, Buffer *); 89int sys_auth_record_login(const char *, const char *, const char *, Buffer *);
90# define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG
91char *sys_auth_get_lastlogin_msg(const char *, uid_t);
90# define CUSTOM_FAILED_LOGIN 1 92# define CUSTOM_FAILED_LOGIN 1
91#endif 93#endif
92 94
diff --git a/sshlogin.c b/sshlogin.c
index dff47b6f7..33bd652fb 100644
--- a/sshlogin.c
+++ b/sshlogin.c
@@ -93,6 +93,13 @@ store_lastlog_message(const char *user, uid_t uid)
93 if (!options.print_lastlog) 93 if (!options.print_lastlog)
94 return; 94 return;
95 95
96# ifdef CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG
97 time_string = sys_auth_get_lastlogin_msg(user, uid);
98 if (time_string != NULL) {
99 buffer_append(&loginmsg, time_string, strlen(time_string));
100 xfree(time_string);
101 }
102# else
96 last_login_time = get_last_login_time(uid, user, hostname, 103 last_login_time = get_last_login_time(uid, user, hostname,
97 sizeof(hostname)); 104 sizeof(hostname));
98 105
@@ -107,6 +114,7 @@ store_lastlog_message(const char *user, uid_t uid)
107 time_string, hostname); 114 time_string, hostname);
108 buffer_append(&loginmsg, buf, strlen(buf)); 115 buffer_append(&loginmsg, buf, strlen(buf));
109 } 116 }
117# endif /* CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG */
110#endif /* NO_SSH_LASTLOG */ 118#endif /* NO_SSH_LASTLOG */
111} 119}
112 120