Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 2731 - X startup fails to initialise a users environment correctly
Summary: X startup fails to initialise a users environment correctly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-14 13:38 UTC by Mark Gawler
Modified: 2003-02-04 19:42 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix to the fix in /etc/X11/Xsession (xsession-patch,523 bytes, patch)
2002-06-02 12:46 UTC, Mark Gawler
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Gawler 2002-05-14 13:38:34 UTC
The start up script for Fluxbox (and possibly other WM) fails to initialise a  
users environment correctly and run the  /etc/profile scripts.  
The X components that are not run / loaded are:  
 ~/.xsession  
 ~/.Xresources  
 ~/.Xdefaults  
 ~/.Xmodmap   
   
A proposed fix for this problem is to replce the existing  
/etc/X11/Session/fluxbox script with the following:  
[code]  
#!/bin/sh  
  
# Fluxbox start-up script, called from /etc/X11/chooser.sh (xdm/kdm)  
# Modified (completely rewritten) by Mark Gawler 12-May-2002  
  
# Load .Xdefaults, .Xmodmap and run /etc/profile, ~/.xsession  
  
# For some reason /etc/profile was not run during the starting of fluxbox so   
# hear seems like a good place to add it.  
source /etc/profile  
  
# The start up of fluxbox seems to be sadly missing the running / loading of  
# the normal user definable stuff when the user logs in via xdm/kdm so we'll  
# do it hear.  
   
startup=$HOME/.xsession  
  
userdefaults=$HOME/.Xdefaults  
userresources=$HOME/.Xresources   
usermodmap=$HOME/.Xmodmap   
  
#Xdefaults  
if [ -f "$userdefaults" ]; then  
    xrdb -merge "$userdefaults"  
fi  
#Xresorces  
if [ -f "$userresources" ]; then  
    xrdb -merge "$userresources"  
fi  
#Xmodmap  
if [ -f "$usermodmap" ]; then  
    xmodmap "$usermodmap"  
fi  
#xsession  
if [ -f "$startup" ]; then  
	if [ -x "$startup" ]; then  
	    source "$startup" &  
	else  
	    source /bin/sh "$startup" &  
	fi  
fi  
  
# And finally we'll start fluxbox,   
/usr/bin/fluxbox  
[/code]
Comment 1 Seemant Kulleen (RETIRED) gentoo-dev 2002-05-21 10:42:50 UTC
to be honest, I do not think it is the window manager's job to do this.  I think
it is the user's job to do this.  In other words, I'm not convinced that this is
a correct thing to do, but I have an open enough mind to consider your argument,
if you'd like to make one..
Comment 2 Seemant Kulleen (RETIRED) gentoo-dev 2002-05-21 10:50:37 UTC
OK, wait, I see your point if it is something that applied to gdm, kdm and xdm
rather than specific window managers.
Comment 3 Seemant Kulleen (RETIRED) gentoo-dev 2002-05-22 06:49:47 UTC
Please read my comments, Mark.
Comment 4 Mark Gawler 2002-05-22 14:26:01 UTC
I agree it is probably a gdm, kdm and xdm problem so I should have worded the 
bug differently. There is however a confusion in that the problem doesn't 
exist in KDE which, must do the initialisation for itself (I'm not saying that 
KDE is correct). 
 
I've re read the X and xdm man pages, these reinforce the view that it's a xdm 
problem: 
 
From the xdm man page - Overview 
"After the user logs in, xdm runs the Xstartup script as root.  
Then xdm runs the Xsession script as the user. This system session file may do 
some additional start-up and typically runs the .xsession script in the user's 
home directory." 
 
The Session Program section goes into more detail, which leads me to think 
that it's a problem with the /etc/X11/xdm/Xsession script rather than the 
fluxbox start-up script. KDE appears to do its own thing, which confused me.  
 
In conclusion there is a bug but its not specific to fluxbox. 
 
Comment 5 Seemant Kulleen (RETIRED) gentoo-dev 2002-05-22 15:57:24 UTC
sending this to Az since it's a DM issue
Comment 6 Martin Schlemmer (RETIRED) gentoo-dev 2002-05-22 16:57:04 UTC
The idea was that each script for the window manager in /etc/X11/Sessions/
should setup the environment as needed for that specific WM.  Gnome does
this, as for KDE, etc, I have no idea.  We can change /etc/X11/xdm/Xsession
to load the resources in all cases if it will be easier.
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2002-05-26 14:15:24 UTC
Im putting this on my to-do for next X revision.
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2002-06-01 06:04:36 UTC
Ok, try xfree-4.2.0-r11.
Comment 9 Mark Gawler 2002-06-02 12:46:27 UTC
Created attachment 1310 [details, diff]
Fix to the fix in /etc/X11/Xsession 

That doesn't quite fix it, but its close :-)

1) The /etc/profile script still isn't run so the users PATH isn't set-up
fully.
2) The ~/.xsession script needs to be run before the exec of the results of
/etc/X11/chooser.sh, otherwise the ~/.xsession is not run. 

I've attached a patch to the Xfree 4.2.0-r11 /etc/X11/Xsession script

Mark
Comment 10 Martin Schlemmer (RETIRED) gentoo-dev 2002-06-02 14:59:17 UTC
To be honest, I dont think it should source /etc/profile.  No other
distro that I have looked at do this (was some time ago, so could be
wrong) ... not even the generic files that comes with XFree86 do this.

> 2) The ~/.xsession script needs to be run before the exec of the results of
> /etc/X11/chooser.sh, otherwise the ~/.xsession is not run.

This is debatible.  But you may have part of the point.  It should not
always run ~/.xsession, but rather should do:

------------------------------snip------------------------------------
#xsession
if [ -s "$startup" ]; then
        if [ -x "$startup" ]; then
                exec "$startup"
        else
                exec /bin/sh "$startup"
        fi
elif [ -n "`/etc/X11/chooser.sh`" ]; then
        exec "`/etc/X11/chooser.sh`"
else
        exec xsm
fi
------------------------------snip-----------------------------------

Meaning, it should execute ~/.xsession if it exists, else run the system
default.
Comment 11 Martin Schlemmer (RETIRED) gentoo-dev 2002-06-02 15:12:28 UTC
Actually, this is from the xdm manpage:

-----------------------------snip---------------------------------
            #!/bin/sh
            #
            # Xsession
            #
            # This is the program that is run as the client
            # for the display manager.

            case $# in
            1)
                 case $1 in
                 failsafe)
                      exec xterm -geometry 80x24-0-0
                      ;;
                 esac
            esac

            startup=$HOME/.xsession
            resources=$HOME/.Xresources

            if [ -f "$startup" ]; then
                 exec "$startup"
            else
                 if [ -f "$resources" ]; then
                      xrdb -load "$resources"
                 fi
                 twm &
                 xman -geometry +10-10 &
                 exec xterm -geometry 80x24+10+10 -ls
            fi
-----------------------------snip---------------------------------

Which comes back to my original point that it is the session file
in /etc/X11/Sessions that should do the proper setup, or the job
of ~/.xsession.  A good example (if you merge gnome-base/gdm) is the
/etc/X11/Sessions/Gnome session file.
Comment 12 Mark Gawler 2002-06-02 15:51:23 UTC
I was just re-reading the xdm manpage myself, I'd missed the point of how 
Xsession script was meant to work. Clearly you are quite correct about only 
one of the Xsession scripts being run, the users taking precedence. I was 
trying to use Xsession it a way it isn't meant to be. 
 
I was uneasy about the /etc/profile script being run in the Xsession script so 
again I think your correct, but who's responsibility is it? I thought it 
should be run prior to starting the WM so that the WM had the correct 
environment. The case that caused me to raise the bug in the first place was 
the Fluxbox menus. The default fluxbox menus have kde applications in (if kde 
in your USE flags), but the /etc/profile is not run during the starting of the 
WM so kde is not in the path and thus the applications cant be found. KDE 
manages to run the scrip during its start-up so is it a case that it's the 
responsibility of the individual WM.   
 
Comment 13 Martin Schlemmer (RETIRED) gentoo-dev 2002-06-02 16:03:33 UTC
I think this should go as a bug to fluxbox and co that do not have
proper Session files ... maybe adding this bug as reference.  Anyhow, ill
fix the order in Xsession.
Comment 14 Dan Armak (RETIRED) gentoo-dev 2002-06-03 14:13:00 UTC
I only know how things stand with KDE. The x11/session script merely runs   startkde, all the changes are made to startkde and the only relevant change is   making it a login session (i.e. we modify it to start with #!/bin/sh --login).   So it reads /etc/profile, which makes sense. If you make this a global feature, we'll need to remove it from there.  I'm not clear as to the solution you decided on. Please tell me what if anything is required from the kde session script and/or kdm etc. 
Comment 15 Toby Dickenson 2002-10-15 16:42:00 UTC
The changelog for xfree-4.2.0-r11 says: 
 
> Fix /etc/X11/xdm/Xsession to first run ~/.xsession, rather then the system 
>  default (bug #2731). 
 
I have one gentoo system installed in August that uses -r12, which does as I 
would expect from this changelog. (possibly it used to use an older version 
and possibly CONFIG_PROTECT meant it didnt get updated, however I dont think 
this is the case). Its Xsession includes the fragment: 
 
----snip 
# First run ~/.xsession if it exists 
if [ -s "$startup" ]; then 
        if [ -x "$startup" ]; then 
                exec "$startup" 
        else 
                exec /bin/sh "$startup" 
        fi 
# If not, try the system default 
elif [ -n "`/etc/X11/chooser.sh`" ]; then 
        exec "`/etc/X11/chooser.sh`" 
----snip 
 
However the current -r12 ebuild in portage today includes the opposite. 
 
----snip 
# First run the system default 
if [ -n "`/etc/X11/chooser.sh`" ]; then 
        exec "`/etc/X11/chooser.sh`" 
# If not defined, try the user's ~/.xsession 
elif [ -s "$startup" ]; then 
        if [ -x "$startup" ]; then 
                exec "$startup" 
        else 
                exec /bin/sh "$startup" 
        fi 
----snip 
 
I think the first fragment is correct. Has something regressed in -r12 ? 
Comment 16 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-25 13:31:46 UTC
It causes problems for KDE :(
Comment 17 Paul de Vrieze (RETIRED) gentoo-dev 2003-01-16 02:50:58 UTC
The thing is that .xsession is supposed to start a window manager. This cannot
work together with the possibility to choose ones windowmanager. I believe a new
configuration file in that respect could be usefull. Esp. to start things like
gpg-agent (needed for aegypten support in kde-3.1), or IME's. Basically each
file in /etc/X11/Sessions could be changed to source in some script that loads
what could be called the Xprofile. This script should be something like:

#!/bin/sh
if [ -f $HOME/.Xprofile ]; then
  source .Xprofile
elif [ -f /etc/X11/Xprofile ]; then
  souce /etc/X11/Xprofile
fi

As example the kde start script would then be:

#!/bin/sh
source /etc/X11/loadprofile
exec startkde