[NTLUG:Discuss] SuSE 9 or 9.1 PATH environment changes after su
Terry
trryhend at gmail.com
Sat Sep 11 15:14:58 CDT 2004
On Fri, 10 Sep 2004 23:36:30 -0500, Kevin Brannen <kbrannen at pwhome.com> wrote:
> Ralph Green, Jr wrote:
>
> >Howdy,
> > Another list member has told me off-list that he does not believe me
> >when I told him that the PATH environment variable changed after I did
> >an su to root. I tried this on SuSE 9 and 9.1 and I did not pass any
> >parameters to the su command(i.e., su, not su -). Can anyone else here
> >tell me what their SuSE system does? If you have tweaked your system to
> >change this behavior from it's default, then please tell me that, too.
> >
> >
>
> You mean like:
>
> [1 ~ /home/kevin] echo $PATH
> .:/home/kevin/bin/Linux:/home/kevin/bin/scripts:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/opt/gnome/bin:/opt/tcm/bin:/opt/pgsql/bin:/opt/svn/bin:/opt/kde3/bin:/home/kevin/toolbox/lib
> [2 ~ /home/kevin] su
> Password:
> dilbert:/home/kevin # echo $PATH
> /usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin
>
> That's what I'd expect because when it switches user, it should execute
> the new user's .bashrc (or the default in /etc somewhere if the new user
> doesn't have one [my root person does not]).
>
> Or we could read the man page, :-)
>
> ---
> -m, --preserve-environment
> do not reset environment variables
> ---
>
> Seeing that is has this option, I'd say that the default is that is will
> reset the env-vars. Let's try it:
>
> [8 ~ /etc] su
> -m
> Password:
> [2 ~ /etc] id
> uid=0(root) gid=0(root) groups=0(root)
> [3 ~ /etc] echo $PATH
> .:/home/kevin/bin/Linux:/home/kevin/bin/scripts:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/opt/gnome/bin:/opt/tcm/bin:/opt/pgsql/bin:/opt/svn/bin:/opt/kde3/bin:/home/kevin/toolbox/lib
>
> Gee whiz, look at that. :-) Of course, that probably only applies to
> the GNU su command (I have Suse 9.0). On other Unixes it may be
> different. I have no idea what the Posix standard says.
>
> <soapbox>
> And like so many other places, GNU wants you to go read info files to
> find out how the command really works because they're too lazy to make
> proper man pages (or is it arrogant because they think "info" is
> better?). A pox on them for this stupidity!
> </soapbox>
>
Maybe one of us concerned citicizens [/users] shoud re-write the man
file for them. (Maybe they're just busy, not lazy).
</soapboz> :)
More information about the Discuss
mailing list