0

在我的 CI 控制器上使用 Phpass 0.3 时出现此错误

消息:is_readable() [function.is-readable]:open_basedir 限制生效。文件(/dev/urandom)不在允许的路径中:(/home/:/usr/lib/php:/usr/local/lib/php:/tmp)

文件名:phpass-0.3/PasswordHash.php

有人能告诉我问题是什么吗?

4

1 回答 1

0

open_basedir is a directive defined in your php.ini file.

It is set to the lowest directory that you are allowed to access from a PHP script, usually your webroot.

Trying to access a file/directory further down the tree such as in /dev/ will then be dissallowed and you will get the message you have.

You will have to edit your php.ini and set open_basedir to your server root, which is generally a bad thing security-wise as if anyone managed to inject malicious code into your script they would have access to the entire system.

It would be safer to exececute a script (Perl, Python, etc) that lives in your web folder to read /dev/urandom if you really need to.

$output = `/scripts/get_urandom.pl`;
// Process output

Version 1.8 of phpass resolves this issue by suppressing the error:

Changes since revision 1.7: +2 -2 lines:

Prefixed is_readable() with "@" to suppress warning when open_basedir restriction is in effect.

于 2012-03-22T08:22:59.230 回答