fedora core 3, httpd and PHP exec()
Hi,
I'm running PHP in safe mode, and trying to run system command (uptime) in exec() statement. When i turn off the selinux (via firewall settings in KDE), the script works fine, but when its enabled, i get the following error in /var/log/messages
Dec 25 04:15:26 melville kernel: audit(1103948126.072:0): avc: denied
{ read }
for pid=5926 exe=/usr/sbin/httpd name=sh dev=hda2 ino=670441
scontext=root:sys
tem_r:httpd_t tcontext=system_u:object_r:bin_t tclass=lnk_file
Dec 25 04:17:46 melville kernel: audit(1103948266.882:0): avc: denied
{ read }
for pid=5944 exe=/usr/sbin/httpd name=sh dev=hda2 ino=670441
scontext=root:sys
tem_r:httpd_t tcontext=system_u:object_r:bin_t tclass=lnk_file
I tried using chcon (chcon -R -t httpd_sys_script_exec_t .) , but of no use as i dont know how to set permissions for binary files.
Please advise!
BR. Zia
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 10 lines · Zia Syed
I'm running PHP in safe mode, and trying to run system command (uptime) in
exec()statement. When i turn off the selinux (via firewall settings in KDE), the script works fine, but when its enabled, i get the following error in/var/log/messagesDec 25 04:15:26 melville kernel: audit(1103948126.072:0): avc: denied{ read }
for pid=5926 exe=/usr/sbin/httpd name=sh dev=hda2 ino=670441
scontext=root:sys
tem_r:httpd_t tcontext=system_u:object_r:bin_t tclass=lnk_file
Quoted 5 lines
Dec 25 04:17:46 melville kernel: audit(1103948266.882:0): avc: denied{ read }
for pid=5944 exe=/usr/sbin/httpd name=sh dev=hda2 ino=670441
scontext=root:sys
tem_r:httpd_t tcontext=system_u:object_r:bin_t tclass=lnk_file
We should allow it to read such sym-links.
Probably the best thing to do for executing programs via system(3) (as it seems PHP is doing) is to have a domain_auto_trans() rule.
Maybe domain_auto_trans(httpd_t, shell_exec_t, httpd_sys_script_t)?
Signature · 9 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 3 lines · Zia Syed
Thanks for your reply. Where should I write this rule? I search for documentation on selinux and according to them i need to put them in a .te file. However, I dont have any .te file on my system.
You need to install the package selinux-policy-X-sources where "X" is either "targeted" or "strict" depending on what you installed (most likely targeted).
Signature · 9 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 21 lines · Russell Coker
Quoted 10 lines · Zia Syed
I'm running PHP in safe mode, and trying to run system command (uptime) in
exec()statement. When i turn off the selinux (via firewall settings in KDE), the script works fine, but when its enabled, i get the following error in/var/log/messagesDec 25 04:15:26 melville kernel: audit(1103948126.072:0): avc: denied{ read }
for pid=5926 exe=/usr/sbin/httpd name=sh dev=hda2 ino=670441 scontext=root:sys
tem_r:httpd_t tcontext=system_u:object_r:bin_t tclass=lnk_fileQuoted 7 lines
Dec 25 04:17:46 melville kernel: audit(1103948266.882:0): avc: denied{ read }
for pid=5944 exe=/usr/sbin/httpd name=sh dev=hda2 ino=670441 scontext=root:sys
tem_r:httpd_t tcontext=system_u:object_r:bin_t tclass=lnk_file
Quoted 8 lines
We should allow it to read such sym-links.
Probably the best thing to do for executing programs via system(3) (as it seems PHP is doing) is to have a
domain_auto_trans()rule.Maybe
domain_auto_trans(httpd_t, shell_exec_t, httpd_sys_script_t)?
Reading the policy, it looks like if you set the boolean httpd_ssi_exec you get this rule.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.