1
votes

We moved from Slackware to CentOS here, it was working fine then without notice, php stopped executing external calls such as calls to "wc" and "spamc". All such calls appear on error_log as:

sh: /usr/bin/spamc: Permission denied

The paths are correct. We have the permissions set correctly and apache is supposed to be able to execute the files with no problem. We're NOT on safe_mode and we do not have base_dir set. It is not SELinux, or at least sestatus says SELinux is disabled.

summary:

  • PHP can't execute anything thru exec() or popen()
  • Paths to binaries are correct.
  • We are not in safe mode
  • We don't have base_dir set
  • Permissions on the binaries allow apache user to execute them
  • SELinux is disabled
  • disable_functions in php.ini is empty
  • We have no clue why it doesn't work

PHP version 5.3.3 and CentOS 5.5

Anyone has a clue of what might be happening? Thanks in advance

4
Could probably be better answered on Server Fault or Webmasters: serverfault.com or webmasters.stackexchange.com - Orbling
This question is better suited to serverfault.com - Todd Moses
@Andre Garzia - What is your full command like ? - ajreal
What a stupid phrasing: "php can't...". Remember, every time something doesn't work, it's not php but you to blame. - Your Common Sense
well, it seems you´re confusing "php can´t" as in php doesn´t have such feature with "php can´t" meaning "my php installation is unable to do such and such". And the blame was not on me because I did not changed the permissions to break the system. Also your comment added nothing to the discussion or the solution, which mean it is useless, you should help people and not blame them. They are here for help not so you can feel superior. We still do not know what changed "usr" to 644 but it was not a user initiated thing and sure it was not my fault. Damn people, always trying to blame someone... - Andre Garzia

4 Answers

2
votes

SELinux is blocking your attempts to run them. I recommend you come up with rules that allow you to run the subset of external commands required and load that as a module.

1
votes

Found the error.

I was trying to execute /usr/bin/tidy for example, the usr folder had a 644 permission which is akin to lovecraftian horror in my book. I could work because I was root.

I figured it out after going crazy and deciding to check the permissions on all the path components of the command from the root / folder to the tidy binary, I found all permissions set correctly but the usr folder perms were completely screwed.

This is fixed.

0
votes

Does PHP run as Apache on the server? I thought it ran as Nobody..

0
votes

https://serverfault.com/questions/207989/php-cant-execute-any-external-command/208001#208001

Generally PHP on centOS is ran as nobody unless you have compiled php as fastcgi, dso etc...