Use RX_WINDOWS constant in core and file module

This commit is contained in:
Kijin Sung 2020-02-14 16:16:33 +09:00
parent 76c68c63e0
commit 4ac0a6bf66
4 changed files with 7 additions and 8 deletions

View file

@ -198,20 +198,19 @@ class Security
// Use other good sources of entropy if random_bytes() is not available.
if ($entropy === false)
{
$is_windows = (defined('\PHP_OS') && strtoupper(substr(\PHP_OS, 0, 3)) === 'WIN');
if(function_exists('openssl_random_pseudo_bytes'))
{
$entropy = openssl_random_pseudo_bytes($entropy_capped_bytes);
}
elseif(function_exists('mcrypt_create_iv') && !$is_windows)
elseif(function_exists('mcrypt_create_iv') && !\RX_WINDOWS)
{
$entropy = mcrypt_create_iv($entropy_capped_bytes, \MCRYPT_DEV_URANDOM);
}
elseif(function_exists('mcrypt_create_iv') && $is_windows)
elseif(function_exists('mcrypt_create_iv') && \RX_WINDOWS)
{
$entropy = mcrypt_create_iv($entropy_capped_bytes, \MCRYPT_RAND);
}
elseif(!$is_windows && @is_readable('/dev/urandom'))
elseif(!\RX_WINDOWS && @is_readable('/dev/urandom'))
{
$fp = fopen('/dev/urandom', 'rb');
if (function_exists('stream_set_read_buffer')) // This function does not exist in HHVM.

View file

@ -152,7 +152,7 @@ class Storage
public static function isExecutable($path)
{
$path = rtrim($path, '/\\');
if (function_exists('exec') && !starts_with('win', \PHP_OS, false))
if (function_exists('exec') && !\RX_WINDOWS)
{
@exec('/bin/ls -l ' . escapeshellarg($path), $output, $return_var);
if ($return_var === 0)
@ -880,7 +880,7 @@ class Storage
public static function recommendUmask()
{
// On Windows, set the umask to 0000.
if (strncasecmp(\PHP_OS, 'Win', 3) === 0)
if (\RX_WINDOWS)
{
return '0000';
}