Bug 53068 - su does not change USER or LOGNAME to root
su does not change USER or LOGNAME to root
Product: Red Hat Linux
Classification: Retired
Component: sh-utils (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
Aaron Brown
Depends On:
  Show dependency treegraph
Reported: 2001-09-03 01:23 EDT by pogosyan
Modified: 2007-04-18 12:36 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-09-03 01:23:59 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description pogosyan 2001-09-03 01:23:55 EDT
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 06:36:39 EDT
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 16:47:55 EDT
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.