Bug 66486

Summary: gdm sources .bash_profile twice
Product: [Retired] Red Hat Linux Reporter: Michael Wardle <michael.wardle>
Component: gdmAssignee: Havoc Pennington <hp>
Status: CLOSED RAWHIDE QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: jirka, petersen, sopwith
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
URL: http://bugzilla.gnome.org/show_bug.cgi?id=84827
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-09-05 23:30:08 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 67218, 73062    

Description Michael Wardle 2002-06-11 03:17:29 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc2)
Gecko/20020512 Netscape/7.0b1

Description of problem:
I added some statements to my ~/.bash_profile to get ssh-add (or equivalent) to
prompt me for my password whenever I log in (both text and graphics modes).

When I log in using gdm and the default session (so ~/.xsession is run), I am
prompted for my password twice.  If I log in using kdm or xdm, I am only
prompted once.  (Reproduced several times, definately not passphrase related!)

Adding some lines to ~/.bash_profile confirms that gdm causes ~/.bash_profile to
be sourced twice, whereas other display managers (such as kdm and xdm) only
source this file once.

It seems that gdm is performing an extra login (like "bash --login" or "exec -l").

Please see URL for full details as I submitted to GNOME bug system.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. touch ~/gdmlogin.log
2. create a new ~/.xsession containing something like:
    echo "$(date) starting .xsession" >> $HOME/gdmlogin.log
    exec gnome-session
3. log in to a Red Hat/GNOME system using the "Default" session type
   (this should invoke /etc/X11/xdm/Xsession, which will fall thru
    to the default session and call "exec -l $SHELL -c ~/.xsession")
4. read ~/gdmlogin.log, it will have 2 entries
5. repeat with kdm or xdm: only 1 entry will have been added

Actual Results:  Login script (such as ~/.bash_profile) is sourced twice.

Expected Results:  Login script (such as ~/.bash_profile) is only sourced once.

Additional info:
Comment 1 Michael Wardle 2002-06-11 03:32:52 EDT
The steps I gave were bad, the log is in the wrong place.  A simple way to

1. touch ~/gdmdebug.log
2. create ~/.bash_profile:
   echo "$(date): in .bash_profile" >> $USER/gdmdebug.log
3. create ~/.xsession:
   exec gnome-session
4. log in to using gdm with the Default session
5. repeat with xdm or kdm
Comment 2 Michael Wardle 2002-06-11 03:35:09 EDT
This could possibly be a duplicate of an old Red Hat 6.1 bug, Bugzilla bug 6965,
presuming the user had something that modified $PATH in ~/.bash_profile.
Comment 3 Michael Wardle 2002-06-11 04:19:09 EDT
Reproduced this on a clean install of Red Hat Linux 7.3 (which includes
essentially the same version of gdm).
Comment 4 Havoc Pennington 2002-07-07 18:33:57 EDT
See claim in http://bugzilla.gnome.org/show_bug.cgi?id=84827
that this is an xinitrc bug. (Slightly wrong, since we don't run bash --login,
we run exec -l gnome-session)

I guess I'd rather change gdm, so that the "exec -l" goes right around
gnome-session, and we don't run the bulk of Xsession with the profile having 
been loaded.
Comment 5 Michael Wardle 2002-07-07 18:45:36 EDT
I've just replied to that bug saying that the problem disappears if exec is
removed from the gdm 
session scripts.  The true cause of the bug should
probably be investigated, but it should be 
safe to remove the exec from the
gdm session scripts because something is exec'd in 

In other words, since /etc/X11/xdm/Xsession already calls
exec -l $SHELL -c 
exec -l $SHELL -c startkde
exec -l $SHELL -c $HOME/.xsession

should be fairly safe to remove the initial exec from
as it 
just calls Xsession.
Comment 6 Elliot Lee 2002-08-26 13:27:15 EDT
The first bash_profile run occurs when gdm/daemon/slave.c runs -/bin/sh -c 'my-session-

The second one occurs in Xsession when it does the exec -l $SHELL ...

I am removing the '-' in the slave.c exec line so that everything should work sanely.
Comment 7 Jens Petersen 2002-09-03 21:38:49 EDT
Wouldn't it be better to change Xsession instead?

Making the change in slave.c means that /etc/X11/xinit/xinitrc.d/*
scripts get run without the user's shell environment, which is bad
for skkinput (eg XIM=skkinput).
Comment 8 Havoc Pennington 2002-09-03 22:08:25 EDT
I think doing it in Xsession is right as most of the Xsession script should not
run in the user's environment... the "exec -l shell" line marks the start of
launching the user's environment.

If /etc/X11/xinit/xinitrc.d/ should run in the user's environment, it should
probably get run from a hook in /etc/profile.d...
Comment 9 Jens Petersen 2002-09-05 03:44:45 EDT
Well, I guess running them from /etc/profile somehow would also be fine.
How would you make sure that they are only run when starting an X session
Comment 10 Jens Petersen 2002-09-05 23:36:22 EDT
In xinitrc-3.29-1, xinput now sources /etc/profile.d/lang.sh
which basically fixes the XIM selection configuration problem.
So I'm closing this again.