Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 16346 - /bin/su --login <username> is not giving the correct environment for <username>
Summary: /bin/su --login <username> is not giving the correct environment for <username>
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High major
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-25 08:15 UTC by Andrew Glen-Young
Modified: 2003-02-26 02:27 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Glen-Young 2003-02-25 08:15:58 UTC
While creating an oracle installation script, I noticed that upon issuing the 
command: "su -login -command 'env' oracle" that the environment was not 
correctly set (resulting in the database not starting). I tried this with a 
variety of commands and users and have noticed the same result with /bin/su on 
at least 4 Gentoo 1.4 boxes.

On testing the command on RedHat, the 'su' command completes as expected.

Reproducible: Always
Steps to Reproduce:
1. Login as root.
2. /bin/su -l -c 'whoami' foobar

Actual Results:  
root

Expected Results:  
foobar
Comment 1 Andrew Glen-Young 2003-02-25 08:17:15 UTC
If this bug is a duplicate - I apologise. Searching for 'su' returns many, many results (which I scanned) :(
Comment 2 SpanKY gentoo-dev 2003-02-25 12:17:41 UTC
what if you use `su - <username>` ? 
 
the manpage for su does not list '--login' as a valid option 
Comment 3 Andrew Glen-Young 2003-02-26 01:33:04 UTC
I normally use 'su - ', but this does not work either (ironically I used --login in my summary, etc. to aviod confucsion). The manpage does not list this, but the info page does. 

From 'info su':
`-'
`-l'
`--login'
     Make the shell a login shell.  This means the following.  Unset all
     environment variables except `TERM', `HOME', and `SHELL' (which
     are set as described above), and `USER' and `LOGNAME' (which are
     set, even for the super-user, as described above), and set `PATH'
     to a compiled-in default value.  Change to USER's home directory.
     Prepend `-' to the shell's name, intended to make it read its
     login startup file(s).

From my experience with Linux From Scratch, if I remember correctly, 'su' is contained in more than one GNU utils "package". Perhaps this version does not support the '-' option? This might also explain the differences between the info and manpages? This version seems to come with shadow-utils. The other seems to be from sh-utils (RedHat also uses the sh-utils version). A quick look at the output from ldd for /bin/su (both versions) shows that they both are linked to the same libraries.

Hope this extra info (no pun intended) helps.
Comment 4 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-26 02:27:52 UTC
The info page is from sh-utils (coreutils.info), which have the options for
the su we do not use.  Unfortunately the info file have other usefull info,
so nuking it is not an option I would like to consider.  And su we use
supporting pam, make it more secure than the one from sh-utils.

Please use 'man su' for info on su.

I am marking this as wont fix, as there is no clear middle way :(