Use preg_match_all to get redis password from args

This should fix the issue where preg_split was being used and would cause an error if the redis args variable didn't contain the --requirepass string and the WebGUI wouldn't load as a result.
This commit is contained in:
Eric Pfeiffer 2021-10-12 09:42:04 -05:00
parent f6bbdc72fd
commit 5e90a3a35d

@ -132,10 +132,14 @@ function loadClass($class) {
$REDIS_ROOT_PASSWORD = '';
$_REDIS_ARGS = loadClass('Helper')->getEnv('REDIS_ARGS');
$_REDIS_PASS = preg_split("/--requirepass\s+/", $_REDIS_ARGS);
if (is_array($_REDIS_PASS) && count($_REDIS_PASS)) {
$_REDIS_PASS = [];
preg_match_all('/--requirepass\s+([^\s]*)/', $_REDIS_ARGS, $_REDIS_PASS);
if (! empty($_REDIS_PASS[1])) {
// In case the option is specified multiple times, use the last effective one.
$_REDIS_PASS = $_REDIS_PASS[count($_REDIS_PASS)-1];
$_REDIS_PASS = end($_REDIS_PASS[1]);
if (strlen($_REDIS_PASS) > 0) {
$REDIS_ROOT_PASSWORD = $_REDIS_PASS;
}