Bug 15881 - strange PATH settings
strange PATH settings
Status: CLOSED WORKSFORME
Product: Red Hat Linux
Classification: Retired
Component: util-linux (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Elliot Lee
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-08-09 14:31 EDT by Michael Redinger
Modified: 2007-04-18 12:28 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-14 14:58:54 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Michael Redinger 2000-08-09 14:31:10 EDT
Just noticed some strange things doing an echo $PATH (from different
environments):

non-root user
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/c102mr/bin

root
/usr/local/sbin:/usr/sbin:/sbin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:\
/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

root (su - from non-root user)
/usr/local/sbin:/usr/sbin:/sbin:/usr/kerberos/sbin:/usr/kerberos/bin:/bin:/sbin:\
/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin

non-root user ( su - from non-root user to root, su - to non-root user)
/usr/kerberos/bin:/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:\
/home/c102mr/bin

rsh non-root user
/usr/bin:/bin

rlogin non-root user
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/c102mr/bin


Some notes:

- the PATH of normal users should probably end with ":" to include the
  current directory. This is one of the most FAQ ...

- I think it should be /usr/bin/X11, not /usr/X11R6/bin (for compatibility
  reasons with other Unix Platforms)
- for non-root it should be  
  /usr/kerberos/bin:/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:$HOME/bin:

- the root path is really messed ... should read:
  /sbin:/usr/sbin:/usr/kerberos/sbin:/usr/local/sbin:/usr/kerberos/bin:\
  /bin:/usr/bin:/usr/bin/X11:/usr/local/bin:$HOME/bin

- su - does mess up your path

- rsh should have better path settings ... at least include /usr/bin/X11
and
  /usr/local/bin
  (how is this done? pam_env?)


Think this is a MUST-FIX.
Comment 1 Bernhard Rosenkraenzer 2000-08-09 14:44:37 EDT
The initial paths are set by login (util-linux)
Comment 2 Michael Redinger 2000-08-09 17:55:58 EDT
Right, but they are treated quite differently by the different programs. Eg.
some programs do read profile, some don't. Same for bashrc. I think the path
should be right before these files are accessed. I had a very quick look at
/etc/security/pam_env.conf (used by pam_env), and it looked as if this could
some of these problems (could be wrong, but it looked nice .. :) ).
Comment 3 Michael Redinger 2000-08-13 12:15:12 EDT
Same in RC1, changing version.

There's a bug that's possibly related to this - see bug #16004
Comment 4 Glen Foster 2000-08-13 14:00:24 EDT
I agree that paths should be consistenty set given various methods to obtain
access to a specific user-ID.  I do not agree, however, with some of the
specific recommendations made.  Regardless, this is an issue that could be much
farther-reaching than just in bash or with /etc/profile, and should be deferred
to the next release of Red Hat Linux.  There's simply not enough time to
completely investigate this defect and make a complete change prior to releasing
Winston.  Marking as DEFERRED.
Comment 5 Michael Redinger 2000-12-22 15:34:55 EST
Same in Florence Beta 1, therefore reopening.

Some test results (note that I couldn't test rsh yet as it doesn't work for me.)

xterm -ls:
/usr/bin:/bin:/usr/X11R6/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:\
/home/c102mr/bin:/usr/X11R6/bin:/usr/X11R6/bin:/home/c102mr/bin

xterm:
/usr/bin:/bin:/usr/X11R6/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:\
/home/c102mr/bin:/usr/X11R6/bin


xterm -e su -:
/usr/local/sbin:/usr/sbin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:\
/usr/local/bin:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin

xterm -e su:
/usr/bin:/bin:/usr/X11R6/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:\
/home/c102mr/bin:/usr/X11R6/bin

xterm -e su -, then su - to normal user:
/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/home/c102mr/bin


telnet:
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/c102mr/bin


Comment 6 Gerald Teschl 2000-12-28 07:56:04 EST
This should really be fixed! You could at least apply the patch from
below /etc/profile and make similar changes to the other init scripts.

--- profile.orig        Thu Dec 28 13:41:11 2000 
+++ profile     Thu Dec 28 13:42:49 2000
@@ -3,7 +3,10 @@
 # System wide environment and startup programs
 # Functions and aliases go in /etc/bashrc
 
-PATH="$PATH:/usr/X11R6/bin"
+if echo $PATH | grep -vq /usr/X11R6/bin
+then
+        PATH="$PATH:/usr/X11R6/bin"
+fi
 
 ulimit -S -c 1000000 > /dev/null 2>&1
 if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
Comment 7 Erik Troan 2001-02-08 19:06:20 EST
The grep suggestion is in the current setup package, and correct.

Some of this is invalid:

	1) /usr/X11R6/bin is the canonical location, and /usr/bin/X11 is a
	   compatibility symlink (according to FHS), so we do this correctly

	2) Leaving . out of users paths is quite concsious, and intended to
	   prevent users from running the wrong programs inadvertently
	   there's pretty widespread agreement this is a good security policy

	3) are paths are essentialy the ones you suggest, though the order
	   differs a bit

	4) the rsh/telnet paths look okay to me.... (sorry)

I think the most obviously correct part of this has been addressed in the setup
package, and I'm going to close the rest of this.
Comment 8 Michael Redinger 2001-04-02 05:54:59 EDT
Reopening this for RC2, QA0328:

I think this is really broken - the path settings are inconsistent, some are
definitely wrong:

-----

login as normal user on console:
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/c102mr/bin

(looks good!)

xterm -ls as normal user in KDE:
/usr/kerberos/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/home/user/bin:/ho
me/user/bin

(the user's home directory is listed twice; local/bin should be the first bin
directory listed)
(see "rsh localhost as normal user")



login as root on the console:
/usr/local/sbin:/usr/sbin:/sbin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/
sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

(/usr/local/sbin, /usr/sbin and /sbin are listed twice; /root/bin shouldn't
be there - your mileage may vary ...)



login as normal user, then su - to root:
/usr/local/sbin:/usr/sbin:/sbin:/usr/kerberos/sbin:/usr/kerberos/bin:/bin:/sbin:
/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/r
oot/bin

(quite different, right? This is _really_ broken)
(please note /usr/bin/X11:/usr/X11R6/bin)

-----

login as normal user, then su to root:
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
:/home/c102mr/bin

xterm -ls in kde, then su to root:
/usr/kerberos/sbin:/usr/kerberos/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin
:/home/user/bin:/home/user/bin

(the sbin directories,except for kerberos, are missing; include them or
remove /usr/kerberos/sbin, too.; note that the user home directory is now
listed twice.)

-----

rsh localhost as normal user:
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/user/bin

(this one's fine ...)


rsh localhost as normal user, then su to root:
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
:/home/user/bin

(similar to "su to root", but much better ...)



-----

rsh localhost as root:
/usr/local/sbin:/usr/sbin:/sbin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/
sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

(again - some sbin directories are listed twice.)

-----
Comment 9 Michael Redinger 2001-07-07 13:09:32 EDT

Looks much better in Fairfax. But there are some issues left:



- every login method has a different path (at least the order differs)

  (well, ssh and rlogin are identical with console login, but that's not

  really surprising ...)

- there are many duplicate entries

- console root login: /usr/local/sbin, /usr/sbin and /sbin are listed twice

- kde root login (no, I don't use this!):

      /sbin and /usr/sbin are listed twice

- gnome root login (neither this one ...):

      /sbin and /usr/sbin are listed twice

- rsh is very different, as usual ... it simply sets the path to

      /usr/bin:/bin (yes, it's hardcoded ...). :(





The gory details: ;)



console:

user:

/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/c102mr/bin

root:

/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin







kde:

user:

/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/home/c102mr/bin:/home/c102mr/bin 

root:

/usr/local/sbin:/usr/sbin:/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/root/bin







gnome:

user:

/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/home/c102mr/bin

root:

/usr/local/sbin:/usr/sbin:/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/root/bin







ssh:

user:

/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/c102mr/bin

root:

/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin







rlogin:

user:

/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/c102mr/bin

root:

/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin







rsh (rsh host 'echo $PATH'):

user:

/usr/bin:/bin

root:

/usr/bin:/bin



Comment 10 Elliot Lee 2001-07-17 17:54:53 EDT
. Multiple entries are cosmetically broken if at all, and the fixes for them are
usually uglier than the problem.

. The different path settings based on how the shell is started are
normal/traditional. There certainly is not presently a universal way of
configuring the 

. A lot of the differences for different logins are on purpose.

I'm not sure there are any real bugs here. Can you explain what is broken (not
functioning as specified) as opposed to just something you didn't expect?
Comment 11 Jay Turner 2003-04-14 14:58:54 EDT
Closing out due to bit-rot.

Note You need to log in before you can comment on or make changes to this bug.