GNOME Bugzilla – Bug 84827
gdm logs user in twice (runs .profile/.login twice)
Last modified: 2002-07-07 22:40:29 UTC
I added ssh-add to my ~/.bash_profile, and now I am prompted for the same password twice when logging in with gdm, but I am only prompted once if I use kdm or xdm. If I put something like the following in ~/.bash_profile: echo "$(date): running .bash_profile" >> $USER/gdmlogin.log I notice that two entries appear in the log file I created when I log in with gdm, but only one entry appears when I log in with kdm or xdm. This suggests that my login script (such as ~/.bash_profile) is being evaluated twice. If I add some more log messages, I see that one login is being caused by my ~/.xsession which includes the statement: exec -l $SHELL -c "gnome-session" (my ~/.xsession is run from the system's Xsession, which falls thru to the default case.) The other (the one only occurring with gdm) appears to occur even before PreSession/Default is called. This can also result in $PATH having the same entries twice if $PATH is being modified in the user's login script (~/.bash_profile or similar). A more accurate description would be that gdm is logging the user in (in the same way that bash --login does), whereas kdm and xdm do not. gdm doing so causes unwanted side-effects. I am accessing gdm via XDMCP.
If you are using the Xsession session you should use the one supplied with gdm itself and not the one supplied by X (I suppose this may be redhat's setup). The thing is that gdm runs your shell in login mode and then executes the session script in that shell. IF the session script starts with #!/bin/bash -login then you'll get a bash login thing as well. This is wrong and braindead and that's what it seems that xdm ships with (braindead if you use any other shell then bash, since you'd probably want your shell's login stuff to be run rather then bash's). As such I'm marking this as a NOTGNOME since gdm doesn't ship with an Xsession that has a -login argument for the shell (at least not in the latest versions it doesnt). You can fix this by editting /etc/X11/gdm/Xsession and removing the -login from the first line.
I made sure to remove any thing that looked like it would log the user in, including anything like "bash --login" or "exec -l", and the problem still occurs. It's interesting, however, that the problem seems to go away when I remove the "exec" from the session files in /etc/X11/gdm/Sessions. Perhaps Red Hat could consider removing the exec from there if it's calling another script that also includes an exec (such as Xsession), but the shell shouldn't log the user in unless "exec -l" or "bash --login" is called, as George suggests. This makes me wonder if it's a bug in bash, but it's still something that must be worked around.