Problem
I am using the "recon" command, which provides another shell. When I type:
# who am iI get blank or the incorrect information returned.
Cause
"recon" functions as an escape sequence reconglomerator. It gives the invoking user a new pseudo-tty and passes input and output between this pty and the user's original tty.
"recon" gives a tty, but doesn't write an entry to /etc/utmp because it isn't a login shell. Being on a tty that has no utmp record creates a situation in which "who am i" may return empty information.
"who" looks up ttyname in /etc/utmp so after executing "recon" there is a new ttyname that isn't in /etc/utmp, so "who" cannot figure out who you are.
Over time /etc/utmp tends to collect errors, one of the most common one is that it will list ttys that are no longer logged in.
/etc/utmp maintains status for all ttys over time, so it contains records for those where the user has not logged out correctly and this is commonly caused by logins disconnecting ungracefully (eg. turning off a Windows client system).
If the tty you get from `recon` is listed in /etc/utmp from an old
session, `who am i` may display something along the lines of:$ tty
/dev/ttyp46
$ who am i
<my_server> ttyp46 Jan 3 11:25
$ recon
$ tty
/dev/ttyp52
$ who am i
. ttyp52 Jan 8 11:43 Solution
A workaround would be to use:# echo "$LOGNAME\t`tty`\t`id`"
root /dev/ttyp2Using "who" will list all the ttys that are currently logged in.
# who
root ttyp1 Jan 10 10:17ie. will not list the new ttyp2 tty used by the "recon" shell.
See also
id(C)
recon(C)
tty(C)
who(C)