Thomas. Yep, this is an interesting thread... and I do apologise for my slight inaccuracies :-(
Yes, but do not forget, peter, that GNU have added a bazillion of > > options ontop of the standard UNIX ones....
'... at it's heart is the idea that the power of a system comes from the relationships among programs than from the programs themselves. Many UNIX programs do quite trivial tasks in isolation, but, combined with other programs, become general and useful tools...' (Kernighan and Pike) Sorry, couldn't resist that :-) Peter. On Mon, 2003-07-28 at 10:33, Thomas Adam wrote:
--- Peter Wilson <peter.wilson@tuxite.com> wrote:
As far as my understanding of the philosophy of su is concerned, the default action is not to perform a 'login' but to change the effective guid and uid of the shell, this is the function of the '-' or '-l'
Yes, you are right when you say that a normal "su" changes the effective UID **and** GID, but that is only for the $USER, and NOT for the shell as you write above :) the shell does not have U{G}ID's!!! You're slightly in error when you say that "-" or "-l" is all that those options do, apart from changing the UID/GID of the $USER concerned. I have been intrigued by by this thread ever since it started and have ran several degenerative tests, not to mention several "strace"()'s.
"su -" (su -l) creates a login shell, i.e. "~/.bashrc" is read upon startup. Furthermore, the environment variables:
SHELL TERM PATH HOME
are all changed.
With a plain "su" however, only $SHELL and $LOGNAME, $HOME should be changed, UNLESS you have them defined in ~/.bashrc!!!
Thus, what I am suspecting is that in your "/root/.bashrc" file you have PATH being exported. I'd most likely comment this out, as it is already pre-defined in /etc/profile for root anyhow... The reason why ~/.bashrc is read is because "su" is interactive.
That way, when you either "su" or "su -" it will be alright :)
To counteract the effects of this, issue:
su -m [user]
which will leave the environment un-modified.
parameter, therefore it should certainly not source the target users rc or profile files. I'm not sure why some implementations of su on *nix change the path variable (even RedHat doesn't... probably an oversight while wondering how to make it even more difficult to use Wine) , and if they do I would hope that it's documented :-)
The parlance for "su" on UNIX systems kept changing...
In regard to newbie manuals, I've been working on unix systems since 1989 (would have thought I would have learnt my lesson by now, or at least something) and I still bash them repeatedly on my head (how can Kernighan and Pike write 'The UNIX programming environment' in about the same space as my UNIX shell quick reference?)
Yes, but do not forget, peter, that GNU have added a bazillion of options ontop of the standard UNIX ones....
HTH,
-- Thomas Adam
Peter. (tired, friday, ten past four and it's raining)
On Fri, 2003-07-25 at 13:25, Thomas Adam wrote:
--- richard@tortoise.demon.co.uk wrote:
Hi Thomas,
Richard,
could you bear with me on this?
Sure, of course. You must forgive me if my tone appears slightly angry, that is *most definitely* not my intent. I find this most interesting.
I don't think /etc/profile is executed if I su to root. If I put
something like echo "here we are in /etc/profile" at the start of it, I never see the echo when I su
Of course not. I am taking that last sentence literally when you say "su" and not "su -". If you just "su", then yes, you will get to be user "root", but all that has done is to change your effective $UID and $GID. NO environment variables are modified with a plain "su".
Ok, so no environment variables are modified. $PATH is an environmental variable.
$PATH is indeed an environment variable. If you were to type in "exports", you'd see a huge list of them.
richard@linux:~ > echo $PATH
/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/lib/java/bin:/var/lib
/dosemu:/usr/games/bin:/usr/games:/opt/gnome/bin:/opt/kde2/bin:/opt/kd
e/bin:/usr/openwin/bin:.:/opt/gnome/bin:/opt/pilotsdk/bin richard@linux:~ > su Password: root@linux:/home/richard > echo $PATH /usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin
So a plain su HAS modified an environmental variable. PATH wasn't constructed after su within /etc/profile because /etc/profile wasn't run.
So the question remains, where does the new path come from?
I'm likely being thick here.
No, Richard far from it :) I think I should start checking my facts. I use suSE 6.4 on my server and my story stands thus far, yet I am suspecting now that a plain "su" does indeed modify $PATH, perhaps from sourcing "~/.bashrc" and "~/.bash_profile", which *might* contain a new $PATH export. BUT, if that were the case then the second $PATH you listed there would be the exported one when you logged into root's account normally.
One thing I am going to suggest is you *try* the following:
su -c'bash -norc'
That would effectively stop bash from reading ~/.bashrc et al on "su". My only suspicion here is that by doing that command above, you'd be creating a subshell within the su'ed account...
I've just ran "strace su" and a plain "su" does read ~/.bashrc :) :) Therefore, if you have export PATH in "~/.bashrc", I would either comment it out, or...
su -m
would also stop this from happening.
I am off now to hit myself repeatedly, after which I am then going to go and read Newbie_Linux_Guide, and then I am going to apologise for dragging this thread out far too long, and giving everybody the creeps.
Sorry :)
-- Thomas Adam
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
________________________________________________________________________
Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/