Skip to content

gdm-{wayland,x}-session: import PATH from systemd

Gigadoc2 requested to merge Gigadoc2/gdm:fix/systemd-user-path into master

In both gdm-wayland-session and gdm-x-session, environment variables from the systemd user manager are imported, if it is available. Those environment variables are set up for the session-to-be-spawned, however, environment variables that the gdm-{wayland,x}-session process itself has are also inherited to the new session, and they are given preference over what is imported from systemd.

That is not accidential, the gdm-{wayland,x}-session process has fresh variables as to what the new user session will be (think $DISPLAY, $XDG_CURRENT_DESKTOP, etc.) and those should not be overwritten by stale data from the systemd user manager, who might have those variables still set from a previous session. As the gdm-{wayland,x}-session process does not inherit the environment in which GDM itself is launched, but gets a fresh environment with only purposefully added variables, this is in general not a problem (i.e. there are no environment variables from the systemd system instance overwriting those in our user session).

However, the GDM session worker sets a default fallback PATH for gdm-{wayland,x}-session. This then gets preferred over whatever the systemd user manager has, resulting in the session always getting the fallback PATH.

As GDM probably needs to consider scenarios where no variables can get imported from the systemd user manager (maybe it is not used at all), removing the default PATH is not an option. Instead, this commit adds a tiny bit of special handling to remove PATH from the subprocess_launcher environment right before merging with the imported variables, and only if we actually have any imported variables.

Closes: #385 (closed)

Merge request reports