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

Re: $PATH and /etc/profile



Michael B Allen wrote:
> Sam Halliday 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"

who said this was the "correct" way? if it was the "correct" way, do you not
think the debian maintainers would have done this a long time ago?

> 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.

it IS differnet. if you start from the console, you should really do `startx &`
to detach from the console and allow you to continue working on the console and
X; hence 2 logins. try `startx`, lock your screen, do a Ctrl-Alt-F1 and realise
that C-c will kill the X session and give whoever is at the machine your console
login. using startx is an arcane way of starting up X. use a login manager.

> > 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.

yes... it IS a login, and sessreg will register it.

> > 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

why? .xsession is there for users to set up their system. perhaps i don't want
the login files to be sourced during my X login? what do i do then? come on...
its one line!

> 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.

exactly. and why should it be reached? it is up to debian to set up the PATH for
each of these window managers, not the user.

> > 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.

do you also have access to a SUN machine? a *BSD machine? all of these systems
have been using this method for years... it is standard. it is the way it is
done. X is NOT a login shell.

> > 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.

hmm, you are correct about not being logged in twice. i could have sworn on my
LFS system last year this counted as 2 logins...

> if you run startx on the console then you *are* logged in twice

this is true. but that is becuase you ARE logged in twice. once in the console,
and once in X.

> 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.

newbies generally don't use .xsession, they use the drop down window to choose a
desktop. curious users use .xsession, and they should be given the correct
answer, which can be solved in userspace... not sysadmin space. X is not a login
shell. besides, how is 

  change:
   /etc/X11/Xsession.d/99xfree86-common_start
  to read:
   exec -l $SHELL -c "$STARTUP"

in any way less cryptic than

  add
    . /etc/profile
    . $HOME/.profile
  (if you use a POSIX shell) to the top of your ~/.xsession file

> > > 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

i agree

> 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.

why don't you direct this question to the debian X maintainers and see what
their response is? i'm sure they will give you a full list... a bug report will
be less hassle to you in the long run if you reply to these kinds of messages on
a weekly basis.

personally... i used to do as you suggest on my LFS system (you can check the
archives for me saying what youare saying now). until i had to use many
different machines and OS and i sat down to write a .xsession file which could
be used on Debian GNU/Linux, LFS, SunOS and FreeBSD. some of those machines i
did not have admin access to. i settled on adding a few lines as it is standard
and it gives me full control of what is set, and isn't set in my X session.

also... having a "standard" way to log in to a desktop (all debian scripts and
selected from the drop down mennu) _should_ be different to a user using their
own .xsession to log into the same desktop, with a different environment (by
that, i mean maybe add an extra directory into PATH). it helps debugging and
support.

cheers,
Sam
-- 
Free High School Science Texts
  http://www.nongnu.org/fhsst/
Sam's Homepages
  http://fommil.homeunix.org/~samuel/
  http://www.ma.hw.ac.uk/~samuel/

Attachment: pgpUNzNS9T2OQ.pgp
Description: PGP signature


Reply to: