0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 19:22:14 +02:00

get legacy test case to pass

This commit is contained in:
David Goodwin 2021-09-29 18:32:46 +01:00
parent 0b9b7db917
commit 309b4a84aa
2 changed files with 16 additions and 5 deletions

View File

@ -1299,24 +1299,35 @@ function pacrypt($pw, $pw_db = "")
$mechanism = $CONF['encrypt'] ?? 'CRYPT';
if ($mechanism == 'php_crypt') {
$mechanism = strtoupper($mechanism);
$crypts = ['PHP_CRYPT', 'MD5CRYPT', 'PHP_CRYPT:DES', 'PHP_CRYPT:MD5', 'PHP_CRYPT:SHA256'];
if (in_array($mechanism, $crypts)) {
$mechanism = 'CRYPT';
}
if ($mechanism == 'php_crypt:SHA512') {
if ($mechanism == 'PHP_CRYPT:SHA512') {
$mechanism = 'SHA512-CRYPT';
}
if(preg_match('/^dovecot:(.*)$/i', $mechanism, $matches)) {
if($mechanism == 'SHA512.B64') {
$mechanism = 'SHA512-CRYPT.B64';
}
if(preg_match('/^DOVECOT:(.*)$/i', $mechanism, $matches)) {
$mechanism = strtoupper($matches[1]);
}
if(preg_match('/^courier:(.*)$/i', $mechanism, $matches)) {
if(preg_match('/^COURIER:(.*)$/i', $mechanism, $matches)) {
$mechanism = strtoupper($mechanism);
}
if (empty($pw_db)) {
$pw_db = null;
}
if($mechanism == 'AUTHLIB') {
return _pacrypt_authlib($pw, $pw_db);
}
$hasher = new \PostfixAdmin\PasswordHashing\Crypt($mechanism);
return $hasher->crypt($pw, $pw_db);
}

View File

@ -313,7 +313,7 @@ EOF;
'cleartext' => 'test123',
'mysql_encrypt' => '$6$$KMCDSuWNoVgNrK5P1zDS12ZZt.LV4z9v9NtD0AG0T5Rv/n0wWVvZmHMSKKZQciP7lrqrlbrBrBd4lhBSGy1BU0',
'authlib' => '{md5raw}cc03e747a6afbbcbf8be7668acfebee5',
'php_crypt:SHA512' => '$6$IeqpXtDIXF09ADdc$IsE.SSK3zuwtS9fdWZ0oVxXQjPDj834xqxTiv3Qfidq3AbAjPb0DNyI28JyzmDVlbfC9uSfNxD9RUyeO1.7FV/',
'php_crypt:SHA512' => '{SHA512-CRYPT}$6$IeqpXtDIXF09ADdc$IsE.SSK3zuwtS9fdWZ0oVxXQjPDj834xqxTiv3Qfidq3AbAjPb0DNyI28JyzmDVlbfC9uSfNxD9RUyeO1.7FV/',
'php_crypt:DES' => 'VXAXutUnpVYg6',
'php_crypt:MD5' => '$1$rGTbP.KE$wimpECWs/wQa7rnSwCmHU.',
'php_crypt:SHA256' => '$5$UaZs6ZuaLkVPx3bM$4JwAqdphXVutFYw7COgAkp/vj09S1DfjIftxtjqDrr/',