Skip to content
Snippets Groups Projects
Commit 20ed76e4 authored by Jared Hancock's avatar Jared Hancock
Browse files

Squelch errors from open_basedir restrictions

When reading data from /dev/urandom and friends on *nix systems with the
open_basedir setting enforced.
parent c80be0b6
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ class PasswordHash { ...@@ -48,7 +48,7 @@ class PasswordHash {
function get_random_bytes($count) function get_random_bytes($count)
{ {
$output = ''; $output = '';
if (is_readable('/dev/urandom') && if (@is_readable('/dev/urandom') &&
($fh = @fopen('/dev/urandom', 'rb'))) { ($fh = @fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count); $output = fread($fh, $count);
fclose($fh); fclose($fh);
......
...@@ -178,10 +178,10 @@ class Auth_SASL_DigestMD5 extends Auth_SASL_Common ...@@ -178,10 +178,10 @@ class Auth_SASL_DigestMD5 extends Auth_SASL_Common
*/ */
function _getCnonce() function _getCnonce()
{ {
if (file_exists('/dev/urandom') && $fd = @fopen('/dev/urandom', 'r')) { if (@file_exists('/dev/urandom') && $fd = @fopen('/dev/urandom', 'r')) {
return base64_encode(fread($fd, 32)); return base64_encode(fread($fd, 32));
} elseif (file_exists('/dev/random') && $fd = @fopen('/dev/random', 'r')) { } elseif (@file_exists('/dev/random') && $fd = @fopen('/dev/random', 'r')) {
return base64_encode(fread($fd, 32)); return base64_encode(fread($fd, 32));
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment