Saturday, 19 November 2016
require once - PHP error: open_basedir restriction in effect
Answer
Answer
I using this Yubico authentication PHP class: https://github.com/Yubico/php-yubico. I create php file test.php with this code:
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 "Authentication failed: " . $auth->getMessage();
print "
Debug output from server: " . $yubi->getLastResponse();
} else {
print "
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?
Answer
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).
c++ - Does curly brackets matter for empty constructor?
Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...
-
In K-PAX , there are two possible explanations: Prot is crazy. He is truly an alien. There are facts that indicate 1, but also 2. Examples: ...
-
I found this excellent tutorial on regular expressions and while I intuitively understand what "greedy", "reluctant" an...
-
Why this works? I mean, accessing the private variable. class Test { private $q = 0; public function __construct() { $this-...
No comments:
Post a Comment