Linux
Samba 不會以 systemd 啟動
我在 centos 8 上從原始碼安裝 samba 4.12.6。
當我直接啟動 samba
/usr/local/samba/sbin/samba
它按預期執行。
現在我創建一個 systemd 單元:
[Unit] Description=Samba Active Directory Domain Controller After=network.target [Service] Type=forking ExecStart=/usr/local/samba/sbin/samba -D PIDFile=/usr/local/samba/var/run/samba.pid ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=default.target
啟動它,它失敗,權限被拒絕
[root@centos-server-01 ~]# systemctl status samba-ad.service ● samba-ad.service - Samba Active Directory Domain Controller Loaded: loaded (/etc/systemd/system/samba-ad.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2020-09-04 19:03:24 CEST; 14s ago Process: 1549 ExecStart=/usr/local/samba/sbin/samba -D (code=exited, status=203/EXEC) Sep 04 19:03:24 centos-server-01 systemd[1]: Starting Samba Active Directory Domain Controller... Sep 04 19:03:24 centos-server-01 systemd[1]: samba-ad.service: Control process exited, code=exited status=203 Sep 04 19:03:24 centos-server-01 systemd[1]: samba-ad.service: Failed with result 'exit-code'. Sep 04 19:03:24 centos-server-01 systemd[1]: Failed to start Samba Active Directory Domain Controller.
journalctl
顯示:journalctl _PID=1549 -- Logs begin at Fri 2020-09-04 18:00:19 CEST, end at Fri 2020-09-04 19:03:39 CEST. -- Sep 04 19:03:24 centos-server-01 systemd[1549]: samba-ad.service: Failed to execute command: Permission denied Sep 04 19:03:24 centos-server-01 systemd[1549]: samba-ad.service: Failed at step EXEC spawning /usr/local/samba/sbin/samba: Permission denied
samba 二進製文件是可執行的:
ls -al /usr/local/samba/sbin/ total 2816 -rwxr-xr-x. 1 root root 771608 Sep 2 17:28 eventlogadm -rwxr-xr-x. 1 root root 331304 Sep 2 17:28 nmbd -rwxr-xr-x. 1 root root 58280 Sep 2 17:27 samba -rwxr-xr-x. 1 root root 3616 Sep 1 20:15 samba-gpupdate . .
file
顯示:/usr/local/samba/sbin/samba: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically li nked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=3f9ee20e102f467fc 12e1b4bc913472f23dcde0b, not stripped
我總是以 root 身份登錄。我閱讀了在執行生成步驟中失敗…權限被拒絕和以下內容,但它沒有幫助。
也許有人對我有線索
SELinux 將可在 ExecStart 中使用的二進製文件限制為具有
system_u:object_r:bin_t:s0
屬性集的路徑。通常這些是/usr/bin /usr/sbin /usr/libexec /usr/local/bin
目錄。您需要將 samba 二進製文件移動到此目錄之一或更改 selinux 策略以允許 systemd 使用 /usr/local/samba/sbin/ 中的二進製文件:chcon -R -t bin_t /usr/local/samba/sbin/