Unverified Commit 9e1878c7 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(core) Bump PHP min version to PHP7 and remove fallback

Bumped minimum PHP version to 7.0.0 because we use strict typing.
Removed fallback for random_int.

issue #6002
Showing with 1 addition and 41 deletions
+1 -41
...@@ -1931,38 +1931,6 @@ function load_all_classes () ...@@ -1931,38 +1931,6 @@ function load_all_classes ()
} }
} }
if (!function_exists('random_int')) {
// PHP<7, we fallback on openssl_random_pseudo_bytes
function random_int ($min, $max)
{
$range = $max - $min;
if ($range <= 0) {
throw new Exception('Invalid range passed to random_int');
}
$log = log($range, 2);
// length in bytes
$nbBytes = (int) ($log / 8) + 1;
// length in bits
$nbBits = (int) $log + 1;
// set all lower bits to 1
$filter = pow(2, $nbBits) - 1;
if ($filter >= PHP_INT_MAX) {
$filter = PHP_INT_MAX;
}
do {
$randomBytes = openssl_random_pseudo_bytes($nbBytes, $strong);
if (!$strong || ($randomBytes === FALSE)) {
throw new Exception('Failed to get random bytes');
}
$rnd = hexdec(bin2hex($randomBytes));
// discard irrelevant bits
$rnd = $rnd & $filter;
} while ($rnd > $range);
return $min + $rnd;
}
}
function ldap_escape_f ($str, $ignore = '') function ldap_escape_f ($str, $ignore = '')
{ {
return ldap_escape($str, $ignore, LDAP_ESCAPE_FILTER); return ldap_escape($str, $ignore, LDAP_ESCAPE_FILTER);
......
...@@ -73,7 +73,7 @@ define("CONFIGRDN", "cn=config,ou=fusiondirectory,"); /*! Define FusionDirectory ...@@ -73,7 +73,7 @@ define("CONFIGRDN", "cn=config,ou=fusiondirectory,"); /*! Define FusionDirectory
/*! /*!
* \brief Minimum PHP version * \brief Minimum PHP version
*/ */
define('PHP_MIN_VERSION', '5.6.0'); define('PHP_MIN_VERSION', '7.0.0');
/*! /*!
* \brief Toggle crashing on PHP error, used for test suites * \brief Toggle crashing on PHP error, used for test suites
......
...@@ -95,14 +95,6 @@ class setupStepChecks extends setupStep ...@@ -95,14 +95,6 @@ class setupStepChecks extends setupStep
$M = TRUE; $M = TRUE;
$basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ]; $basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ];
/* Pseudo-random check */
$N = _('Checking cryptographically secure pseudo-random integers');
$D = _('You must use PHP>=7 or have openssl module activated so that FusionDirectory can generate cryptographically secure pseudo-random integers.');
$S = _('Please upgrade to PHP7 or activate openssl module.');
$R = (is_callable('random_int') || is_callable('openssl_random_pseudo_bytes'));
$M = TRUE;
$basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ];
/* Check for json support */ /* Check for json support */
$N = msgPool::checkingFor('json'); $N = msgPool::checkingFor('json');
$D = _('FusionDirectory requires this module to encode variables for javascript use.'); $D = _('FusionDirectory requires this module to encode variables for javascript use.');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment