Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #224231

Re: Systemd user environment variables not picked up for me

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups linux.debian.user
Subject Re: Systemd user environment variables not picked up for me
Date 2020-06-30 14:30 +0200
Message-ID <AnnyF-1ya-5@gated-at.bofh.it> (permalink)
References <AmYTD-3nX-1@gated-at.bofh.it> <An430-6nE-21@gated-at.bofh.it> <An4w1-6MV-5@gated-at.bofh.it> <Ani5Y-6Fh-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Jun 30, 2020 at 08:14:41AM +0200, l0f4r0@tuta.io wrote:
> It seems you can reconstruct those "early" variables like the following:
> HOME=/home/@{PAM_USER}
> 
> Or use @{HOME} directly since PAM 1.2.0.
> 
> Source: https://unix.stackexchange.com/questions/258246/why-does-pam-environment-not-include-home-in-my-new-path

Huh... interesting stuff.  Apparently I haven't been reading the
correct man pages, to start with.

None of this stuff is mentioned *at all* in pam_env(7).  The only thing
you can find there is "SEE ALSO  pam_env.conf(5)".

pam_env.conf(5) is far more interesting, especially this paragraph:

       The /etc/environment file specifies the environment variables to be
       set. The file must consist of simple NAME=VALUE pairs on separate
       lines. The pam_env(8) module will read the file after the pam_env.conf
       file.

So... wait, there are *two* config files, and they're *completely
different*?!  Jesus.

Taking your comments, plus the linked web page, plus the pam_env.conf(5)
man page, plus the commentary in the /etc/security/pam_env.conf file, I
performed the following experiment:

First, I added two lines to the end of /etc/security/pam_env.conf:

TEST1		DEFAULT=${HOME}/foo
TEST2		DEFAULT=@{HOME}/foo

Then I opened a new terminal window, and ran "su - greg" inside it.

unicorn:~$ su - greg
Password: 
unicorn:~$ env | grep TEST
TEST2=/home/greg/foo
TEST1=/foo

Huh.  It actually *worked*.  Astonishing.

I feel like the /etc/environment file needs some comments in it saying
"This is a useless legacy file; if you actually want to add environment
variables to user logins, see pam_env.conf(5) and put your changes in
/etc/security/pam_env.conf instead."  But then again, that would probably
be treated as live code rather than a comment, and something would
explode.

And then /etc/security/pam_env.conf needs comments that say "Use @{HOME}
instead of ${HOME}."  That can either replace or augment the current
comment that says "For example, HOME is used below several times, but
many PAM applications don't make it available by the time you need it."

Of course, none of this will actually happen, because it is Upstream
Documentation, and Debian won't want to touch it.

Back to linux.debian.user | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Systemd user environment variables not picked up for me Thomas Pircher <thp+debian@p5r.uk> - 2020-06-29 12:10 +0200
  Re: Systemd user environment variables not picked up for me Thomas Pircher <thp+debian@p5r.uk> - 2020-06-29 13:10 +0200
  Re: Systemd user environment variables not picked up for me Greg Wooledge <wooledg@eeg.ccf.org> - 2020-06-29 15:40 +0200
    Re: Systemd user environment variables not picked up for me Thomas Pircher <thp+debian@p5r.uk> - 2020-06-29 19:10 +0200
  Re: Systemd user environment variables not picked up for me l0f4r0@tuta.io - 2020-06-29 17:40 +0200
    Re: Systemd user environment variables not picked up for me Greg Wooledge <wooledg@eeg.ccf.org> - 2020-06-29 18:10 +0200
      Re: Systemd user environment variables not picked up for me Thomas Pircher <thp+debian@p5r.uk> - 2020-06-29 19:10 +0200
      Re: Systemd user environment variables not picked up for me Andrei POPESCU <andreimpopescu@gmail.com> - 2020-06-29 22:00 +0200
        Re: Systemd user environment variables not picked up for me Greg Wooledge <wooledg@eeg.ccf.org> - 2020-06-29 22:20 +0200
      Re: Systemd user environment variables not picked up for me l0f4r0@tuta.io - 2020-06-30 08:40 +0200
        Re: Systemd user environment variables not picked up for me Greg Wooledge <wooledg@eeg.ccf.org> - 2020-06-30 14:30 +0200

csiph-web