Systemd

創建了使用者服務。返回錯誤“在步驟 GROUP 生成失敗:不允許操作”

  • November 19, 2019

我創建了一個服務。

admin@Xroklaus:~ $ cat /etc/systemd/user/duniter.service 
[Unit]
Description=Duniter node
After=network.target
ConditionPathExists=/home/folatt/.config/duniter/duniter_default/duniter.db

[Service]
Group=folatt
User=folatt
Type=forking
ExecStart=/usr/bin/duniter webstart
ExecReload=/usr/bin/duniter webrestart
ExecStop=/usr/bin/duniter stop
Restart=on-failure

[Install]
WantedBy=multi-user.target

重新啟動後,它不會載入。

folatt@Xroklaus:~ $ systemctl --user status duniter.service
● duniter.service - Duniter node
  Loaded: loaded (/etc/systemd/user/duniter.service; enabled)
  Active: failed (Result: start-limit) since Sun 2018-01-07 20:31:43 UTC; 1min 3s ago
 Process: 2212 ExecStart=/usr/bin/duniter webstart (code=exited, status=216/GROUP)

Journalctl 提供了有關錯誤的更多資訊。

admin@Xroklaus:~ $ sudo journalctl -p 3 --no-pager
-- Logs begin at Sun 2018-01-07 20:30:33 UTC, end at Sun 2018-01-07 20:31:49 UTC. --
Jan 07 20:30:39 Xroklaus bluetoothd[876]: Sap driver initialization failed.
Jan 07 20:30:39 Xroklaus bluetoothd[876]: sap-server: Operation not permitted (1)
Jan 07 20:31:26 Xroklaus systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Jan 07 20:31:42 Xroklaus systemd[2203]: Failed at step GROUP spawning /usr/bin/duniter: Operation not permitted
Jan 07 20:31:42 Xroklaus systemd[2177]: Failed to start Duniter node.
Jan 07 20:31:42 Xroklaus systemd[2206]: Failed at step GROUP spawning /usr/bin/duniter: Operation not permitted
Jan 07 20:31:42 Xroklaus systemd[2177]: Failed to start Duniter node.
Jan 07 20:31:43 Xroklaus systemd[2208]: Failed at step GROUP spawning /usr/bin/duniter: Operation not permitted
Jan 07 20:31:43 Xroklaus systemd[2177]: Failed to start Duniter node.
Jan 07 20:31:43 Xroklaus systemd[2210]: Failed at step GROUP spawning /usr/bin/duniter: Operation not permitted
Jan 07 20:31:43 Xroklaus systemd[2177]: Failed to start Duniter node.
Jan 07 20:31:43 Xroklaus systemd[2212]: Failed at step GROUP spawning /usr/bin/duniter: Operation not permitted
Jan 07 20:31:43 Xroklaus systemd[2177]: Failed to start Duniter node.
Jan 07 20:31:43 Xroklaus systemd[2177]: Failed to start Duniter node.

但這就是我所得到的。我不知道解決方案是什麼。

我移動了服務文件並刪除了使用者和組,同時還更改了安裝目標,如下所示:

/usr/lib/systemd/user/duniter.service

[Unit]
Description=Duniter node
After=network.target
ConditionPathExists=/home/folatt/.config/duniter/duniter_default/duniter.db

[Service]
Type=forking
ExecStart=/usr/bin/duniter webstart
ExecReload=/usr/bin/duniter webrestart
ExecStop=/usr/bin/duniter stop
Restart=on-failure

[Install]
WantedBy=default.target

如果您有使用者和/或組依賴於網路服務(例如 LDAP)的服務,則必須將相應的服務(例如 nslcd)添加到

$$ Unit $$服務定義文件的部分。 如果在尚不可用的網路目錄中定義了使用者或組,則服務將無法啟動,並出現“在步驟 GROUP spawning 時失敗”錯誤。

引用自:https://unix.stackexchange.com/questions/415521