2014-03-04 34 views
0

我使用nginx和php-fpm作爲默認webserver而不使用apache。 因此,爲了最好的安全性,每個主機都有自己的php-fpm池。我沒有想爲所有用戶啓用,但我需要使用此功能的一些主機(1或3主機,不再)。只對某些主機啓用shell_exec

shell_exec在php.ini中被關閉。 我嘗試啓用網站中的php-fpm的游泳池了shell_exec,但它不工作:

php_admin_value[shell_exec] = on 

回答

0

您可以創建白名單IP主機,因爲這:

$whitelist = array('127.0.0.1', '192.168.0.1', 'whateverIPyouAuth'); 
if(in_array($_SERVER['REMOTE_ADDR'], $whitelist)){ 
    //shell_exec call here 
} 
0

您可以通過suhosin.executor.func.blacklist

做到這一點

1)註釋disable_function in php.ini
2)在下面加上這一行(列出所有要被列入黑名單的函數,同時作爲disable_function)

suhosin.executor.func.blacklist = exec, passthru, shell_exec, system, proc_open, popen, apache_child_terminate, apache_setenv, define_syslog_variables, pcntl_exec, openlog, posix_getpwuid, posix_kill, posix_setpgid, posix_setsid, posix_setuid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, syslog, curl_exec, curl_multi_exec, php_uname, phpinfo

3)在使用行虛擬主機部分:

php_admin_value suhosin.executor.func.blacklist ".." 

因此可以重新定義黑色列出的函數對於該特定虛擬主機。

在你的情況下,除shell_exec之外的所有功能。

這將是php_admin_value suhosin.executor.func.blacklist "passthru, shell_exec, system, proc_open, popen, apache_child_terminate, apache_setenv, define_syslog_variables, pcntl_exec, openlog, posix_getpwuid, posix_kill, posix_setpgid, posix_setsid, posix_setuid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, syslog, curl_exec, curl_multi_exec, php_uname, phpinfo"

Reference

0

別的東西要考慮的是在主php.ini文件以禁用disable_function

然後設置disable_function每個FPM池:(例如)

php_admin_value[disable_functions] = exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source 

如果你有一個特定的FPM池,你需要使用一個或一個以上的這些功能,只是從池配置中刪除。

相關問題