From 8f35cdb04e263fbcad5d3c7de77d7e48acb26946 Mon Sep 17 00:00:00 2001 From: Marius Burkard <m.burkard@pixcept.de> Date: Mon, 26 Aug 2019 14:03:35 +0200 Subject: [PATCH] - prevent running update when mysql cannot be used from command line with credentials from mysql_clientdb.conf --- install/update.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/install/update.php b/install/update.php index 42ddd625f5..11570aa666 100644 --- a/install/update.php +++ b/install/update.php @@ -293,6 +293,22 @@ if($conf['mysql']['master_slave_setup'] == 'y') { */ checkDbHealth(); + +/* + * Check command line mysql login + */ +if( !empty($conf["mysql"]["admin_password"]) ) { + $cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." -P ".escapeshellarg($conf['mysql']['port'])." -D ".escapeshellarg($conf['mysql']['database'])." -e ". escapeshellarg('SHOW DATABASES'); +} else { + $cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -P ".escapeshellarg($conf['mysql']['port'])." -D ".escapeshellarg($conf['mysql']['database'])." -e ". escapeshellarg('SHOW DATABASES'); +} +$retval = 0; +$retout = array(); +exec($cmd, $retout, $retval); +if($retval != 0) { + die("Unable to call mysql command line with credentials from mysql_clientdb.conf\n"); +} + /* * dump the new Database and reconfigure the server.ini */ -- GitLab