quote:
is the pathmunge thing RH specific then? by that i mean it won't work with other systems
No. Pathmunge() is just a function, defined in the /etc/profile file. When /bin/bash is executed, it first looks in the user's home directory (and this includes ROOT) for a .bash_profile file. If it doesn't find one there, it then goes into the system-wide applicable /etc/profile file to get its instructions. From my experience, BASH is BASH. When you type in a command (let's use mplayer as an example ) BASH will first search the .bash_profile file for "mplayer" (it its PATHs), and if it can't find it in that PATH, or the .bash_profile doesn't exist, it checks the PATH in /etc/profile. It runs the same way no matter what distro it is installed on.
quote:
if i added a lot of pathmunge to my /etc/profile would it just not work because it's not red hat?
It will work. Out of curiosity, I tried it tonight on Debian Woody, and it works fine. I'll post my /etc/profile below with all of the comments with the modifications I made.
quote:
if i copied /etc/profile into /root as .bash_profile would i replicate the vulnerability, or is that red hat specific also? (what is this vulnerability anyway?)
Depending on what is in your /etc/profile, you would not want to copy its entire content's to /root/.bash_profile. Why you would want to do that is beyond me
As for the security vulnerability, I came across it when I was inquiring about pathmunge() on Red Hat's website for WJ / Bob. I flipped through a page that gave a run-down ofthe vulnerability, but since I don't run Red Hat, I really didn't pay much attention to it. Now, I can't find the damned thing to save my life.
.
To sum it all up, I just think that this is another one of Red Hat's gimmicks of trying to be different. It is simplified, in that pathmunge takes care of both Root's and User's PATHs all in one shot. You can also structure the if/else ladded with the UID numbers (the if [ `id -u` = 0 ] part) to incorporate PATHs for users more efficiently. For example, if you are a SysAdmin at a programming company, and you have 200 people on your system, you first would assign a UID and then a GID to every person. If 100 of those people don't have write permission, even in their home directories (they would most likely have one folder in which they could compile their stuff), I guess this would save time from having to create 200 .bash_profile files in each user's directory. With this function, it allows you to assign PATHs to certain programs with either UID or GID, etc., and keeps it all in one place. Or if you had a group of people working on C projets, and a group of people working on Java projects, you could distribute permissions and paths more easily with this pathmunge function.
If you want to try it out, go for it. Just make sure you back-up /etc/profile before you get busy with it.
Here is my /etc/profile (with modifications and the pathmunge fucntion)
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
#PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
#JAVA_HOME="/usr/lib/j2se"
###
The above two line I commented to test out pathmungepathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|
$1($|i
" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# Path manipulation
# if UID = Root
if [ `id -u` = 0 ]; then
#Set the superuser's PATH
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
# Here you could get fancy, and set a normal user's path to whatever you wanted
# if [ `id -u` = 1000]; then
# Set the person with UID 1000, my normal account, in this case
# pathmunge /usr/local/bin
# pathmunge /copperhead/bin
# fi
# the path for ALL users
pathmunge /usr/X11R6/bin after
pathmunge /usr/games after
# unset the function so it doesn't execute continuously
unset pathmunge
# Basic default shell prompt configuration
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
export PATH PS1
#export JAVA_HOME
# end /etc/profile
Hope that helps. Try it out
[ May 15, 2003: Message edited by: Copperhead ]