Bug 453

Summary: sudo 1.7.4p4 yields incorrect who -m (who am i) output
Product: Sudo Reporter: Kent Squires <ksquire>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: low    
Version: 1.7.4   
Hardware: IBM   
OS: AIX   

Description Kent Squires 2010-12-10 15:16:54 MST
AIX: 5300-12-02
using many sudo 1.7.4p4 binaries, including the one from ftp://ftp.sudo.ws/pub/sudo/packages/AIX/5.3/sudo-1.7.4-5.ppc.rpm, yields the following

butthead:/home/ksquires >sudo su - root
butthead:/ >who am i
root      pts/1 

it should yield the following format
butthead:/home/ksquires >su - root
root's Password:
butthead:/ >who am i
ksquires    pts/0       Dec 10 12:52     (192.168.1.241) 

the 1.7.2 binaries seem to function properly in this respect
Comment 1 Kent Squires 2010-12-10 16:01:21 MST
it doesn't appear to be working under Linux either:

under Red Hat Enterprise Linux AS release 4
$ sudo who am i
$ 
(no output)
Comment 2 Todd C. Miller 2010-12-10 16:46:11 MST
This doesn't sound like a sudo problem to me.  I've tried sudo 1.7.4p4 on both AIX 5.3 and RHEL 4 and "who am i" behaves as expected.

-bash-3.1$ uname -a
AIX vasaix53 3 5 0000C68AD300
-bash-3.1$ who am i
tmiller     pts/1       Dec 10 15:27     (10.5.56.147)
-bash-3.1$ sudo who am i
tmiller     pts/1       Dec 10 15:27     (10.5.56.147)   
-bash-3.1$ sudo  su -
-bash-3.1# who am i
tmiller     pts/1       Dec 10 15:27     (10.5.56.147)   

The who command uses the contents of the utmp (and/or utmpx) file to determine the actual user.  Depending on how sudo is configured, it may allocate a new pty to run the command in, for which there will be no corresponding utmp entry.  In this case, the who command will lookup the user based on the effect uid, which will be the invoking user.

For instance, if the log_input, log_output or use_pty options are specified in sudoers, sudo will run the command in a new pty. Do you have any of those configured in sudoers?  Here's what I get when log_output is defined:

-bash-3.1$ who am i
tmiller     pts/1       Dec 10 15:27     (10.5.56.147) 
-bash-3.1$ sudo who am i
root      pts/2 

There are no details other than the user and tty name since there is no corresponding utmp entry (as this is not a real login).
Comment 3 Kent Squires 2010-12-10 16:53:51 MST
ok, I do have log_input and log_output defined.  Is there a way to get sudo who am i to report "properly" with these settings defined? I *love* the log_input/output feature, but using them is messing up some other stuff because of the sudo who am i output.
Comment 4 Todd C. Miller 2010-12-21 10:18:07 MST
Reopening as an enhancement to add utmp/wtmp support when a new pty is allocated.
Comment 5 Todd C. Miller 2011-03-22 09:43:50 MDT
Sudo 1.7.6 and 1.8.1 will include support for updating the utmp file which will allow "who am i" to work as you expect it to.

Beta versions of each are now available, see http://www.sudo.ws/sudo/devel.html
Comment 6 Todd C. Miller 2011-04-12 12:03:03 MDT
Sudo 1.7.6 and 1.8.1 have support for writing to the utmp file.