From b5d19264dee62052fa98bfb73ec499eeef3c1260 Mon Sep 17 00:00:00 2001 From: ulin-evgeny Date: Sun, 20 Jun 2021 05:07:19 +0300 Subject: [PATCH 1/3] Fixed typos --- docs/getting-started/change-container-versions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting-started/change-container-versions.rst b/docs/getting-started/change-container-versions.rst index 2dc71f59..3ed27f09 100644 --- a/docs/getting-started/change-container-versions.rst +++ b/docs/getting-started/change-container-versions.rst @@ -128,7 +128,7 @@ Now save the file and you can start the Devilbox again. # Navigate to the Devilbox directory host> cd path/to/devilbox - # Stop all container + # Start all container host> docker-compose up php httpd bind .. seealso:: :ref:`start_the_devilbox` @@ -193,7 +193,7 @@ Now save the file and you can start the Devilbox again. # Navigate to the Devilbox directory host> cd path/to/devilbox - # Stop all container + # Start all container host> docker-compose up php httpd bind .. seealso:: :ref:`start_the_devilbox` From 5e90a3a35d82a8403e94a0ebc94d8057f3e50c0e Mon Sep 17 00:00:00 2001 From: Eric Pfeiffer Date: Tue, 12 Oct 2021 09:42:04 -0500 Subject: [PATCH 2/3] 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. --- .devilbox/www/config.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.devilbox/www/config.php b/.devilbox/www/config.php index 38117d87..e792f90c 100644 --- a/.devilbox/www/config.php +++ b/.devilbox/www/config.php @@ -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; } From 56555e87a5db40f39ba4e96c850eac9b3cae1328 Mon Sep 17 00:00:00 2001 From: Eric Pfeiffer Date: Tue, 12 Oct 2021 10:44:44 -0500 Subject: [PATCH 3/3] Adjust redis args regex to allow optional quotes. --- .devilbox/www/config.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.devilbox/www/config.php b/.devilbox/www/config.php index e792f90c..b0d87848 100644 --- a/.devilbox/www/config.php +++ b/.devilbox/www/config.php @@ -127,18 +127,26 @@ function loadClass($class) { break; case 'Redis': - // Check if redis is using a password $REDIS_ROOT_PASSWORD = ''; $_REDIS_ARGS = loadClass('Helper')->getEnv('REDIS_ARGS'); + /* + * This pattern will match optional quoted string, 'my password' or "my password" + * or if there aren't any quotes, it will match up until the next space. + */ $_REDIS_PASS = []; - preg_match_all('/--requirepass\s+([^\s]*)/', $_REDIS_ARGS, $_REDIS_PASS); + preg_match_all('/--requirepass\s+("|\')?(?(1)(.*)|([^\s]*))(?(1)\1|)/', $_REDIS_ARGS, $_REDIS_PASS, PREG_SET_ORDER); - if (! empty($_REDIS_PASS[1])) { - // In case the option is specified multiple times, use the last effective one. - $_REDIS_PASS = end($_REDIS_PASS[1]); + if (! empty($_REDIS_PASS)) { + /* + * In case the option is specified multiple times, use the last effective one. + * + * preg_match_all returns a multi-dimensional array, the first level array is in order of which was matched first, + * and the password string is either matched in group 2 or group 3 which is always the end of the sub-array. + */ + $_REDIS_PASS = end(end($_REDIS_PASS)); if (strlen($_REDIS_PASS) > 0) { $REDIS_ROOT_PASSWORD = $_REDIS_PASS;