Using Gentoo and KDE 4, opening Konsole or xterm doesn't provide defined stuff in /etc/profile. This file is normally sourced by a login shell, but what can be considered as a login shell in a graphical environment? Is this supposed to be sourced before the X session? Should the shell of Konsole be set up with bash --login? Is this a bug?
Thanks for your help.
It depends.
Unless the shell is launched as a "login shell", which is the system's way of signaling to the shell that this is the first time the user is interacting with the computer for this session, it is started as a "child" shell.
"Login" shells source the environment from whatever control mechanism is set up (/etc/profile, /etc/profile.d/, and usually local dotfiles like .profile and .bashrc (if bash)).
"Child" shells just inherit their parent's environment, but sometimes also run some dotfiles depending on how they are configured.
In most systems with X configured, the dot files are sourced by whatever process starts the window manager and xterms or konsoles or whatever just inherit from that. This is because it isn't considered a login session, since you were already logged in when you started the konsole.
You can set your konsole to run 'bash --login' if you want, but this might have unexpected side-effects later on when you run something which depends on an environment variable that you are clobbering with the --login parameter.
According to this page in the Gentoo Handbook, on Gentoo you'll want to define your environment variables in a file underneath the /etc/env.d directory, rather than in /etc/profile itself.
A login shell is distinguished (by the shell interpreter) by starting with a "-". That is, argv[0] of a login bash shell will be -bash vice bash. Similarly for other shells (-ksh vs ksh, -csh vs csh, -sh vs sh, etc.) This is done by the login program or other authentication step. Bash offers the -l or --login option, but that should be the equivalent of -bash.
If you want to ensure that /etc/profile is read (instead of only setting up an inherited environment), you can explicitly read it in ~/.profile. Use the appropriate file names for your shell of choice.
I think this is a bug in gentoo... check your ~/.xsession-errors for an error involving 'keychain'...
emerging net-misc/keychain fixed it for me.