The program I am running needs root privledges and therefore is run with sudo
, but it also needs to know what user is running it. getuid
and
A Linux-specific audit_getloginuid()
function provided by the auditing system may be able to help; since pam_loginuid(8)
is only going to be installed for the "main" daemons (sshd
, login
, gdm
, etc.) the audit uid will remain unchanged when sudo(8)
executes.
This will require a little configuration; add:
session required pam_loginuid.so
to the /etc/pam.d/sshd
file -- and whichever other services you allow your users to use.
Ensure pam_loginuid.so
isn't loaded in the /etc/pam.d/sudo
configuration file.