比较来自世界各地的卖家的域名和 IT 服务价格

无法使用 `systemctl --user` 因为“无法获得连接 D-bus: 该决议否认了 »

我正在尝试在用户级别配置服务
https://serverfault.com/a/906224
在类似的问题上。 我创建了必要的文件并重新启动。

我最好是因为现在我被“无法建立连接” D-bus: 决议被拒绝“当它”未能建立连接 D-bus: 连接被拒绝“,但我处于死胡同,因为我不知道他试图获得哪个对象 (文件? 插座?) 因此,甚至无法检查当前的权限。 有任何想法吗?

我补充说:

loginctl enable-linger userservice

/usr/lib/systemd/user/dbus.service (-rw-r - r - 根根)

[Unit]
Description=D-Bus User Message Bus
Requires=dbus.socket

[Service]
ExecStart=/usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation
ExecReload=/usr/bin/dbus-send --print-reply --session --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig

[Install]
Also=dbus.socket

/usr/lib/systemd/user/dbus.socket (-rw-r - r - 根根)

[Unit]
Description=D-Bus User Message Bus Socket

[Socket]
ListenStream=%t/bus
ExecStartPost=-/bin/systemctl --user set-environment DBUS_SESSION_BUS_ADDRESS=unix:path=%t/bus

[Install]
WantedBy=sockets.target
Also=dbus.service

/home/uservice/.config/systemd/user/uservice.service

[Unit]
Description=Test user-level service

[Service]
Type=dbus
BusName=com.wtf.service
ExecStart=/home/userservice/userservice.py
Restart=on-failure

[Install]
WantedBy=default.target

其他地方没有链接 ...

这样它失败了:

systemctl --user status

改变 2018-10-25:

添加

export XDG_RUNTIME_DIR=/run/user/$(id -u)



.bashrc

. 该变量已安装,现在我得到:

Failed to get D-us connection: no such file or directory

. 说来也怪

man systemctl

我们

systemctl --help

提到

--user

选择,同时提及

--system

并指定此默认值 (什么是其他参数).

使用 RHEL 7.4 (从

systemd 219

据报道称

systemctl --version

) 通过 SELinux.
已邀请:

裸奔

赞同来自:

所以,有一个很长一段时间的问题

XDG_RUNTIME_DIR

登录用户时,未正确设置环境变量,也无法安装,因此无法访问用户 D-Bus. 除了本地图形控制台之外,用户使用不同的方法进入系统时会发生这种情况。

您可以通过添加到用户来绕过它

$HOME/.bashrc

:

export XDG_RUNTIME_DIR=/run/user/$(id -u)

然后再次登录并登录。

君笑尘

赞同来自:

我注意到了服务器 tableau 用途 --user systemd services - 他们甚至在文件中有一个关于这个的说明:
https://help.tableau.com/curre ... r.htm
用户服务 systemd 不像经常流程经理一样使用 systemd. Red Hat 禁用用户服务 systemd 在 RHEL 7 (因此,在所有分布中 RHEL, 如 CentOS, Oracle Linux 7, Amazon Linux 2). 但 RedHat 保证 Tableau, 启动用户服务 systemd 支持,直到重新启用服务。

他们是如何做到的呢 (具有用户ID的示例 29575)

# cat /etc/systemd/system/user@29575.service
[Unit]
Description=User Manager for UID %i
After=systemd-user-sessions.service
# These are present in the RHEL8 version of this file except that the unit is Requires, not Wants.
# It's listed as Wants here so that if this file is used in a RHEL7 settings, it will not fail.
# If a user upgrades from RHEL7 to RHEL8, this unit file will continue to work until it's
# deleted the next time they upgrade Tableau Server itself.
After=user-runtime-dir@%i.service
Wants=user-runtime-dir@%i.service

[Service]
LimitNOFILE=infinity
LimitNPROC=infinity
User=%i
PAMName=systemd-user
Type=notify
# PermissionsStartOnly is deprecated and will be removed in future versions of systemd
# This is required for all systemd versions prior to version 231
PermissionsStartOnly=true
ExecStartPre=/bin/loginctl enable-linger %i
ExecStart=-/lib/systemd/systemd --user
Slice=user-%i.slice
KillMode=mixed
Delegate=yes
TasksMax=infinity
Restart=always
RestartSec=15

[Install]
WantedBy=default.target

创建此文件后:

systemctl daemon-reload
systemctl enable user@29575.service
systemctl start user@29575.service

你需要安装 XDG_RUNTIME_DIR 在 env 这个用户在周围 bashrc 或类似:

[ -z "${XDG_RUNTIME_DIR}" ] && export XDG_RUNTIME_DIR=/run/user/$(id -ru)

我测试了最新版本 RHEL 7.8, 并且正如预期的那样,她可以运行 "systemctl --user status" 作为我的用户。

要回复问题请先登录注册