On Oct 31, 2008, at 11:33 AM, Frédéric Perrin wrote:
When I « su - » to root (after being logged in as my normal user), the
LOGNAME env variable is still set to my previous user, as in :

| [EMAIL PROTECTED]:~% /usr/bin/su -l
| Password:
| root - fred

As far as I can tell, this contradicts the fine manual that says :

| -l Simulate a full login. The environment is discarded except for
|         HOME, SHELL, PATH, TERM, and USER.

So I would have expected LOGNAME to be either empty or set by some shell startup script to be root. So, why is LOGNAME still equal to my previous
user ? (and where is it set ? « grep -r LOGNAME /etc » doesn't turn up

When you "su -l" it invokes /usr/bin/login, which per "man login" sets up up $LOGNAME:

     The login utility enters information into the environment (see
environ(7)) specifying the user's home directory (HOME), command inter- preter (SHELL), search path (PATH), terminal type (TERM) and user name
     (both LOGNAME and USER).

I believe it looks up the actual username from the wtmp record associated with your open tty, so $USER corresponds to the effective userid, but $LOGNAME corresponds to the actual username used to login, aka your "real userid"...?


freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to