Samba non si avvia con systemd

Sep 05 2020

Installa samba 4.12.6 dal sorgente su centos 8.

Quando avvio direttamente samba

/usr/local/samba/sbin/samba

funziona come previsto.

Ora creo un'unità 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

Avvialo e fallisce con il permesso negato

[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 Spettacoli:

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

Il binario di samba è eseguibile:

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 Spettacoli:

/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

Sono sempre connesso come root. Ho letto Fallito al passaggio EXEC spawning ... Autorizzazione negata e quanto segue ma non ha aiutato.

Forse qualcuno ha un'idea per me

Risposte

2 kofemann Sep 05 2020 at 19:30

SELinux limita i binari che possono essere usati in ExecStart ai percorsi che hanno gli system_u:object_r:bin_t:s0attributi impostati. In genere si tratta di /usr/bin /usr/sbin /usr/libexec /usr/local/bindirectory. È necessario spostare il binario di samba in una di queste directory o modificare la politica di selinux per consentire a systemd di utilizzare i binari in / usr / local / samba / sbin / come:

chcon -R -t bin_t /usr/local/samba/sbin/