summaryrefslogtreecommitdiff
path: root/plugins/password/drivers/sql.php
diff options
context:
space:
mode:
authordefa <defa@so36.net>2012-08-28 16:11:49 +0200
committerdefa <defa@so36.net>2012-08-28 16:11:49 +0200
commit5c603c4032bf71792e7accd80e2b7d0e78d445f8 (patch)
tree78076c5616c078e35aaf55b45d1cf60edbfd158f /plugins/password/drivers/sql.php
parent5e9b40a0d5d6c0d0205c761cee0991417cc78451 (diff)
fixed the patch after some testing, works productive
Diffstat (limited to 'plugins/password/drivers/sql.php')
-rw-r--r--plugins/password/drivers/sql.php31
1 files changed, 18 insertions, 13 deletions
diff --git a/plugins/password/drivers/sql.php b/plugins/password/drivers/sql.php
index ec04048f6..8bdcabf83 100644
--- a/plugins/password/drivers/sql.php
+++ b/plugins/password/drivers/sql.php
@@ -41,29 +41,34 @@ class rcube_sql_password
if (strpos($sql, '%c') !== FALSE) {
$salt = '';
- if (!($crypt_digest = $rcmail->config->get('password_crypt_digest')))
- $crypt_digest = CRYPT_MD5;
+ if (!($crypt_hash = $rcmail->config->get('password_crypt_hash')))
+ {
+ if (CRYPT_MD5)
+ $crypt_hash = 'md5';
+ else if (CRYPT_STD_DES)
+ $crypt_hash = 'des';
+ }
- switch ($crypt_digest)
+ switch ($crypt_hash)
{
- case CRYPT_MD5:
+ case 'md5':
$len = 8;
- $salt_digest = '$1$';
+ $salt_hashindicator = '$1$';
break;
- case CRYPT_STD_DES:
+ case 'des':
$len = 2;
break;
- case CRYPT_BLOWFISH:
+ case 'blowfish':
$len = 22;
- $salt_digest = '$2a$';
+ $salt_hashindicator = '$2a$';
break;
- case CRYPT_SHA256:
+ case 'sha256':
$len = 16;
- $salt_digest = '$5$';
+ $salt_hashindicator = '$5$';
break;
- case CRYPT_SHA512:
+ case 'sha512':
$len = 16;
- $salt_digest = '$6$';
+ $salt_hashindicator = '$6$';
break;
default:
return PASSWORD_CRYPT_ERROR;
@@ -75,7 +80,7 @@ class rcube_sql_password
$salt .= $seedchars[rand(0, 63)];
}
- $sql = str_replace('%c', $db->quote(crypt($passwd, $salt_digest ? $salt_digest .$salt.'$' : $salt)), $sql);
+ $sql = str_replace('%c', $db->quote(crypt($passwd, $salt_hashindicator ? $salt_hashindicator .$salt.'$' : $salt)), $sql);
}
// dovecotpw