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

Re: Ideal place to set environment variables

On Fri, 30 Mar 2018, Greg Wooledge wrote:
> 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.

pam_env.so can do substitutions, like:


Though that assumes that HOME was actually set (probably not) at the
time that pam_env fires. Recent versions of pam env have a PAM_ITEM
@{HOME}, which calls pam_modutil_getpwnam, which should return the HOME
directory in all cases. [Oddly, this isn't documented in the manpage,
but it's there in the source code.]

In this case, you likely really want pam_mail, and something like:

session optional pam_mail.so dir=~/Maildir nopen

which should DTRT.

Don Armstrong                      https://www.donarmstrong.com

"The trouble with you, Ibid" he said, "is that you think you're the
biggest bloody authority on everything"
 -- Terry Pratchet _Pyramids_ p146

Reply to: