From 9f62ddaf36c89dcfe3514479b444096cb1a964f7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Mar 2018 19:24:34 +0100 Subject: [PATCH 1/3] Fix: missing update of $conf --- htdocs/install/step5.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index df8ec9812c1..ac0c015e0be 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -176,17 +176,20 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $resql=$db->query($sql); - if ($resql) - { - $numrows=$db->num_rows($resql); - if ($numrows == 0) - { - // Define default setup for password encryption - dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities - dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities - } - } + if ($resql) + { + $numrows=$db->num_rows($resql); + if ($numrows == 0) + { + // Define default setup for password encryption + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities + + // Update of $conf + $conf->setValues($db); + } + } // Create user used to create the admin user $createuser=new User($db); From 6e585869c77ae5996d607e1e6552c18f17ba717e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Mar 2018 19:33:08 +0100 Subject: [PATCH 2/3] Fix: better method for avoid lost global --- htdocs/install/step5.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index ac0c015e0be..205162a75c3 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -181,13 +181,17 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $numrows=$db->num_rows($resql); if ($numrows == 0) { + $salt = dol_print_date(dol_now(), 'dayhourlog'); + // Define default setup for password encryption dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "MAIN_SECURITY_SALT", $salt, 'chaine', 0, '', 0); // All entities dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities - // Update of $conf - $conf->setValues($db); + // Update of $conf->global + $conf->global->DATABASE_PWD_ENCRYPTED = 1; + $conf->global->MAIN_SECURITY_SALT = $salt; + $conf->global->MAIN_SECURITY_HASH_ALGO = 'sha1md5'; } } From c0a6ae2195b1077fc68f1a7f52fd1ece09408df8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Mar 2018 18:31:11 +0100 Subject: [PATCH 3/3] Fix: replace with dolibarr_install_syslog --- htdocs/install/step5.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 205162a75c3..2fa8f07c7ba 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -181,17 +181,12 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $numrows=$db->num_rows($resql); if ($numrows == 0) { - $salt = dol_print_date(dol_now(), 'dayhourlog'); - // Define default setup for password encryption - dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SECURITY_SALT", $salt, 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); // Not All entities ?! + dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities - // Update of $conf->global - $conf->global->DATABASE_PWD_ENCRYPTED = 1; - $conf->global->MAIN_SECURITY_SALT = $salt; - $conf->global->MAIN_SECURITY_HASH_ALGO = 'sha1md5'; + dolibarr_install_syslog('step5: DATABASE_PWD_ENCRYPTED = '.$conf->global->DATABASE_PWD_ENCRYPTED.' MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO, LOG_INFO); } }