diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-03-23 12:38:26 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-03-23 12:38:26 +0000 |
| commit | 75b533625a638a34d8b460d5808a57f8be4b7c3f (patch) | |
| tree | f6b09981cc1dc8a9448f92272e31dafedf8288ca /plugins/password/drivers/sql.php | |
| parent | 38987511c153d054441fca8d0a4c01b8c24936dd (diff) | |
- Password: Support dovecotpw encryption
git-svn-id: https://svn.roundcube.net/trunk@3404 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/password/drivers/sql.php')
| -rw-r--r-- | plugins/password/drivers/sql.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/password/drivers/sql.php b/plugins/password/drivers/sql.php index 1e737f233..9337a6754 100644 --- a/plugins/password/drivers/sql.php +++ b/plugins/password/drivers/sql.php @@ -49,6 +49,32 @@ function password_save($curpass, $passwd) } $sql = str_replace('%c', $db->quote(crypt($passwd, CRYPT_MD5 ? '$1$'.$salt.'$' : $salt)), $sql); } + + // dovecotpw + if (strpos($sql, '%D') !== FALSE) { + if (!($dovecotpw = $rcmail->config->get('dovecotpw'))) + $dovecotpw = 'dovecotpw'; + if (!($method = $rcmail->config->get('dovecotmethod'))) + $method = 'CRAM-MD5'; + $tmpfile = tempnam('/tmp', 'rouncdube-'); + $pipe = popen("'$dovecotpw' -s '$method' > '$tmpfile'", "w"); + if (!$pipe) { + unlink($tmpfile); + return PASSWORD_CRYPT_ERROR; + } + else { + fwrite($pipe, $passwd . "\n", 1+strlen($passwd)); usleep(1000); + fwrite($pipe, $passwd . "\n", 1+strlen($passwd)); + pclose($pipe); + $newpass = file_get_contents($tmpfile); + if (!preg_match('/^\{' . $method . '\}/', $newpass)) { + return PASSWORD_CRYPT_ERROR; + } + $newpass = trim(str_replace('{' . $method . '}', '', $newpass)); + unlink($tmpfile); + } + $sql = str_replace('%D', $db->quote($newpass), $sql); + } // hashed passwords if (preg_match('/%[n|q]/', $sql)) { |
