Forums:
Hola.!
Tengo un Centos7 y necesito reiniciarlo desde una página en php, pero sin deshabilitar el SeLinux.
En sudoers tengo
Defaults:apache !requiretty
apache ALL=(ALL) NOPASSWD: /sbin/reboot
Con php ejecuto
system('sudo /sbin/reboot')
y en audit.log obtengo
type=AVC msg=audit(1423351504.095:18585): avc: denied { getattr } for pid=29484 comm="sudo" path="/usr/bin/systemctl" dev="dm-1" ino=33597973 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:systemd_systemctl_exec_t:s0 tclass=file
type=AVC msg=audit(1423351504.095:18586): avc: denied { getattr } for pid=29484 comm="sudo" path="/usr/bin/systemctl" dev="dm-1" ino=33597973 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:systemd_systemctl_exec_t:s0 tclass=file
type=AVC msg=audit(1423351504.095:18587): avc: denied { getattr } for pid=29484 comm="sudo" path="/usr/bin/systemctl" dev="dm-1" ino=33597973 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:systemd_systemctl_exec_t:s0 tclass=file
type=AVC msg=audit(1423351504.096:18588): avc: denied { getattr } for pid=29484 comm="sudo" path="/var/db/sudo" dev="dm-1" ino=554623 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:sudo_db_t:s0 tclass=dir
type=AVC msg=audit(1423351504.099:18589): avc: denied { read } for pid=29487 comm="unix_chkpwd" name="shadow" dev="dm-1" ino=34749252 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:shadow_t:s0 tclass=file
type=AVC msg=audit(1423351504.104:18590): avc: denied { search } for pid=29488 comm="sendmail" name="postfix" dev="dm-1" ino=34220000 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:postfix_etc_t:s0 tclass=dir
Me podrían ayudar a solucionarlo?
saludos.!
audit2allow
Hola Monkito.
Efectivamente, selinux esta restringiendo el acceso y el uso de varios comandos en el sistema operativo, incluyendo sudo.
Este enlace puede ofrecerte ayuda en relacion con este inconveniente:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Fixing_Problems-Allowing_Access_audit2allow.html
Espero que esto pueda ayudarte.
Saludos,