Description of Problem:
Mkaing su to root does not set enviroment variable USER or LOGNAME to
which are left set to the user issuing su. Incidently, HOME variable is
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
Version-Release number of selected component (if applicable):
Steps to Reproduce:
2. echo $USER $LOGNAME
LOGNAME=root (or I'd even think, LOGNAME=olduser)
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]$ su lena
[lena@dima]$ echo $USER $LOGNAME
[root@dima]# echo $USER $LOGNAME
2) But in general, why is su not supposed to change USER ? From su man page
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
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.