From 20ed76e465b83fe01836598cce719dd74872122d Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 13 Aug 2012 15:45:16 -0500 Subject: [PATCH] Squelch errors from open_basedir restrictions When reading data from /dev/urandom and friends on *nix systems with the open_basedir setting enforced. --- include/PasswordHash.php | 2 +- include/pear/Auth/SASL/DigestMD5.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/PasswordHash.php b/include/PasswordHash.php index a30f41137..b5b8efcad 100644 --- a/include/PasswordHash.php +++ b/include/PasswordHash.php @@ -48,7 +48,7 @@ class PasswordHash { function get_random_bytes($count) { $output = ''; - if (is_readable('/dev/urandom') && + if (@is_readable('/dev/urandom') && ($fh = @fopen('/dev/urandom', 'rb'))) { $output = fread($fh, $count); fclose($fh); diff --git a/include/pear/Auth/SASL/DigestMD5.php b/include/pear/Auth/SASL/DigestMD5.php index 4534e500b..e97e15dab 100644 --- a/include/pear/Auth/SASL/DigestMD5.php +++ b/include/pear/Auth/SASL/DigestMD5.php @@ -178,10 +178,10 @@ class Auth_SASL_DigestMD5 extends Auth_SASL_Common */ 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)); - } 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)); } else { -- GitLab