Re: [systemd-devel] Environment File Question

2017-12-19 Thread Lennart Poettering
On Mo, 18.12.17 23:22, Boyce, Kevin P [US] (AS) (kevin.bo...@ngc.com) wrote:

> Good Day List,
> 
> This may be a noob question but I'm trying to understand how systemd works 
> with environment variables for system services in one place.  Reading various 
> sites and systemd documentation only seems to be confusing me at this point.
> 
> When I set in /etc/systemd/system.conf
> DefaultEnvironment="VAR1=Test" 'VAR2=TEST 2', my service reads the
> variables correctly, but why are these not inherited by the user
> when they login?  Isn't systemd the parent of all processes and
> shouldn't that environment I specify be preserved?

This depends on how the program the puts together the login
environment does it, i.e. sshd, login, gdm, whatever it is. More often
than not they tend to clean up the environment block fully. 

> Further, what if I need expansion of these variables like
> DefaultEnvironment="VAR1=$(readlink -f /path/to/symlink)" to work
> also which complicates things.  /etc/environment does not do this.

You could use "systemctl set-environment" to set env vars to be
inherited by system services programmatically. But of course, be
careful to not introduce races.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Environment File Question

2017-12-18 Thread Andrei Borzenkov
19.12.2017 02:22, Boyce, Kevin P [US] (AS) пишет:
> Good Day List,
> 
> This may be a noob question but I'm trying to understand how systemd works 
> with environment variables for system services in one place.  Reading various 
> sites and systemd documentation only seems to be confusing me at this point.
> 
> When I set in /etc/systemd/system.conf DefaultEnvironment="VAR1=Test" 
> 'VAR2=TEST 2', my service reads the variables correctly, but why are these 
> not inherited by the user when they login?

/bin/login will initialize environment unless called with "-p" option.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Environment File Question

2017-12-18 Thread Boyce, Kevin P [US] (AS)
Good Day List,

This may be a noob question but I'm trying to understand how systemd works with 
environment variables for system services in one place.  Reading various sites 
and systemd documentation only seems to be confusing me at this point.

When I set in /etc/systemd/system.conf DefaultEnvironment="VAR1=Test" 
'VAR2=TEST 2', my service reads the variables correctly, but why are these not 
inherited by the user when they login?
Isn't systemd the parent of all processes and shouldn't that environment I 
specify be preserved?

Further, what if I need expansion of these variables like 
DefaultEnvironment="VAR1=$(readlink -f /path/to/symlink)" to work also which 
complicates things.  /etc/environment does not do this.

On RHEL7 we don't have the system-environment-generator available as it was 
released in systemd v.233 I think. RHEL has v219.

Thanks,
Kevin

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel