On Thursday 11 January 2007 16:55, Leo Peschier wrote:
> Hello all,
>
> If I figured it out correctly, using su to change to root runs the
> /root/.bashrc script, which runs the /etc/bashrc script. So, when
> using the standard .bashrc and bashrc scripts from the BLFS-book, the
> /etc/profile.d/*.sh are not run after su-ing to root. This means for
> instance that the $PATH is reset, which I've always found a bit
> peculiar, but thought it was intentionally set-up that way. Now I've
> noticed that the umask.sh is also not run after su-ing, so the umask
> remains set at 0002, which seems not to be intentional.
> Am I missing something here?
>
> Leo.

Hi Leo,

man bash has a good explanation about bash startup. Particularly, 
INVOCATION.  You basically got it right. :)

When you su it is a non-login shell therefore, /etc/profile is not 
executed. Since it is your system,  you can change the scripts to 
behave the way you want. If it is important that su behaves exactly 
like a root login shell, then change the scripts so they don't check 
the uid of the current user and call /etc/profile from .bashrc.

Or, easier would be...you can force su to create a new login session 
with...
su  -

the '-' tells bash it is a login session, thus forcing the read 
of /etc/profile. see man su.

I imagine the startup scripts are setup this way for security reasons. 
For example, /sbin is not in the users $PATH because the user doesn't 
require access to system commands.

Shawn
-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to