FS#21862 - [filesystem] Setting PATH late in /etc/profile clobbers /etc/bash.bashrc.local PATH for login shells
Attached to Project:
Arch Linux
Opened by Davie (daschu117) - Sunday, 28 November 2010, 06:07 GMT
Last edited by Pierre Schmitz (Pierre) - Sunday, 12 December 2010, 23:42 GMT
Opened by Davie (daschu117) - Sunday, 28 November 2010, 06:07 GMT
Last edited by Pierre Schmitz (Pierre) - Sunday, 12 December 2010, 23:42 GMT
|
Details
Description:
The ordering of the steps taken by /etc/profile causes PATH to be explicitly set to "/bin:/usr/bin:/sbin:/usr/sbin" after /etc/profile.$shell is called. If using bash as your shell, this will eventually cause /etc/bash.bashrc.local to be called (by way of /etc/profile -> /etc/profile.bash -> /etc/bash.bashrc -> /etc/bash.bashrc.local), but any setting of PATH in this bash.bashrc.local file will be clobbered when /etc/profile explicitly sets the PATH. This only affects login shells (since they source /etc/profile only, but that chainloads /etc/bash.bashrc eventually). Calling bash as a subshell or within screen only sources /etc/bash.bashrc and not /etc/profile. /etc/profile currently contains: # Load shell specific profile settings test -f "/etc/profile.$shell" && . "/etc/profile.$shell" unset shell #Set our umask umask 022 # Set our default path PATH="/bin:/usr/bin:/sbin:/usr/sbin" export PATH If the default path is set before loading shell specific profile settings, then users would be free to place their customized PATH string into /etc/bash.bashrc.local and not have it be clobbered for login shells. This would simply require changing the order in the default /etc/profile that ships with the filesystem package. # Set our default path PATH="/bin:/usr/bin:/sbin:/usr/sbin" export PATH # Load shell specific profile settings test -f "/etc/profile.$shell" && . "/etc/profile.$shell" unset shell #Set our umask umask 022 Additional info: Package: filesystem Version: 2010.09-1 Steps to reproduce: Place the following into /etc/bash.bashrc.local: PATH=/usr/local/bin:/usr/local/sbin:$PATH export PATH Now login via ssh or a tty and view the current PATH with "echo $PATH": /bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/perl5/core_perl/bin Now type "bash" to get a subshell and "echo $PATH" again: /usr/local/bin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/perl5/vendor_perl/bin:/usr/lib/perl5/core_perl/bin |
This task depends upon
# Set our default path
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
export PATH
# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
for profile in /etc/profile.d/*.sh; do
test -x $profile && . $profile
done
unset profile
fi
# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
. /etc/bash.bashrc
fi