0

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.

Patrick Allaert
  • 145
  • 1
  • 6

4 Answers4

1

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.

David Mackintosh
  • 14,223
  • 6
  • 46
  • 77
0

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.

user56452
  • 101
  • 1
0

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.

ngm
  • 123
  • 6
  • I know, /etc/profile is a gentoo script that setup different stuff coming from /etc/env.d/ as well as /etc/profile.d/ and which is not supposed to be modified. My problem is that /etc/profile is not sourced at all ignoring that kind of stuff too! – Patrick Allaert Nov 24 '09 at 12:06
0

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.

mpez0
  • 1,492
  • 9
  • 9