[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: $PATH and /etc/profile



On Sun, 27 Jun 2004 17:20:21 +0100
Sam Halliday <fommil@yahoo.ie> wrote:

> Bob Proulx wrote:
> > Simon L wrote:
> > > When I log in text mode, the entire PATH is there as I want, I can 
> > > "startx" and when I open a terminal, the PATH is perfect.
> > > Now, if I start the computer with KDM and that I run a terminal, the 
> > > PATH is only: "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"
> > By starting a login shell.  Create ~/.xsession with the following:
> > 
> >   #!/bin/bash --login
> >   exec x-session-manager # or gnome-session or whatever.
> 
> AAAARG! you can't be serious!! .xsession as a LOGIN shell??
> 
> repeat after me... X windows is not your shell!

Right. That's why the correct method is to change:

 /etc/X11/Xsession.d/99xfree86-common_start

to read:

  exec -l $SHELL -c "$STARTUP"

This will exec the session manager though a login shell. This permits the
shell to contibute to the environment (in the case of bash this includes
sourcing /etc/profile).

> 
> Simon, the reason you do not get your PATH set correctly is that if you
> login at a console, /etc/profile will be read because it is a login shell.
> starting X from there will inherit all your settings.

Why is this different from what is happening above? If you run startx you're
starting X from a login shell.

> if however, you login via kdm/gdm/xdm, it is NOT a login shell,

True, I suppose it's not a "shell" but if you're using *dm conceptually it
is a login.

> so /etc/profile
> is not read. there are good reasons for this. if you do not agree with
> these good reasons, then you can simply add the line
>   . /etc/profile
> to your ~/.xsession file.

No. 1) this is an arcane hack that the average user should not have to put
up with and 2) ~./xsession is not executed unless you choose "Default System
Session" -- if you select "KDE" or "WindowMaker" etc the xsession.d scripts
bail out before ~/.xsession is reached.

> doing as Bob suggests and changing your X login to a login shell is NOT
> the way to solve this problem.

Well besides Debian I only have access to a RedHat machine but from looking
at their X scripts the xsession is exec'd through a login shell precisely as
I described. So it's not too far fetched. In fact it makes perfect sense to
me.

> the only reason his solution works is because in the
> process of making X a login shell, /etc/profile will be sourced. in his
> solution you will be seen to be logged in twice.

No. This is false. If you're talking about running /usr/bin/who to see who's
actively logged in then you will not be show as logged in twice if you use
*dm and if you run startx on the console then you *are* logged in twice --
do Ctrl-Alt-F1 and do Ctrl-z then bg and you still have access to that
console. If you're talking about /usr/bin/last to see who has logged in then
you are not shown as having logged in twice if you're using *dm. If you run
startx on the console yes you may be logged has having logged in twice, I'm
not sure. In that case you could create an ~/.xsession to override the
method posted above but we could argue about what the majority would would
want for default bahavior. Personally I think I would rather appear as
having logged in an extra time (like Ctrl-Alt-F2 and login) than be required
to hack some obscure X session control file that newbies are clueless about
and ask about every two weeks.

> > P.S.  Does it seem like I answer this question about every other week?
> 
> i hope you aren't giving this advise to everyone!

He's not. But I *am* and I will continue to because 1) there is a
significant amount of ignorance and disinformation flying around on this
list about this topic and 2) it is the most appropriate solution for
everybody. If you don't agree with that then you will have to point out to
me were there is *any* negative to using the method posted above for *any*
configuration. If you can successfully do that I will include your point in
my advice and leave it to the user to decide.

Mike

-- 
Greedo shoots first? Not in my Star Wars.



Reply to: