]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
su: fix lastlog and btmp logging
authorKarel Zak <kzak@redhat.com>
Mon, 9 Sep 2013 10:24:01 +0000 (12:24 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 9 Sep 2013 10:37:34 +0000 (12:37 +0200)
The su(1) logging code mix ups "old" and "new" passwd structs. The
result is things like

Sep  9 11:50:45 x2 su: (to kzak) kzak on none

in /var/log/messages. The right log entry is

Sep  9 11:50:45 x2 su: (to root) kzak on pts/3

The bug has been introduced by commit c74a7af17c7a176c358dfaa8e1814786c89ebc14.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1005194
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/su-common.c

index ade5c9210aa09dfddfe9dffeddda9933fb3f6255..858af0176ff6b8f82adadec6494e89391fecb390 100644 (file)
@@ -161,7 +161,7 @@ log_syslog(struct passwd const *pw, bool successful)
       old_user = pwd ? pwd->pw_name : "";
     }
 
-  if (get_terminal_name(STDERR_FILENO, NULL, &tty, NULL) == 0 && tty)
+  if (get_terminal_name(STDERR_FILENO, NULL, &tty, NULL) != 0 || !tty)
     tty = "none";
 
   openlog (program_invocation_short_name, 0 , LOG_AUTH);
@@ -483,9 +483,6 @@ authenticate (const struct passwd *pw)
 
 done:
 
-  if (lpw && lpw->pw_name)
-     pw = lpw;
-
   log_syslog(pw, !is_pam_failure(retval));
 
   if (is_pam_failure(retval))