mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
Fix regression on pass encryption in conf
This commit is contained in:
@@ -444,7 +444,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td colspan="3">'.$langs->trans("MainDbPasswordFileConfEncrypted").'</td>';
|
print '<td colspan="3">'.$langs->trans("MainDbPasswordFileConfEncrypted").'</td>';
|
||||||
print '<td align="center" width="60">';
|
print '<td align="center" width="60">';
|
||||||
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || preg_match('/dolcrypt:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
||||||
print img_picto($langs->trans("Active"), 'tick');
|
print img_picto($langs->trans("Active"), 'tick');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -527,7 +527,7 @@ print '<br>';
|
|||||||
/*
|
/*
|
||||||
$usepassinconfencrypted = 0;
|
$usepassinconfencrypted = 0;
|
||||||
global $dolibarr_main_db_pass, $dolibarr_main_db_encrypted_pass;
|
global $dolibarr_main_db_pass, $dolibarr_main_db_encrypted_pass;
|
||||||
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || preg_match('/dolcrypt:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
||||||
$usepassinconfencrypted = 1;
|
$usepassinconfencrypted = 1;
|
||||||
}
|
}
|
||||||
print '<strong>'.$langs->trans("MainDbPasswordFileConfEncrypted").'</strong>: ';
|
print '<strong>'.$langs->trans("MainDbPasswordFileConfEncrypted").'</strong>: ';
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ function isDolTms($timestamp)
|
|||||||
* @param string $type Type of database (mysql, pgsql...)
|
* @param string $type Type of database (mysql, pgsql...)
|
||||||
* @param string $host Address of database server
|
* @param string $host Address of database server
|
||||||
* @param string $user Authorized username
|
* @param string $user Authorized username
|
||||||
* @param string $pass Password
|
* @param string $pass Password (clear)
|
||||||
* @param string $name Name of database
|
* @param string $name Name of database
|
||||||
* @param int $port Port of database server
|
* @param int $port Port of database server
|
||||||
* @return DoliDB A DoliDB instance
|
* @return DoliDB A DoliDB instance
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ function dolEncrypt($chain, $key = '', $ciphering = '', $forceseed = '')
|
|||||||
* Note: If a backup is restored onto another instance with a different $conf->file->instance_unique_id, then decoded value will differ.
|
* Note: If a backup is restored onto another instance with a different $conf->file->instance_unique_id, then decoded value will differ.
|
||||||
*
|
*
|
||||||
* @param string $chain string to decode
|
* @param string $chain string to decode
|
||||||
* @param string $key If '', we use $conf->file->instance_unique_id
|
* @param string $key If '', we use $conf->file->dolcrypt_key else $conf->file->instance_unique_id
|
||||||
* @return string encoded string
|
* @return string encoded string
|
||||||
* @since v17
|
* @since v17
|
||||||
* @see dolEncrypt(), dol_hash()
|
* @see dolEncrypt(), dol_hash()
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ if (!file_exists($conffile)) {
|
|||||||
|
|
||||||
// Requirements met/all ok: display the next step button
|
// Requirements met/all ok: display the next step button
|
||||||
if ($checksok) {
|
if ($checksok) {
|
||||||
$ok = 0;
|
$ok = false;
|
||||||
|
|
||||||
// Try to create db connection
|
// Try to create db connection
|
||||||
if (file_exists($conffile)) {
|
if (file_exists($conffile)) {
|
||||||
@@ -358,11 +358,13 @@ if (!file_exists($conffile)) {
|
|||||||
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
|
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
|
||||||
|
|
||||||
// If password is encoded, we decode it
|
// If password is encoded, we decode it
|
||||||
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || preg_match('/dolcrypt:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
||||||
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
|
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
|
||||||
if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
|
if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
|
||||||
$dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially encrypted
|
$dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially encrypted
|
||||||
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
|
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
|
||||||
|
} elseif (preg_match('/dolcrypt:/i', $dolibarr_main_db_pass)) {
|
||||||
|
$dolibarr_main_db_pass = dolDecrypt($dolibarr_main_db_pass);
|
||||||
} else {
|
} else {
|
||||||
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
|
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
|
||||||
}
|
}
|
||||||
@@ -375,6 +377,7 @@ if (!file_exists($conffile)) {
|
|||||||
$conf->db->name = $dolibarr_main_db_name;
|
$conf->db->name = $dolibarr_main_db_name;
|
||||||
$conf->db->user = $dolibarr_main_db_user;
|
$conf->db->user = $dolibarr_main_db_user;
|
||||||
$conf->db->pass = $dolibarr_main_db_pass;
|
$conf->db->pass = $dolibarr_main_db_pass;
|
||||||
|
|
||||||
$db = getDoliDBInstance($conf->db->type, $conf->db->host, (string) $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
|
$db = getDoliDBInstance($conf->db->type, $conf->db->host, (string) $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
|
||||||
if ($db->connected && $db->database_selected) {
|
if ($db->connected && $db->database_selected) {
|
||||||
$ok = true;
|
$ok = true;
|
||||||
|
|||||||
@@ -140,12 +140,14 @@ print '<table cellspacing="0" cellpadding="1" class="centpercent">';
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// If password is encoded, we decode it
|
// If password is encoded, we decode it
|
||||||
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || preg_match('/dolcrypt:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
||||||
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
|
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
|
||||||
if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
|
if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
|
||||||
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
|
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
|
||||||
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
|
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
|
||||||
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially encrypted
|
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially encrypted
|
||||||
|
} elseif (preg_match('/dolcrypt:/i', $dolibarr_main_db_pass)) {
|
||||||
|
$dolibarr_main_db_pass = dolDecrypt($dolibarr_main_db_pass);
|
||||||
} else {
|
} else {
|
||||||
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
|
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user