diff options
Diffstat (limited to 'src/su.c')
-rw-r--r-- | src/su.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -173,7 +173,10 @@ log_su (struct passwd const *pw, bool successful) { /* getlogin can fail -- usually due to lack of utmp entry. Resort to getpwuid. */ - struct passwd *pwd = getpwuid (getuid ()); + errno = 0; + uid_t ruid = getuid (); + uid_t NO_UID = -1; + struct passwd *pwd = (ruid == NO_UID && errno ? NULL : getpwuid (ruid)); old_user = (pwd ? pwd->pw_name : ""); } tty = ttyname (STDERR_FILENO); |