【问题标题】:PHPass error: function name must be a stringPHPass 错误:函数名必须是字符串
【发布时间】:2012-01-03 08:10:53
【问题描述】:

我在使用 PHPass 时遇到此错误:

警告:is_readable():open_basedir 限制生效。 文件(/dev/urandom)不在允许的路径中: (/customers/example.com/example.com/httpd.www:/customers/example.com/example.com/httpd.private:/customers/example.com/example.com/tmp:/customers/example.com /example.com:/var/www/diagnostics:/usr/share/php) 在 /customers/example.com/example.com/httpd.www/example/scripts/PasswordHash.php 在第 51 行致命错误:函数名称必须是字符串 /customers/example.com/example.com/httpd.www/example/register.php 第 82 行

PasswordHash.php (PHPass) 上的第 51-54 行:

    if (is_readable('/dev/urandom') &&
        ($fh = @fopen('/dev/urandom', 'rb'))) {
        $output = fread($fh, $count);
        fclose($fh);

register.php第81-84行(还包括:前两行是require和$hasher):

require('scripts/PasswordHash.php');
$hasher = new PasswordHash(8, false);
$hash = $hasher->HashPassword($pw);
if($strlen($hash) < 20){
    $notice[] = "Error";
}

那么,这个错误是什么意思?

【问题讨论】:

  • 还没有答案吗?没有人知道这个问题的答案吗?

标签: php phpass


【解决方案1】:

open_basedir 限制是 PHP 中的一种安全措施,基本上是将文件系统的访问权限限制在特定目录。这在每个人都应该只能访问自己的文件的共享环境中很有用。默认设置是允许打开所有文件。

在这种情况下,phpass 试图访问/dev/urandom,它不包含在您允许的目录中,从而导致错误。解决方法是更改​​php.iniopen_basedir 的设置以允许/dev/urandom(或允许一切)。

phpass resolves this issue 1.8 版通过抑制错误:

自 1.7 版以来的变化:+2 -2 行:

以“@”为前缀的 is_readable() 以在 open_basedir 时抑制警告 限制生效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-26
    • 2011-02-27
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多