PHP function is_executable returns false even though the file is definitely executable
I'm using PHP 5.3.
Using getfacl the files permissions are:
user::rwx
group::r-x
other::r-x
I also am having problems using PHP's Program execution Functions, http://www.php开发者_运维百科.net/manual/en/ref.exec.php
The program in question is wkhtmltopdf and I have it in my /usr/bin directory.
I have the convert program in my /usr/bin directory with the exact same permissions and the is_executable function returns true.
For me the answer was to create a policy module to allow wkhtmltopdf to run without disabling SELinux:
sudo su -
(run as root to make the next steps simpler)tail -F /var/log/audit.log | grep wkhtml > wkhtml.audit
(leave this running and continue to next step)- try to load your web page that attempts to create a pdf, it will fail as before but now we are logging.
- CTRL+C to stop the process from step 2 (can skip to 7 if in a hurry, but it's strongly suggested you use these review steps before making selinux exceptions permanent!)
cat wkhtml.audit | audit2allow -m wkhtmltopdf > wkhtmltopdf.te
- review the wkhtmltopdf.te file to make sure new rules will be sensible. you will probably see "allow httpd_t self:process execmem" and possibly "allow httpd_t var_t:file read" depending on your setup
cat wkhtml.audit | audit2allow -M wkhtmltopdf
semodule -i wkhtmltopdf.pp
(might take a minute, be patient)
You should now be able to load the pdf-creating page without error. If not, we have likely fixed one problem and arrived at another--might need to repeat steps. Tail to wkhtml.audit2 this time and cat it with the original when making a new module (or else you'll be undoing first fix!):
tail -F ... > wkhtml.audit2
if audit2 is empty, there is a non-selinux problem. otherwise:
cat wkhtml.audit wkhtml.audit2 | audit2allow ...
After some research I solved this. The problem was selinux policies standing in the way. I used the Security Context from /usr/bin/convert and used the chcon command to apply the same security context to /usr/bin/wkhtmltopdf
精彩评论