[systemd-devel] Help on Automatic Symlink XDG_DATA_HOME

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sat Nov 2 06:55:12 PDT 2013


On Sat, Nov 02, 2013 at 02:54:20AM +0000, systemdkiosk at yopmail.com wrote:
> Zbigniew Jędrzejewski-Szmek wrote:
> 
> > 'systemctl --user show-environment' will show what's set
> 
> I get errors as normal user and root.
> 
> $ systemctl --user show-environment 
> Failed to issue method call: Process /bin/false exited with status 1
So something is broken.

> $ su -
> Password:
> # systemctl --user show-environment 
> Failed to get D-Bus connection: Unable to autolaunch a dbus-daemon
> without a $DISPLAY for X11
Running systemctl --user under root is even more confusing, because it's
not clear if you'd get the root instance or the user instance.

> > systemd is executed by systemd
> > with a standard set of variables
> 
> Might sysd avoid/defer possibly wrong values until they are reliable?
Not really. The design is that systemd (PID 1) launches user at username.service,
which spawns systemd --user instance. This --user instance launches some
services, including possibly at some point, your session. A shell
is not involved anywhere in this process... Reading stuff from /etc/profile*
is possibly only if you insert a shell somewhere in this sequence, which
is contrary to the design.

> Might it offer a config file for admins to override assumptions? Note my
> XDG vars need $USER, so:
> export XDG_DATA_HOME="/tmp/user_data_for_$USER"
> 
> > /etc/profile* is unfortunately shell-only, so it's not something
> > that systemd can use directly. I think that adding a custom pam
> > module would be a better option here (c.f. pam_env(8)).
> 
> Everything else works swell with /etc/profile* values, and, for that
> matter, even systemd does after login. KDE works in its entirety. Read
> on XDG_RUNTIME_DIR. tightly bound to login.
> http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html
Right, they are all started much later, and through a shell.

> If I need PAM trickery then I'd rather drop a one-line script into
> /etc/profile.d to delete the symlink and call it a wrap.
We might even drop the creation of the symlink from systemd, but
this won' solve your real problem: that systemd --user runs with different
XDG_* settings than the rest of your session. Fix that, and the symlink
issue will fix itself too.

> But philosophically, would it be fair to say:
> 
> "All vars can, and should, be set or changed in /etc/profile.d, except
> XDG vars, which only for the sake of systemd should be set elsewhere."
> 
> Is that idea documented or proposed anywhere, or desirable design? Isn't
> the issue more about sysd bootstrapping glitches?
Like I said above, /etc/profile* are a bunch of shell scripts. This
means that XDG_ stuff must be set elsewhere. Otherwise systemd --user
and anything spawned by it will have wrong settings.

> Thanks for the feedback in any case. Sounds like a cleanup script is the
> fast answer. Maybe in future sysd can offer an admin config file for XDG
> vars.
> 
> Glad I asked, help was appreciated and very rapid.

Zbyszek


More information about the systemd-devel mailing list