[systemd-devel] systemd user instance not working in only one account, XDG_RUNTIME_DIR not being set

Mantas Mikulėnas grawity at gmail.com
Tue Apr 11 05:31:33 UTC 2023


On Tue, Apr 11, 2023, 03:41 Chandler <admin at genome.arizona.edu> wrote:

> systemd has been working great here, system-wide as well as in all user
> instances except one.  I'm not exactly sure what all the steps are in
> the process to get a systemd user instance running.  The directory
> /run/user/$UID was not being created, though.
>
> I made some progress by running `systemctl start
> user@<username>.service` and the /run/user/$UID was created.
>
> `systemctl --user status` returns `Failed to connect to bus: No such
> file or directory`.  XDG_RUNTIME_DIR is not being set, but a command
> like `XDG_RUNTIME_DIR=/run/user/$UID systemctl --user status` runs
> successfully, so I think it's down to this last piece.
>

The same pam_systemd module registers a "session" with logind (which
triggers the creation of runtime directory as well as the startup of
user@<uid>.service;
note: *not* user@<username>) and sets XDG_RUNTIME_DIR after the session has
been registered. Check whether your tty or display is shown in the
`loginctl` session list.

Note that logind does not allow registering sessions from within another
session, so tools like `su` won't be able to do that (except for some
situations where they can but you wouldn't want them to) – only a fresh
login gets you a session. So usually step 1 is to not use `su` or `sudo`
here – run `machinectl shell foo@` if you need a shell for a local user.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20230411/48f744d0/attachment.htm>


More information about the systemd-devel mailing list