Discussion:
su and environmnet
(too old to reply)
Eric
2010-06-28 20:12:22 UTC
Permalink
On my S8 system when I su to root I get an odd PATH environment. It's
not inheriting the path from the original user and it doesn't seem to
be picking up anything from root's .profile, .cshrc or .login (which
is absent anyway).

My questions: When I su (to root) where is root getting its path
from? Note I'm not using the "-" option (I'm not the only person who
has to do this and no one here's going to remember it anyway). The
man page for "su" says it's supposed to inherit the original user's
path but that doesn't seem to be true.

What file(s) do I need to edit to get the path I want when I su to
root (again, without the "-" option)?

TIA
eric
Lordgnome
2010-06-28 20:31:36 UTC
Permalink
Post by Eric
On my S8 system when I su to root I get an odd PATH environment. It's
not inheriting the path from the original user and it doesn't seem to
be picking up anything from root's .profile, .cshrc or .login (which
is absent anyway).
My questions: When I su (to root) where is root getting its path
from? Note I'm not using the "-" option (I'm not the only person who
has to do this and no one here's going to remember it anyway). The
man page for "su" says it's supposed to inherit the original user's
path but that doesn't seem to be true.
What file(s) do I need to edit to get the path I want when I su to
root (again, without the "-" option)?
TIA
eric
My memory may be fading, as I have been retired from admining for 10 years,
but would a possible suggestion be that SU takes you into a Bourne shell
(unless the root account is changed) and thus if you are relying on your
environment coming from a C shell, there would be no .profile to read from?

Les.
Martin Carpenter
2010-06-28 20:58:00 UTC
Permalink
When I su (to root) where is root getting its path from?
Have you tried /etc/default/su?
Eric
2010-06-28 21:14:51 UTC
Permalink
Post by Martin Carpenter
When I su (to root) where is root getting its path from?
Have you tried /etc/default/su?
Ah, okay. So if I su to root, root takes on the path environment
specified in supath? Can that path be overridden from some other
file?

Thanks,
eric
Richard B. Gilbert
2010-06-28 23:11:34 UTC
Permalink
Post by Eric
Post by Martin Carpenter
When I su (to root) where is root getting its path from?
Have you tried /etc/default/su?
Ah, okay. So if I su to root, root takes on the path environment
specified in supath? Can that path be overridden from some other
file?
Thanks,
eric
What problem are you trying to solve?
Eric
2010-06-28 23:38:31 UTC
Permalink
Post by Richard B. Gilbert
Post by Martin Carpenter
When I su (to root) where is root getting its path from?
Have you tried /etc/default/su?
Ah, okay.  So if I su to root, root takes on the path environment
specified in supath?  Can that path be overridden from some other
file?
Thanks,
eric
What problem are you trying to solve?
Well, I think the problem is pretty much solved (edit supath in /etc/
default/su). The point of my follow-on question is just to sort of
round out my knowledge.

eric
Martin Carpenter
2010-06-29 03:43:47 UTC
Permalink
Post by Eric
So if I su to root, root takes on the path environment
specified in supath?
Yes, if you don't specify "su -" (as you noticed).
Post by Eric
Can that path be overridden from some other file?
No, it's hardcoded in su.c:

#define DEFFILE "/etc/default/su"


This is curious, from su.c's header:

/* Copyright (c) 1987, 1988 Microsoft Corporation */
/* All Rights Reserved */

(from OpenSolaris).
Casper H.S. Dik
2010-06-29 09:23:11 UTC
Permalink
Post by Eric
On my S8 system when I su to root I get an odd PATH environment. It's
not inheriting the path from the original user and it doesn't seem to
be picking up anything from root's .profile, .cshrc or .login (which
is absent anyway).
My questions: When I su (to root) where is root getting its path
from? Note I'm not using the "-" option (I'm not the only person who
has to do this and no one here's going to remember it anyway). The
man page for "su" says it's supposed to inherit the original user's
path but that doesn't seem to be true.
What file(s) do I need to edit to get the path I want when I su to
root (again, without the "-" option)?
It should come from /etc/default/su (SUPATH option for root, PATH for
ordinary users)

Depending on the root's shell, it may get the path set by the
init scripts (many shells will source a .file when they are interactive
started)

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Loading...