Bug 53068 - su does not change USER or LOGNAME to root
Summary: su does not change USER or LOGNAME to root
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: sh-utils
Version: 7.1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Bernhard Rosenkraenzer
QA Contact: Aaron Brown
Depends On:
TreeView+ depends on / blocked
Reported: 2001-09-03 05:23 UTC by pogosyan
Modified: 2007-04-18 16:36 UTC (History)
0 users

Clone Of:
Last Closed: 2001-09-03 05:23:59 UTC

Attachments (Terms of Use)

Description pogosyan 2001-09-03 05:23:55 UTC
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
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):

How Reproducible:

Steps to Reproduce:
1.  su 
2.  echo $USER $LOGNAME

Actual Results:

Expected Results:
LOGNAME=root   (or I'd even think, LOGNAME=olduser)

Additional Information:

Comment 1 Bernhard Rosenkraenzer 2001-09-03 10:36:39 UTC
su isn't supposed to change USER and LOGNAME unless it's invoked as su - (and 
if it is invoked as su -, it does).

Comment 2 pogosyan 2001-09-03 20:47:55 UTC
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
       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.

Note You need to log in before you can comment on or make changes to this bug.