basedir restriction in effect
I using this Yubico authentication PHP class: https://github.com/Yubico/php-yubico. I create php file test.php with this code:
<?php
require_once 'Auth/Yubico.php';
$otp = "ccbbddeertkrctjkkcglfndnlihhnvekchkcctif";
# Generate a new id+key from https://api.yubico.com/get-api-key/
$yubi = new Auth_Yubico('42', 'FOOBAR=');
$auth = $yubi->verify($otp);
if (PEAR::isError($auth)) {
print "<p>Authentication failed: " . $auth->getMessage();
print "<p>Debug output from server: " . $yubi->getLastResponse();
} else {
print "<p>You are authenticated!";
}
?>
And do all instructions in this github library. When I open this script I get:
Warning: require_once(): open_basedir restriction in effect. File(/usr/share/php/Auth/Yubico.php) is not within the allowed path(s): (/var/www/hmci/data:.) in /var/www/hmci/data/www/hmci.ru/php-yubico/test.php on line 2 Warning: require_once(/usr/share/php/Auth/Yubico.php): failed to open stream: Operation not permitted in /var/www/hmci/data/www/hmci.ru/php-yubico/test.php on line 2 Fatal error: require_once(): Failed opening required 'Auth/Yubico.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/hmci/data/www/hmci.ru/php-yubico/test.php on line 2
How to solve this problem?
open_basedir
is a PHP option restricting PHP's access to specific directories.
You have the directory /usr/share/php
in your include path without having access to it. Usually, PHP tries all paths in the include_path
one by one. This means that PHP cannot find the file Auth/Yubico.php
in the current directory, so PHP searches in /usr/share/php
next.
Make sure that the file you want to include is actually there. You can also remove /usr/share/php
from your include path (either by editing the php.ini
file, if you have access to it, otherwhise using the ini_set()
method).
使用明确路径指向要包含的文件会导致PHP跳过导致该错误的目录扫描:
require_once dirname(__FILE__) . '/Auth/Yubico.php';
链接地址: http://www.djcxy.com/p/58120.html
上一篇: 一旦不行,包括意志
下一篇: basedir限制有效