: Export variables set via */environment.d/*.conf files
Task Info (Flyspray) | |
---|---|
Opened By | Philipp Reinkemeier (philipp.reinkemeieroffis.de) |
Task ID | 56716 |
Type | Feature Request |
Project | Arch Linux |
Category | Packages: Core |
Version | None |
OS | All |
Opened | 2017-12-14 10:24:29 UTC |
Status | Assigned |
Assignee | Sébastien Luttringer (seblu) |
Details
Description: filesystem provides /etc/profile setting environment variables. Recently, systemd got a new feature for configuring environment variables via /environment.d/.conf files. Environment variables configured via these files end up in the environment block of the systemd user manager. Thus, every service executed by it is aware of them. However, up to now, these environment variables do not necessarily end up in login sessions. For instance if one logs in via the console or ssh, these environment variables are not set. On the other hand gnome seems to import them along with also executing a login shell, thus reading /etc/profile. This leads to the problem mentioned in https://github.com/systemd/systemd/issues/6414: The environment variable PATH, if configured via e.g. some file in ~/.config/environment.d/ is overwritten, because /etc/profile is executed as well. On the other hand an environment variable PATH1 would have a value as expected.
This feature request is about to make sure that environment variables have consistent values, independently of whether one logs in via the console or some graphical session. A way to achieve this would be to add the following line to /etc/profile right after the execution of scripts in /etc/profile.d/:
export $(/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator)
A user can then configure environment variables either via the logic provided by systemd or via ~/.profile. Further, this opens up the possibility to smoothly migrate some scripts in /etc/profile.d to the systemd-logic of setting environment variables. Examples of such scripts are "jre.sh", "libreoffice-*.sh", "locale.sh", "mozilla.sh", ... Thus, environment variables seen by services executed by the systemd user manager process would get consistent with the ones seen in login sessions.
Additional info:
- filesystem 2017.10-2
Steps to reproduce:
- Create a file ~/.config/environment.d/10-path.conf with
the following content PATH=foo
{PATH:+:
PATH} and PATH1=foo{PATH:+:
PATH} - Log into gnome and execute env in a terminal. One gets PATH=X and PATH1=foo:X.
- Login via getty and execute env. One gets PATH=X and PATH1 is not defined. Expected would be PATH=foo:X and PATH1=foo:X in both cases.