无法获得 D-Bus 连接:没有这样的文件或目录。$XDG_RUNTIME_DIR 未设置。已安装 libpam-systemd

Fol*_*aht 3 debian d-bus systemd

我在 LIME2 上安装了 Yunohost,就像我在 Pi3 上所做的一样,现在我遇到了两个月相同的错误(请参阅“无法启用用户服务。“无法获得 D-Bus 连接:连接被拒绝”支持“),只有这一次我已经安装了 libpam-systemd。

admin@Gildurklaus:~ $ systemctl --user list-units
Failed to get D-Bus connection: Connection refused
Run Code Online (Sandbox Code Playgroud)

同样,没有用户参数,命令运行良好。

admin@Gildurklaus:~ $ systemctl list-units

  UNIT                                                                 LOAD   ACTIVE SUB       DESCRIPTION
  proc-sys-fs-binfmt_misc.automount                                    loaded active waiting   Arbitrary Executable File Formats File System Automount Point
  sys-devices-platform-soc-3f201000.serial-tty-ttyAMA0-hci0-rfkill1.device loaded active plugged   /sys/devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/rfkil
  sys-devices-platform-soc-3f201000.serial-tty-ttyAMA0-hci0.device     loaded active plugged   /sys/devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0
  ...
  To show all installed unit files use 'systemctl list-unit-files'.
  lines 102-129/129 (END)
Run Code Online (Sandbox Code Playgroud)

再次 Dbus 不是为我的用户运行,只是在系统范围内运行。

admin@Gildurklaus:~ $ ps -ef | grep dbus
message+   574     1  0 05:53 ?        00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
admin     1988  1971  0 10:03 pts/0    00:00:00 grep dbus
Run Code Online (Sandbox Code Playgroud)

同样,systemd 似乎没有为该用户运行

admin@Gildurklaus:~$ ps -ef | grep dbus
message+   574     1  0 05:53 ?        00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
admin     1988  1971  0 10:03 pts/0    00:00:00 grep dbus
admin@Gildurklaus:~$ ps -ef | grep systemd
root       183     1  0 05:53 ?        00:00:01 /lib/systemd/systemd-journald
root       187     1  0 05:53 ?        00:00:00 /lib/systemd/systemd-udevd
root       572     1  0 05:53 ?        00:00:00 /lib/systemd/systemd-logind
message+   574     1  0 05:53 ?        00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
admin     1990  1971  0 10:04 pts/0    00:00:00 grep systemd
Run Code Online (Sandbox Code Playgroud)

并且 $XDG_RUNTIME_DIR 再次丢失。

admin@Gildurklaus:~ $ systemd --test
Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.
Run Code Online (Sandbox Code Playgroud)

这次安装了 libpam-systemd。

admin@Gildurklaus:~$ apt list --installed *systemd*
Listing... Done
libpam-systemd/oldstable,now 215-17+deb8u7 armhf [installed]
libsystemd0/oldstable,now 215-17+deb8u7 armhf [installed]
systemd/oldstable,now 215-17+deb8u7 armhf [installed]
systemd-shim/oldstable,now 9-1 armhf [installed,automatic]
systemd-sysv/oldstable,now 215-17+deb8u7 armhf [installed]
admin@Gildurklaus:~$ apt list --installed *dbus*   
Listing... Done
dbus/oldstable,now 1.8.22-0+deb8u1 armhf [installed,automatic]
libdbus-1-3/oldstable,now 1.8.22-0+deb8u1 armhf [installed,automatic]
libdbus-glib-1-2/oldstable,now 0.102-1 armhf [installed,automatic]
libnih-dbus1/oldstable,now 1.0.3-4.3 armhf [installed,automatic]
Run Code Online (Sandbox Code Playgroud)

[更新]

我注意到我的 Pi3 和 LIME2 服务器之间存在细微差别。Pi3 会启动 XDG_SESSION_ID 会话,而 LIME2 服务器不会。

π3

admin@Yroklaus:~ $ sudo systemctl status systemd-logind.service
? systemd-logind.service - Login Service
   Loaded: loaded (/lib/systemd/system/systemd-logind.service; static)
   Active: active (running) since Sat 2018-03-24 15:43:32 UTC; 1h 27min ago
     Docs: man:systemd-logind.service(8)
           man:logind.conf(5)
           http://www.freedesktop.org/wiki/Software/systemd/logind
           http://www.freedesktop.org/wiki/Software/systemd/multiseat
 Main PID: 508 (systemd-logind)
   Status: "Processing requests..."
   CGroup: /system.slice/systemd-logind.service
           ??508 /lib/systemd/systemd-logind

Mar 24 15:43:32 Yroklaus systemd[1]: Starting Login Service...
Mar 24 15:43:32 Yroklaus systemd-logind[508]: New seat seat0.
Mar 24 15:43:32 Yroklaus systemd[1]: Started Login Service.
Mar 24 15:43:32 Yroklaus systemd-logind[508]: Couldn't add lingering user folatt: No such file or directory
Mar 24 15:43:32 Yroklaus systemd-logind[508]: User enumeration failed: No such file or directory
Mar 24 16:47:01 Yroklaus systemd-logind[508]: New session c1 of user admin.
Run Code Online (Sandbox Code Playgroud)

石灰2

admin@Gildurklaus:~$ sudo systemctl status systemd-logind.service
? systemd-logind.service - Login Service
   Loaded: loaded (/lib/systemd/system/systemd-logind.service; static)
   Active: active (running) since Sat 2018-03-24 16:43:45 CET; 1h 27min ago
     Docs: man:systemd-logind.service(8)
           man:logind.conf(5)
           http://www.freedesktop.org/wiki/Software/systemd/logind
           http://www.freedesktop.org/wiki/Software/systemd/multiseat
 Main PID: 571 (systemd-logind)
   Status: "Processing requests..."
   CGroup: /system.slice/systemd-logind.service
           ??571 /lib/systemd/systemd-logind

Mar 24 16:43:45 Gildurklaus systemd-logind[571]: New seat seat0.
Mar 24 16:43:45 Gildurklaus systemd[1]: Started Login Service.
Run Code Online (Sandbox Code Playgroud)

Jde*_*eBP 5

Dbus 再次运行。

不,显然不是。这也不是最后一次。

您的进程列表仅显示系统范围的桌面总线代理。请注意--system命令参数中的 以及该进程没有像您一样运行这一事实。

当您systemctl使用该--user选项运行时,它会systemd通过您的每用户桌面总线代理与您的每用户实例对话。

实际上两者都没有运行。

您可能会发现启动每个用户的实例systemd也会启动每个用户的桌面代理。前者管理后者,并且dbus.socket单元 (from /usr/lib/systemd/user/dbus.socket) 可能已经为您的每用户服务管理器启用。(请注意,必须启用的是套接字单元,而不是服务单元。)

所以它实际上与以前的答案相同,即使在上一个问答中没有明确说明:确保您的每用户实例systemd正在运行,并确保启动您的每用户桌面总线代理。您可以运行pam_systemd手动运行的步骤,以首先检查它们本身是否有效。然后检查pam_systemd是否配置为作为登录过程的一部分实际调用。

请记住,这su不是登录机制。它在现有的交互式登录会话中工作。如果您不是以相关帐户的身份登录,则 systemd 挂钩将不会为该帐户激活每个用户的 systemd 实例。

进一步阅读