I am now writing a small script to execute gpg
from PHP (FPM)
but somehow PHP does not allow me to execute any binary/shell script and return exit code 127 . But if I execute those in php-cli it works just fine.
PHP Configuration:
PHP: php-fpm
Webserver: nginx
chroot /user/home/php-root
chdir /
Safemode Off
Disable exec*
?: No
I tried the ff:
exec('whoami')
or ls
all return NULL and gives exitcode 127 shell_exec()
all commands return NULL system()
also return NULL 2>&1
return NULL gpg
, whoami
in chrooted-root/bin
chrooted-root/bin
As far as I tried, nothing works.
Are there anyone able to make PHP-FPM execute shell/binary in chrooted environment?
Thank you very much!
I found that copying /bin/sh
to chrooted-root/bin
worked. Also needed dependencies:
$ ldd /bin/sh
linux-vdso.so.1 (0x00007ffc098c6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2e92d52000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2e9331e000)
So I had to copy /lib/x86_64-linux-gnu/libc.so.6
and /lib64/ld-linux-x86-64.so.2
under my chrooted directory.
I'm not sure if it's /bin/sh
under all distros, might be /bin/bash
or something.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.