Re: Directory 1002/ missing from /var/run/user/

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Mon, 12 Jun 2023 13:20:18 UTC
Graham Perrin <grahamperrin@freebsd.org> writes:

> What normally takes care of creation of the numbered directories?

/var/run/user/ (or /run/user/ on Linux with systemd) is a common prefix
for XDG_RUNTIME_DIR, a standardized place for user-owned unix(4) sockets.
Fallbacks are either app-specific or shared (e.g., CVE-2020-25697).

/var/run/user/<UID> is managed by sysutils/consolekit2 or sysutils/pam_xdg.
In consolekit2 case the directory is created (contents destroyed if
already exists) on the first session of the specific UID either via
C API, DBus API, ck-launch-session(1) or pam_ck_connector(8) and removed
when the last session terminates. In pam_xdg case the directory is
created but not removed unless track_sessions is set.

> A few hours ago, it was unexpectedly missing:

Probably auto-removed by consolekit2 either due to logout or dbus restart.

> I recreated the directory.

Can be automated via PAM e.g.,

  # pkg install consolekit2
  # echo "session optional pam_ck_connector.so nox11" >>/etc/pam.d/system
  # service dbus onestart
  $ exit # log out on VT console to re-trigger PAM

or

  # pkg install pam_xdg
  # echo "session optional pam_xdg.so notroot runtime" >>/etc/pam.d/system
  $ exit # log out on VT console to re-trigger PAM