From 18c533edf8079a7d03594c8959e03b20b817ca8a Mon Sep 17 00:00:00 2001 From: Stefan Fiedler Date: Mon, 9 Apr 2007 18:12:27 +0000 Subject: [PATCH] Stefan Fiedler: sysfiles: add */sbin directories to PATH in /etc/profile not only if / is writeable but also if the user is root. - If /etc/profile doesn't include /sbin dirs in PATH, many init scripts will fail pretty badly, but on bootup, / may not yet be writeable (until the localfs init script has been executed). - Generally, on bootup init calls /etc/rc.d/rc, which in turn calls /sbin/rc for each init script. /sbin/rc spawns a login bash for every script, which sources /etc/profile. Init exports the default PATH ("/bin:usr/bin:/sbin:/usr/sbin") to all its children and thus to /etc/profile (since /sbin/rc copies it to the bash environment). /etc/profile just resets the PATH - if there is no /etc/profile, the init scripts will use the default PATH. [2007040902041895570] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@8321 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- package/base/sysfiles/etc_profile.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/package/base/sysfiles/etc_profile.txt b/package/base/sysfiles/etc_profile.txt index 0eb1fb016..d3e7012b7 100644 --- a/package/base/sysfiles/etc_profile.txt +++ b/package/base/sysfiles/etc_profile.txt @@ -20,15 +20,18 @@ # # --- ROCK-COPYRIGHT-NOTE-END --- +# determine the effective user id +EUID="$( id -u )" + # set the PATH-variable export PATH="" -for _bindir in $HOME/bin /usr/local/bin /usr/bin /bin /usr/X11/bin \ +for _bindir in $HOME${HOME:+/bin} /usr/local/bin /usr/bin /bin /usr/X11/bin \ /usr/games /usr/local/games /opt/*/bin /opt/*/games do if [ -d "$_bindir" ]; then PATH="$PATH${PATH:+:}$_bindir" fi - if [ -w / ]; then + if [ -w / -o "$EUID" == 0 ]; then _sbindir=${_bindir/%\/bin/\/sbin} if [ "$_bindir" != "$_sbindir" -a -d "$_sbindir" ]; then PATH="$PATH${PATH:+:}$_sbindir" @@ -94,5 +97,5 @@ for x in /etc/profile.d/* /etc/conf/profile ; do [[ $x == *.csh ]] && continue [ -f $x ] && . $x done -unset x +unset EUID x