Mailinglist Archive: opensuse-edu (194 mails)

< Previous Next >
Re: [suse-linux-uk-schools] updating gcc
  • From: Thomas Adam <thomas_adam16@xxxxxxxxx>
  • Date: Fri, 25 Jul 2003 12:25:23 +0000 (UTC)
  • Message-id: <20030725122509.33378.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
--- richard@xxxxxxxxxxxxxxxxxxxx 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/

< Previous Next >
Follow Ups
References