systemd --user 未启动:XDG_RUNTIME_DIR 未设置,但已设置

systemd --user 未启动:XDG_RUNTIME_DIR 未设置,但已设置

systemd --user不起作用:

# systemctl --user status

Failed to read server status: Process org.freedesktop.systemd1 exited with status 1

我有:

# echo $XDG_RUNTIME_DIR

/run/user/1000

根本问题似乎是user@1000没有运行。手动启动会产生与登录相同的错误:

# sudo systemctl start user@$(id -u)

Job for [email protected] failed because the service did not take the steps required by its unit configuration.
See "systemctl status [email protected]" and "journalctl -xe" for details.

#systemctl status user@$(id -u)
[email protected] - User Manager for UID 1000
   Loaded: loaded (/usr/lib/systemd/system/[email protected]; static; vendor preset: disabled)
   Active: failed (Result: protocol) since Sun 2019-08-18 19:11:41 CEST; 2min 6s ago
     Docs: man:[email protected](5)
  Process: 13047 ExecStart=/usr/lib/systemd/systemd --user (code=exited, status=1/FAILURE)
 Main PID: 13047 (code=exited, status=1/FAILURE)
    Tasks: 0
   Memory: 452.0K
   CGroup: /user.slice/user-1000.slice/[email protected]

Aug 18 19:11:41 arch0713 systemd[1]: Starting User Manager for UID 1000...
Aug 18 19:11:41 arch0713 systemd[13047]: pam_unix(systemd-user:session): session opened for user roland by (uid=0)
Aug 18 19:11:41 arch0713 systemd[13047]: Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.
Aug 18 19:11:41 arch0713 systemd[1]: [email protected]: Failed with result 'protocol'.
Aug 18 19:11:41 arch0713 systemd[1]: Failed to start User Manager for UID 1000.

唯一失败的服务:

# systemctl --failed

  UNIT              LOAD   ACTIVE SUB    DESCRIPTION[email protected] loaded failed failed User Manager for UID 1000

我还有一些其他的 Arch 安装,其设置基本相同,但问题并不存在。所以我似乎只损坏了这台机器。

重新启动没有帮助。

echo当告诉我已设置$XDG_RUNTIME_DIR 时,我可以检查什么来查找错误的原因?

我不熟悉 systemd 源代码,这当然是一个值得一看的地方,最终我会的,但也许有人给我一个提示。

答案1

我添加了一些额外的日志条目 ( pam_syslog),journalctl --boot摘录如下。

pam_systemd.c

453        if (streq_ptr(service, "systemd-user")) {

未输入。之后还会继续。之后的行MYISSUEupdate被执行,但那是在有问题的错误条目之后。

   673            r = update_environment(handle, "XDG_RUNTIME_DIR", runtime_path);
    Aug 25 15:49:18 arch0713 login[424]: pam_systemd(login:session): MYISSUE
    Aug 25 15:49:18 arch0713 login[424]: pam_systemd(login:session): MYISSUEafter
    Aug 25 15:49:18 arch0713 kernel: audit: type=1006 audit(1566740958.028:33): pid=424 uid=0 old-auid=4294967295 auid=1000 tty=tty1 old-ses=4294967295 ses=1 res=1
    Aug 25 15:49:18 arch0713 systemd-logind[397]: New session 1 of user roland.
    Aug 25 15:49:18 arch0713 systemd[1]: Created slice User Slice of UID 1000.
    Aug 25 15:49:18 arch0713 systemd[1]: Starting User Runtime Directory /run/user/1000...
    Aug 25 15:49:18 arch0713 systemd[1]: Started User Runtime Directory /run/user/1000.
    Aug 25 15:49:18 arch0713 audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=user-runtime-dir@1000 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? te>
    Aug 25 15:49:18 arch0713 kernel: audit: type=1130 audit(1566740958.058:34): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=user-runtime-dir@1000 comm="systemd" exe="/usr/lib/systemd/sy>
    Aug 25 15:49:18 arch0713 systemd[1]: Starting User Manager for UID 1000...
    Aug 25 15:49:18 arch0713 systemd[572]: pam_unix(systemd-user:session): session opened for user roland by (uid=0)
    Aug 25 15:49:18 arch0713 systemd[572]: Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.
    Aug 25 15:49:18 arch0713 kernel: audit: type=1130 audit(1566740958.078:35): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=user@1000 comm="systemd" exe="/usr/lib/systemd/systemd" hostn>
    Aug 25 15:49:18 arch0713 audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=user@1000 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res>
    Aug 25 15:49:18 arch0713 systemd[573]: pam_unix(systemd-user:session): session closed for user roland
    Aug 25 15:49:18 arch0713 systemd[1]: [email protected]: Failed with result 'protocol'.
    Aug 25 15:49:18 arch0713 login[424]: pam_systemd(login:session): MYISSUEafter1
    Aug 25 15:49:18 arch0713 systemd[1]: Failed to start User Manager for UID 1000.
    Aug 25 15:49:18 arch0713 login[424]: pam_systemd(login:session): MYISSUEafter2
    Aug 25 15:49:18 arch0713 systemd[1]: Started Session 1 of user roland.
    Aug 25 15:49:18 arch0713 login[424]: pam_systemd(login:session): MYISSUEafter3
    Aug 25 15:49:18 arch0713 login[424]: pam_systemd(login:session): MYISSUEupdate

然后我发现了这个类似问题

我比较了

/etc/pam.d/systemd-user

account include system-auth
session include system-auth
auth required pam_deny.so
password required pam_deny.so

我的旧有问题的安装与工作较新的安装。

account include system-login
session required pam_loginuid.so
session include system-login

复制这个就解决了这个问题。看来这并没有被命令改变pacman -Syu。我没有找到太平洋新

相关内容