Description of Problem: Mkaing su to root does not set enviroment variable USER or LOGNAME to root, which are left set to the user issuing su. Incidently, HOME variable is set to /root When making su to other, non-root, users, bothe USER and LOGNAME are set to a new user. (actually it is not clear why LOGNAME is set to new user, since su (without -l) presumably does not invokes login shell, I would expect only USER to get new value). Version-Release number of selected component (if applicable): sh-utils-2.0-13 How Reproducible: always Steps to Reproduce: 1. su 2. echo $USER $LOGNAME Actual Results: USER=olduser LOGNAME=olduser Expected Results: USER=root LOGNAME=root (or I'd even think, LOGNAME=olduser) Additional Information:
su isn't supposed to change USER and LOGNAME unless it's invoked as su - (and if it is invoked as su -, it does).
1) on mine clean RH7.1 installation su DOES change both USER and LOGNAME when used to change to regular user. So there is inconcistency. Explicit output (two users - dima and lena) [dima@dima]$ echo $USER $LOGNAME dima dima [dima@dima]$ su lena Password: xxxxxxx [lena@dima]$ echo $USER $LOGNAME lena lena [lena@dima]$ exit [dima@dima]$ su Password: xxxxxxxx [root@dima]# echo $USER $LOGNAME dima dima 2) But in general, why is su not supposed to change USER ? From su man page DESCRIPTION Change the effective user id and group id to that of USER. it seems natural that USER will reflect that change I agree, su probably should not change LOGNAME unless invoked as 'su -', but USER ??? If what you say is right then there is no enviromental variable at all to check for current user. I encountered the problem when tried to make user specific changes in /etc/bashrc.