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

Re: Login Shell/Profile: Stop the Madness



On Thu, 17 Jun 2004 12:18:28 +0100
Michael Graham <oobermick@yahoo.co.uk> wrote:
> > Now I'm on a RH 7.3 system right now and I've never had this profile
> > issue on RH systems so if I look at their scripts I see:
> > 
> > #!/bin/bash
> > 
> > .... lots of stuff ...
> > 
> > # otherwise, take default action
> > if [ -x "$HOME/.xsession" ]; then
> >     exec -l $SHELL -c "$HOME/.xsession"
> > 
> > There are a lot of other lines that look like this but this one
> > illustrates quite clearly how RH handles this. I'm not terribly
> > familiar with exec options of bash but I'm willing to bet it has
> > something to do with the login option or has the equivalent effect.
> 
> But in this case you exec'ing the users own .xsession so sourcing
> .profile isn't a problem, since the user should do it in the .xsession
> (either manually or by making it a login session) so you just do
> 
> exec ~/.xsession
> 
> and let the user deal with it!

No. The user does not need to source any files ever and they should
not source any files ever. When you start a login shell the shell does
it. That's the whole point.

> exec -l $SHELL -c "window-manager-bin"

Right. Natrually you would need to consider the different available
session managers [1]. The point is the exec -l $SHELL gives you a
login shell.

> And this means that the user is logged in twice (once for the shell
> and once for X)

What do you mean by "logged in twice" exactly?

> and is running a shell for no reason other that to
> source a file.

Correct. Although the login shell will "source" the profile. After all
that is the point.

Mike

[1] snipplet from RH 7.3 /etc/X11/xdm/Xsession which is executed by all
*dm managers:

for i in /etc/X11/xinit/xinitrc.d/* ; do
    if [ -x "$i" ]; then 
       . "$i"
    fi
done

# now, we see if xdm/gdm/kdm has asked for a specific environment
case $# in
1)
    if [ -x /usr/share/apps/switchdesk/Xclients.$1 ]; then 
       exec -l $SHELL -c "/usr/share/apps/switchdesk/Xclients.$1";
    fi;

    case $1 in
    failsafe)
       exec -l $SHELL -c "xterm -geometry 80x24-0-0"
       ;;
    gnome)  
       exec -l $SHELL -c "gnome-session"
       ;;
    kde|kde1|kde2)
       exec -l $SHELL -c "/usr/share/apps/switchdesk/Xclients.kde"
       ;;
    twm)    
        # fall back to twm
       exec -l $SHELL -c "/usr/share/apps/switchdesk/Xclients.twm"
       ;;
    esac    
esac

# otherwise, take default action
if [ -x "$HOME/.xsession" ]; then 
    exec -l $SHELL -c "$HOME/.xsession"
elif [ -x "$HOME/.Xclients" ]; then
    exec -l $SHELL -c "$HOME/.Xclients"
elif [ -x /etc/X11/xinit/Xclients ]; then
    exec -l $SHELL -c "/etc/X11/xinit/Xclients"
else

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



Reply to: