Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/index.php/Reporting_Bug_Guidelines

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

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
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Pierre Schmitz (Pierre)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

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

Closed by  Pierre Schmitz (Pierre)
Sunday, 12 December 2010, 23:42 GMT
Reason for closing:  Fixed
Comment by Pierre Schmitz (Pierre) - Monday, 29 November 2010, 14:09 GMT
I think this should already be fixed with the filesystem and bash packages from testing.
Comment by Davie (daschu117) - Monday, 29 November 2010, 17:12 GMT
Aye, that it does. The relevant excerpt from the filesystem package in testing looks like it will get the job done. Thanks!


# 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

Loading...