]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
su: use LOG_PID for syslog
authorSam James <sam@gentoo.org>
Fri, 7 Jan 2022 01:54:41 +0000 (01:54 +0000)
committerSam James <sam@gentoo.org>
Fri, 7 Jan 2022 01:58:20 +0000 (01:58 +0000)
Enable PID in syslog lines for `su`.

In Gentoo Linux, we recently switched `su` providers from
shadow to util-linux.

It was notiiced that syslog output differs slightly
with util-linux (no PID):
```
Jan  7 20:00:50 localhost su: (to root) root on pts/5
Jan  7 20:00:50 localhost su: pam_unix(su:session): session opened for user root(uid=0) by sam(uid=0)
```
... whereas shadow's `su` gave (with PID):
```
Jan  7 20:52:50 localhost su[22245]: Successful su for root by root
Jan  7 20:52:50 localhost su[22245]: + /dev/pts/5 root:root
```

This change enables PID logging to give shadow-like syslog
output for `su`:
```
Jan  7 20:54:32 localhost su[10827]: (to root) root on pts/6
Jan  7 20:54:32 localhost su[10827]: pam_unix(su:session): session opened for user root(uid=0) by sam(uid=0)
```

Signed-off-by: Sam James <sam@gentoo.org>
login-utils/su-common.c

index e57ff64bdb60977e3cad3dd316d1812cee3bb54c..f71dbf928d30e23e9232ba27a85e2a9b526658a2 100644 (file)
@@ -288,7 +288,7 @@ static void log_syslog(struct su_context *su, bool successful)
 {
        DBG(LOG, ul_debug("syslog logging"));
 
-       openlog(program_invocation_short_name, 0, LOG_AUTH);
+       openlog(program_invocation_short_name, LOG_PID, LOG_AUTH);
        syslog(LOG_NOTICE, "%s(to %s) %s on %s",
               successful ? "" :
               su->runuser ? "FAILED RUNUSER " : "FAILED SU ",