PHP shell_exec, permission denied to execute -rwxrwxrwx shell script

I am currently on top of ssh on a remote CentOS 5.6 system that runs the Apache web server. I need to use the poppler pdftohtml pdftohtml , which unfortunately is not currently installed on this machine. So I downloaded the poppler package and built it under my user folder. Since I am not a system administrator, I did not

 make install 

and I have all my compiled files in

 /users/myfolder/poppler-0.18.2/ 

The file I need to execute through php shell_exec() is

 /users/myfolder/poppler-0.18.2/utils/pdftohtml 

If I executed it through my ssh bash, I get the correct output. If I instead put this line in a PHP script:

 echo shell_exec("/users/myfolder/poppler-0.18.2/utils/pdftohtml"); 

I get the following output:

 sh: /users/myfolder/poppler-0.18.2/utils/pdftohtml: Permission denied 

I tried to set file permissions for 777, which are currently -rwxrwxrwx. I also noticed that using shell_exec("whoami"); leads to "apache". Can apache execute the script if the file permissions are rwxrwxrwx?

I also know that installing poppler through make install will solve the problem, but since this is intended for testing, I would like to avoid "infecting" the system outside my personal folder until testing is complete.

Thanks to everyone who will help!

+2
source share
1 answer

Just because the file is executable to the user does not mean that the user can actually execute the file. The user should also be able to "get to" the file: the user needs execute permission for all the "parent directories", in your case for / users, myfolder, poppler-0.18.2 and utils.

Assuming / users is the same as / home, everyone should have + x. From there you can install it: just do chmod o+x /users/myfolder /users/myfolder/poppler-0.18.2 /users/myfolder/poppler-0.18.2/utils

(Note. This will allow everyone to execute this binary, not just Apache.)

If you are an apache user and you are sharing a group, it would be better to use the chown poppler directory and everything that belongs to this group and set g + x instead of o + x.

+8
source

All Articles