I want allow PHP script to execute external command with another user with exec. For this, I call my command like :
exec('sudo -u username /usr/bin/command -a arg1 --arg2 arg2');
In sudoers rules, I have added :
apache ALL=(username)NOPASSWD: /usr/bin/command
Command send TCP paquets. When SELinux is disable, it's work.
To allow SELinux, I have enable, by setroubleshoot rapport :
- httpd_setrlimit -- why apache want change limit for execute simple command ??
- httpd_mod_auth_pam -- Ok, apache can use pam, why not.
- httpd_unified -- why apache want to access memcache ??
But, even after that, after log analyse, I have "unix_chkpwd" and, to terminate the SELinux configuration, apache need to read shadow file.
ausearch -c 'unix_chkpwd' -ts recent --raw | audit2allow
#============= httpd_t ==============
allow httpd_t chkpwd_t:process { noatsecure rlimitinh siginh };
allow httpd_t shadow_t:file { getattr open read };
It's really necessary to add this module ? It's not possible to execute a simple command with another user executed by apache ?
How optimise my SELinux configuration for this simple action ?
Best regards,