Title says it all; I cannot run shell commands properly from PHP (CGI).
Most commands (
pwd and my own program) end with an exit code of 1 (permission denied).
ls ends with an exit code of 2.
- Apache is running as apache:apache (user/group)
- PHP is not chrooted (AFAIK) if you know a definitive way to find out, please reply
- PHP is not in SAFE_MODE
- selinux is DISABLED (sestatus says so)
- suexec is enabled (not sure what to do with it though)
- Functions are not disabled from PHP (otherwise I'd get scripting errors instead of exit codes)
Things I tried:
- Disabled selinux (it was enabled)
- Made apache to run as root (it crashed - a well known issue)
- Changed file permissions of my entire DOCROOT to 0755 and 0777 (and back)
- Changed file owner of my entire DOCROOT to root and nobody, both caused apache to show "access denied" errors
- To use
straceto get a clue of what's going on, but it failed as well
- Run PHP code through CLI (
php -r "echo exec('pwd');") - and it works
- Ensure error logging is at it's max (and displayed), both for PHP and Apache (E_ALL / Debug) - no errors showed up
[HTTP_HOST] => localhost [HTTP_USER_AGENT] => Mozilla/5.0 (X11; U; Linux i686; en-US; rv:18.104.22.168) Gecko/20110622 CentOS/3.6-1.el5.centos Firefox/3.6.18 [HTTP_ACCEPT] => yaddayaddayaddayaddayadda [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip,deflate [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [HTTP_KEEP_ALIVE] => 115 [HTTP_CONNECTION] => keep-alive [HTTP_REFERER] => http://localhost/K2F/?test=system-check [HTTP_CACHE_CONTROL] => max-age=0 [PATH] => /sbin:/usr/sbin:/bin:/usr/bin [SERVER_SIGNATURE] => <address>Apache/2.2.3 (CentOS) Server at localhost Port 80</address> [SERVER_SOFTWARE] => Apache/2.2.3 (CentOS) [SERVER_NAME] => localhost [SERVER_ADDR] => 127.0.0.1 [SERVER_PORT] => 80 [REMOTE_ADDR] => 127.0.0.1 [DOCUMENT_ROOT] => /var/www/html [SERVER_ADMIN] => root@localhost [SCRIPT_FILENAME] => /var/www/html/K2F/index.php [REMOTE_PORT] => 49341 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => test=wkhtmltox [REQUEST_URI] => /K2F/?test=wkhtmltox [SCRIPT_NAME] => /K2F/index.php [PHP_SELF] => /K2F/index.php [REQUEST_TIME] => 1315908875
Misc. PHP functions
[GID] => 48 ---------------.___ both are correct [UID] => 48 ---------------' [PID] => 4152 [USR] => apache -----------.___ fine as well [CWD] => /var/www/html/K2F --'