systemctl 以其他用户身份进行身份验证

systemctl 以其他用户身份进行身份验证

我制作了这个脚本,允许对目录进行非根访问,以便程序可以更改所述目录中的文件。这个 .service 已经在一些机器上运行过,甚至在过去也可以在同一台机器上运行,但是在重新安装 arch linux 之后systemd/systemctl是“Authenticating as: mpd”。

奇怪的是当我用来sudo启动它时。它可以工作,但使用启用不会在重新启动后持续存在。

我真的不知道我在做什么,所以我很抱歉,学期结束后我会阅读 systemd。

[oddstap@Arch2019 ~]$ systemctl enable brightlight.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ====
Authentication is required to manage system service or unit files.
Authenticating as: mpd
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ====
Failed to enable unit: Access denied
[oddstap@Arch2019 ~]$

我不太确定为什么会这样,我尝试了一些方法,例如使用标志--user然后给出确切的目录。它的结果好坏参半/我也尝试将服务文件放入其中,/etc/systemd/system只是做同样的事情。

[oddstap@Arch2019 /usr/lib/systemd/system]$ systemctl --user enable /usr/lib/systemd/system/brightlight.service
Removed /home/oddstap/.config/systemd/user/multi-user.target.wants/brightlight.service.
Created symlink /home/oddstap/.config/systemd/user/multi-user.target.wants/brightlight.service → /usr/lib/systemd/system/brightlight.service.
[oddstap@Arch2019 /usr/lib/systemd/system]$

我认为我见过类似的问题关于服务器故障

这是我在这里发布的 .service 文件,我很确定这不是原因,但我可能是错的。我会尝试解决这个问题,但如果有人有任何想法请告诉我。没有 systemd 启用脚本让我的生活变得艰难。

[Unit]
Description Hopefully will be a solution for you reading.
Before nodered.service

[Service]
Type oneshot
User root
ExecStart=/bin/bash -c "/bin/chmod a+w /sys/class/backlight/intel_backlight/*"

[Install]
WantedBy=multi-user.target

答案1

好吧,我将保留我的问题,以防万一有人能找到适当的解决方案。我可以通过卸载 mpd 然后删除 mpd 用户并重新安装来修复它。它很粗糙,但如果其他人能找出更好的方法来做到这一点,或者甚至为什么首先会发生这种情况,我会很感激。

相关内容