【发布时间】:2019-02-12 18:04:40
【问题描述】:
我正在尝试使用 systemctl 启动我的 exampleService.service,而不以 root 身份登录。我创建了名为 testGroup 的组并在那里添加了我的帐户 - testAccount。我的服务文件位于 /etc/systemd/system 并且我有在/etc/sudoers.d 中创建了文件testConfig,内容如下:
%testAccount ALL= NOPASSWD: /etc/systemd/system start exampleService.service
%testAccount ALL= NOPASSWD: /etc/systemd/system stop exampleService.service
%testAccount ALL= NOPASSWD: /etc/systemd/system restart exampleService.service
#includedir /etc/sudoers.d 行也存在于 sudoers 文件中。现在,当我尝试以以下身份启动服务时:systemctl start exampleService.service(以testAccount 登录)我会弹出输入密码,但它应该' t 是必需的。我的配置中的问题可能出在哪里?
【问题讨论】:
-
您正在运行以启动服务的命令是
/bin/systemctl(或者可能是/sbin/systemctl或/usr/bin/systemctl,取决于发行版),所以这是您需要加入白名单的命令,而不是/etc/systemd/system. sudo 不知道systemctl start exampleService.service与/etc/systemd/system目录有什么关系。