zondag 3 mei 2009

OpenSSH : Server option PrintLastLog does not work on AIX

Introduction:
Currently, the OpenSSH server option "PrintLastLog" does not work on AIX. The last login time is always displayed, disregarding the option.

Impacted:
- OpenSSH <= 5.2p1

Details:
When browsing the source, several functions in loginrec.c were found which solely handle the processing of the last login info (login_get_lastlog, getlast_entry).
Since AIX does not provide such a function natively, the configure script sets the DISABLE_LASTLOG define. A small code snippet from getlast_entry in loginrec.c shows this:

#if defined(DISABLE_LASTLOG)
   /* On some systems we shouldn't even try to obtain last login
    * time, e.g. AIX */
   return (0);


On the other hand, when issuing the AIX loginsuccess() call (which writes a new login record), the last login record can be retrieved by that very same call.
Looking at port-aix.c, the following can be seen:

if (loginsuccess((char *)user, (char *)host, (char *)ttynm, &msg) == 0) {
   success = 1;
   if (msg != NULL && loginmsg != NULL && !msg_done) {
      debug("AIX/loginsuccess: msg %s", msg);
      buffer_append(loginmsg, msg, strlen(msg));
      xfree(msg);
      msg_done = 1;
   }
}


Pointer "msg" points to the new last login info for the user and it always appended to the loginmsg buffer. The buffer_append call should only be called if options.print_lastlog is set.

Resolution:
- Bugzilla item # 1595 was created to address this issue. The item contains patches to the source which solve the issue.

Geen opmerkingen:

Een reactie posten