Systemctl 服务:以非 root 身份运行时未找到单元

Systemctl 服务:以非 root 身份运行时未找到单元

我有以下自定义 systemctl 服务定义:

[Unit]
Description=DIALOG communication control server
After=network.target

[Service]
Restart=always
RestartSec=5
User=daq
Environment="LD_LIBRARY_PATH=/online/subsystems/daq/RCCARS/amber-rccars-lib/lib/release/"
Environment="PATH=/usr/sue/sbin:/usr/sue/bin:/usr/lib64/qt-3.3/bin:/root/perl5/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin:/root/bin"
Environment="DIALOG_CONTROL_SERVER_PORT=55550"

ExecStart=/online/subsystems/daq/RCCARS/amber-rccars-daq/DIALOGCommunicationControlServer/bin/release/_rccars_DIALOGCommunicationControlServer


[Install]
WantedBy=multi-user.target

用户daq应该能够在没有 root 密码的情况下重新启动此服务,因此我添加了此行/etc/sudoers

%daq ALL= NOPASSWD: /bin/systemctl restart DIALOGServer.service

重新启动以 root 身份进行,但作为用户daq,我得到以下信息:

sudo -l

Matching Defaults entries for daq on pcamma00:
    !visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin, env_reset, env_keep="COLORS DISPLAY
    HOSTNAME HISTSIZE KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE",
    env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC
    LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",
    secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin

User daq may run the following commands on pcamma00:
    (daq) NOPASSWD: ALL
    (daq) NOPASSWD: ALL
    (root) NOPASSWD: /bin/systemctl restart DIALOGServer.service

如果我输入:

sudo /bin/systemctl restart DIALOGServer.service

我得到:

Failed to restart DIALOGServer.service: Unit not found

知道为什么当我不是 root 时找不到该单元吗?

相关内容