gpt4 book ai didi

php - 我应该启用 exec()、使用 php 安全模式还是更改 php.ini?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:03:46 25 4
gpt4 key购买 nike

我想在我的 VPS 上使用 drush 来完成 drupal 维护任务。但是,根据我安装的 firewall 的自测结果的建议,我不允许来自 php 的 exec() . Drush 显然想要这个特权,我已经看到了三个选项来完成这项工作。

  1. 启用exec()
  2. 使用php安全模式
  3. 将帐户的 php.ini 更改为“disable_functions = system, exec, shell_exec, passthru”

我的帐户是 Linux VPS 上的唯一管理员,我不打算更改它。我是 VPS 及其安全问题的新手。请告知哪个选项提供了更安全的方法。

终端输出:

>exec() has been disabled for security reasons bootstrap.inc:639      [warning]
The following restricted PHP modes have non-empty values: [error]
disable_functions and magic_quotes_gpc. This configuration is
incompatible with drush. Please check your configuration settings in
/usr/local/lib/php.ini or in your drush.ini file; see
examples/example.drush.ini for details.
exec() has been disabled for security reasons exec.inc:150 [warning]
exec() has been disabled for security reasons exec.inc:150 [warning]
exec() has been disabled for security reasons exec.inc:150 [warning]
unlink(/home/site1/drush/lib/package.xml): No such file or [warning]
directory drush.inc:798
The drush command 'status' could not be found. Run `drush [error]
cache-clear drush` to clear the commandfile cache if you have
installed new extensions.
Drush needs a copy of the PEAR Console_Table library in order to [error]
function, and the attempt to download this file automatically failed.
To continue you will need to download the 1.1.3 package from
http://pear.php.net/package/Console_Table, extract it into
/home/site1/drush/lib directory, such that Table.php exists at
/home/site1/drush/lib/Console_Table-1.1.3/Table.php.

最佳答案

PHP 有许多内置或可通过扩展使用的功能。但是,在某些情况下,库或应用程序被设计为调用外部程序。如果没有 exec,这些包将无法正常工作,因此您可以选择允许使用 exec 或不使用相关包。

忘记 safe_mode:它已被弃用并且即将被完全删除。

exec 的使用本身并不是不安全的——当程序没有正确清理输入时,或者代码的编写方式允许人们欺骗代码以非预期的方式调用 exec代表问题。由于 Drush 是一个管理实用程序,您已经期望它只能由受信任的用户运行。我的意思是——它包括让您输入任何您想要的 php 代码并对其进行 evals()!!!

关于php - 我应该启用 exec()、使用 php 安全模式还是更改 php.ini?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16406417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com