TheShipsMast Posted March 28, 2006 Share Posted March 28, 2006 hi guys,hopefully someone here can help.. I have trawled every forum and googled for a week now, and still cant get this fixed..I have CentOS4.2 installed, with apache2 and php4 rpm installs. httpd is running under user apache. I have full control over the server.DocumentRoot is set to /var/www/htmlmy php page I am trying to execute is this simple one:sr.php<?shell_exec("/tmp/ls.sh > /tmp/output")?>when I load sr.php in a browser, nothing happens. ( I am not expecting anything on screen, but /tmp/output never gets created).a tail of /var/log/http/error_log showssh: /tmp/ls.sh: Permission deniednow, /tmp has 777 perms, and if I runsu -c "/tmp/ls.sh" apache the file /tmp/output gets created.if I change sr.php to<?shell_exec("ls > /tmp/output")?>the file /tmp/output gets created!so it appears php will run system commands, but not user scripts.Any ideas as to why I can not run user scripts from within PHP??This has got me utterly beaten..Thanks in advancenote: I do have semi-colons at the end my code, but everytimeI tried and posted with one, the page wouldnt submit, and gave me an error on the forumedit:php isnt producing any error logs, but this is from the syslog..Mar 28 15:05:26 dell2 kernel: audit(1143554726.143:86): avc: denied { execute } for pid=5652 comm="sh" name="ls.sh" dev=dm-0 ino=4898845 scontext=root:system_r:httpd_sys_script_t tcontext=root:object_r:tmp_t tclass=fileMar 28 15:05:26 dell2 kernel: audit(1143554726.143:87): avc: denied { getattr } for pid=5652 comm="sh" name="ls.sh" dev=dm-0 ino=4898845 scontext=root:system_r:httpd_sys_script_t tcontext=root:object_r:tmp_t tclass=fileMar 28 15:05:26 dell2 kernel: audit(1143554726.144:88): avc: denied { getattr } for pid=5652 comm="sh" name="ls.sh" dev=dm-0 ino=4898845 scontext=root:system_r:httpd_sys_script_t tcontext=root:object_r:tmp_t tclass=file Quote Link to comment Share on other sites More sharing options...
Desdinova Posted March 29, 2006 Share Posted March 29, 2006 I might have a simular problem.. I'm trying to run a shell_exec with a ping, but this only works well when run from a browserwindow. Through a cronjob it's not running the shell_exec at all.. Quote Link to comment Share on other sites More sharing options...
TheShipsMast Posted March 29, 2006 Author Share Posted March 29, 2006 Think I may have sussed the problem.. although I have b0rked my server in the process.. so heed warnings!The problem (I THINK) is to do with SELinux being implemented on the box, and not allowing apache to run scripts.Although, when I tried to loosen up the policies, and rebooted the box...that was 18 hours ago, and the box still isnt pinging :( and its in a datacentre, and the support guys are utter rubbish..arse Quote Link to comment Share on other sites More sharing options...
craygo Posted March 29, 2006 Share Posted March 29, 2006 I am not too farmiliar with the programs on linux. but in windows in order for me to run a batch file which is similar to an sh file in linux, I had to give permissions to the batch file AND the cmd.exe executable to the user account. This is because the cmd function is what runs the .bat file.So in your case you would have to give execute permission to the sh executable and the script you want to run to the apache account.this is how it is on windows anyway.Ray Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.