Comment 13 for bug 18574

Revision history for this message
Tamlin (storyjesse-gmail) wrote :

I've done a little reading and it appears /etc/environment is indeed a configuration file for Linux-PAM
  man PAM ("PAM" must be in capitals "pam" is something else)

Also had a look at Linux-PAM System Administrators Guide http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/sag-pam_env.html which states that pam_env.so passes the lines in /etc/environment

So when is the pam_env.so loaded?

PAM configuration is in /etc/pam.d/ or /etc/pam.conf (the latter is ignored if the former is present) My Ubuntu system (10.4 upgraded from 6.4) uses /etc/pam.d/
Of the files in this directory atd, cron, gdm, gdm-autologin, login & su require pam_env.so so, going by the names of these config files, I'm guessing that pam_env.so, which loads /etc/environment, is run when gdm is started and at login, perhaps even when cron and atd are run?

I can confirm that /etc/environment is read and the variables set at login and/or su login, but I don't have time right now to test cron or atd, and don't know how to test gdm or gdm-autologin

Hope this helps answer the original question somewhat but I agree it would be nice to know how to execute pam_env.so manually.

One limitation to /etc/environment though is that it is NOT a shell script - it is a config file - and therefore putting the following doesn't work:
  scripts_path='/mnt/config/scripts'
  start_stop_scripts="$scripts_path/start-stop"
  script_logs="$scripts_path/script_logs"

this results in
  echo $script_logs
  $scripts_path/script_logs

rather than
  echo $script_logs
  /mnt/config/scripts/script_logs

For this reason I'll probably just put
  source /mnt/config/scripts/myenvar
at the end of /etc/bash.bashrc even though https://help.ubuntu.com/community/EnvironmentVariables says it's not recommended. Then include all my custom global variables in /mnt/config/scripts/myenvar

P.S. I can see why Debian has decided to separate out local variables from /etc/environment as it's not very intuitive to set environment variables through an authentication system. I hope the trend continues and we'll eventually get a standard set of configuration files that all (or at least all compliant) programs reference. :-)