summaryrefslogtreecommitdiff
path: root/plugins/password
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/password')
-rw-r--r--plugins/password/config.inc.php.dist4
-rw-r--r--plugins/password/drivers/sql.php36
-rw-r--r--plugins/password/package.xml25
-rw-r--r--plugins/password/password.php6
4 files changed, 57 insertions, 14 deletions
diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist
index 94af6d776..313e47fda 100644
--- a/plugins/password/config.inc.php.dist
+++ b/plugins/password/config.inc.php.dist
@@ -47,6 +47,10 @@ $rcmail_config['password_db_dsn'] = '';
// Default: "SELECT update_passwd(%c, %u)"
$rcmail_config['password_query'] = 'SELECT update_passwd(%c, %u)';
+// By default domains in variables are using unicode.
+// Enable this option to use punycoded names
+$rcmail_config['password_idn_ascii'] = false;
+
// Path for dovecotpw (if not in $PATH)
// $rcmail_config['password_dovecotpw'] = '/usr/local/sbin/dovecotpw';
diff --git a/plugins/password/drivers/sql.php b/plugins/password/drivers/sql.php
index 836a58a44..06a6b75ff 100644
--- a/plugins/password/drivers/sql.php
+++ b/plugins/password/drivers/sql.php
@@ -37,16 +37,21 @@ function password_save($curpass, $passwd)
// crypted password
if (strpos($sql, '%c') !== FALSE) {
$salt = '';
- if (CRYPT_MD5) {
- $len = rand(3, CRYPT_SALT_LENGTH);
+ if (CRYPT_MD5) {
+ // Always use eight salt characters for MD5 (#1488136)
+ $len = 8;
} else if (CRYPT_STD_DES) {
$len = 2;
} else {
return PASSWORD_CRYPT_ERROR;
}
+
+ //Restrict the character set used as salt (#1488136)
+ $seedchars = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
for ($i = 0; $i < $len ; $i++) {
- $salt .= chr(rand(ord('.'), ord('z')));
+ $salt .= $seedchars[rand(0, 63)];
}
+
$sql = str_replace('%c', $db->quote(crypt($passwd, CRYPT_MD5 ? '$1$'.$salt.'$' : $salt)), $sql);
}
@@ -125,11 +130,28 @@ function password_save($curpass, $passwd)
}
}
+ $local_part = $rcmail->user->get_username('local');
+ $domain_part = $rcmail->user->get_username('domain');
+ $username = $_SESSION['username'];
+ $host = $_SESSION['imap_host'];
+
+ // convert domains to/from punnycode
+ if ($rcmail->config->get('password_idn_ascii')) {
+ $domain_part = rcube_idn_to_ascii($domain_part);
+ $username = rcube_idn_to_ascii($username);
+ $host = rcube_idn_to_ascii($host);
+ }
+ else {
+ $domain_part = rcube_idn_to_utf8($domain_part);
+ $username = rcube_idn_to_utf8($username);
+ $host = rcube_idn_to_utf8($host);
+ }
+
// at least we should always have the local part
- $sql = str_replace('%l', $db->quote($rcmail->user->get_username('local'), 'text'), $sql);
- $sql = str_replace('%d', $db->quote($rcmail->user->get_username('domain'), 'text'), $sql);
- $sql = str_replace('%u', $db->quote($_SESSION['username'],'text'), $sql);
- $sql = str_replace('%h', $db->quote($_SESSION['imap_host'],'text'), $sql);
+ $sql = str_replace('%l', $db->quote($local_part, 'text'), $sql);
+ $sql = str_replace('%d', $db->quote($domain_part, 'text'), $sql);
+ $sql = str_replace('%u', $db->quote($username, 'text'), $sql);
+ $sql = str_replace('%h', $db->quote($host, 'text'), $sql);
$res = $db->query($sql, $sql_vars);
diff --git a/plugins/password/package.xml b/plugins/password/package.xml
index 69cef072f..d3f4bea9b 100644
--- a/plugins/password/package.xml
+++ b/plugins/password/package.xml
@@ -27,10 +27,7 @@
</stability>
<license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license>
<notes>
-- When old and new passwords are the same, do nothing, return success (#1487823)
-- Fixed Samba password hashing in 'ldap' driver
-- Added 'password_change' hook for plugin actions after successful password change
-- Fixed bug where 'doveadm pw' command was used as dovecotpw utility
+- Added option to use punycode or unicode for domain names (#1488103)
</notes>
<contents>
<dir baseinstalldir="/" name="/">
@@ -264,5 +261,25 @@
- Virtualmin driver: Add option for setting username format (#1487781)
</notes>
</release>
+ <release>
+ <date>2011-10-26</date>
+ <time>12:00</time>
+ <version>
+ <release>2.3</release>
+ <api>1.6</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license>
+ <notes>
+- When old and new passwords are the same, do nothing, return success (#1487823)
+- Fixed Samba password hashing in 'ldap' driver
+- Added 'password_change' hook for plugin actions after successful password change
+- Fixed bug where 'doveadm pw' command was used as dovecotpw utility
+- Improve generated crypt() passwords (#1488136)
+ </notes>
+ </release>
</changelog>
</package>
diff --git a/plugins/password/password.php b/plugins/password/password.php
index b1c7863fc..06e3448f0 100644
--- a/plugins/password/password.php
+++ b/plugins/password/password.php
@@ -223,7 +223,7 @@ class password extends rcube_plugin
{
$config = rcmail::get_instance()->config;
$driver = $this->home.'/drivers/'.$config->get('password_driver', 'sql').'.php';
-
+
if (!is_readable($driver)) {
raise_error(array(
'code' => 600,
@@ -233,7 +233,7 @@ class password extends rcube_plugin
), true, false);
return $this->gettext('internalerror');
}
-
+
include($driver);
if (!function_exists('password_save')) {
@@ -270,5 +270,5 @@ class password extends rcube_plugin
}
return $reason;
- }
+ }
}