[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Ideal place to set environment variables

On Thu, Mar 29, 2018 at 09:42:34PM +0100, Jonathan de Boyne Pollard wrote:
> I think that login.conf is a step in the right direction, and I'm planning
> on making tools that support it.  Or, rather, on making the tools that
> already support it on the BSDs also support it on Linux operating systems.
> * http://netbsd.gw.com/cgi-bin/man-cgi?login.conf
> * https://www.freebsd.org/cgi/man.cgi?query=login.conf
> * https://man.openbsd.org/login.conf
> * http://jdebp.eu./Softwares/nosh/guide/userenv-fromenv.html
> I already use them to set the GUI environment from login.conf on TrueOS.
> * https://unix.stackexchange.com/a/390089/5132

I have an extremely simple real-world litmus test which every system
I've ever seen so far has failed:

  How do I set MAIL=$HOME/Maildir/ in the login environment of every
  user, regardless of their shell, or how they log in (console, ssh,
  X Display Manager, GNOME Display Manager, etc.)?

That's it.  Simple, right?  But login.conf can't do it.  And pam_env.so
can't do it.  They only allow static strings with no substitutions.
In fact I'm not aware of ANYTHING that can do it.

The closest I've seen is sshd_config which uses %h and %u tokens in
some contexts, but only for specific sshd configuration parameters --
not for setting environment variables.

In the real world, today, the only solution is to duplicate that setting
in multiple places, so that (hopefully) every conceivable login method +
shell combination will pick up at least one of them.

Reply to: