PHPass错误:函数名必须是字符串

时间:2011-11-21 20:53:09

标签: php phpass

我在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)   在/comersomers/example.com/example.com/httpd.www/example/scripts/PasswordHash.php   第51行致命错误:函数名必须是字符串   第82行/customers/example.com/example.com/httpd.www/example/register.php

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";
}

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

1 个答案:

答案 0 :(得分:3)

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

在这种情况下,phpass正在尝试访问/dev/urandom,它不包含在您允许的目录中,从而导致错误。修复方法是更改​​open_basedirphp.ini的设置以允许/dev/urandom(或允许所有内容)。

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

  

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

     

使用“@”作为前缀的is_readable()以在open_basedir时禁止警告   限制有效。