diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-02-15 12:26:26 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-02-15 12:26:26 +0000 |
| commit | 5862e0d7c6edd90c2523ddde5705e7486f6c20e9 (patch) | |
| tree | 145aff67180e75a8dbdd082d7a777b2b5b2b4904 /plugins/password | |
| parent | a5a38566263ca49371ad9fc417d3ee5ba0f722ab (diff) | |
- Virtualmin driver: Add option for setting username format (#1487781)
git-svn-id: https://svn.roundcube.net/trunk@4546 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/password')
| -rw-r--r-- | plugins/password/README | 2 | ||||
| -rw-r--r-- | plugins/password/config.inc.php.dist | 13 | ||||
| -rw-r--r-- | plugins/password/drivers/virtualmin.php | 43 | ||||
| -rw-r--r-- | plugins/password/package.xml | 7 |
4 files changed, 56 insertions, 9 deletions
diff --git a/plugins/password/README b/plugins/password/README index a31a0e076..81e4f1ead 100644 --- a/plugins/password/README +++ b/plugins/password/README @@ -201,7 +201,7 @@ As in sasl driver this one allows to change password using shell utility called "virtualmin". See drivers/chgvirtualminpasswd.c for - installation instructions. + installation instructions. See also config.inc.php.dist file. 2.9. hMailServer (hmail) diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist index 1140a91da..ddf881217 100644 --- a/plugins/password/config.inc.php.dist +++ b/plugins/password/config.inc.php.dist @@ -285,3 +285,16 @@ $rcmail_config['hmailserver_server'] = array( 'Password' => 'password' // windows user password ); + +// Virtualmin Driver options +// ------------------------- +// Username format: +// 0: username@domain +// 1: username%domain +// 2: username.domain +// 3: domain.username +// 4: username-domain +// 5: domain-username +// 6: username_domain +// 7: domain_username +$rcmail_config['password_virtualmin_format'] = 0; diff --git a/plugins/password/drivers/virtualmin.php b/plugins/password/drivers/virtualmin.php index 96200d61c..78ef4e7c3 100644 --- a/plugins/password/drivers/virtualmin.php +++ b/plugins/password/drivers/virtualmin.php @@ -10,15 +10,50 @@ * It only works with virtualmin on the same host where Roundcube runs * and requires shell access and gcc in order to compile the binary. * - * @version 1.0 + * @version 2.0 * @author Martijn de Munnik */ function password_save($currpass, $newpass) { - $curdir = realpath(dirname(__FILE__)); - $username = escapeshellcmd($_SESSION['username']); - $domain = substr(strrchr($username, "@"), 1); + $rcmail = rcmail::get_instance(); + + $format = $rcmail->config->get('password_virtualmin_format', 0); + $username = $_SESSION['username']; + + switch ($format) { + case 1: // username%domain + $domain = substr(strrchr($username, "%"), 1); + break; + case 2: // username.domain (could be bogus) + $pieces = explode(".", $username); + $domain = $pieces[count($pieces)-2]. "." . end($pieces); + break; + case 3: // domain.username (could be bogus) + $pieces = explode(".", $username); + $domain = $pieces[0]. "." . $pieces[1]; + break; + case 4: // username-domain + $domain = substr(strrchr($username, "-"), 1); + break; + case 5: // domain-username + $domain = str_replace(strrchr($username, "-"), "", $username); + break; + case 6: // username_domain + $domain = substr(strrchr($username, "_"), 1); + break; + case 7: // domain_username + $pieces = explode("_", $username); + $domain = $pieces[0]; + break; + default: // username@domain + $domain = substr(strrchr($username, "@"), 1); + } + + $username = escapeshellcmd($username); + $domain = escapeshellcmd($domain); + $newpass = escapeshellcmd($newpass); + $curdir = realpath(dirname(__FILE__)); exec("$curdir/chgvirtualminpasswd modify-user --domain $domain --user $username --pass $newpass", $output, $returnvalue); diff --git a/plugins/password/package.xml b/plugins/password/package.xml index d1472ff80..a4827dfd0 100644 --- a/plugins/password/package.xml +++ b/plugins/password/package.xml @@ -15,8 +15,8 @@ <email>alec@alec.pl</email> <active>yes</active> </lead> - <date></date> - <time></time> + <date>2011-02-15</date> + <time>12:00</time> <version> <release>2.2</release> <api>1.6</api> @@ -37,9 +37,8 @@ - Fix extended error messages handling (#1487676) - Fix double request when clicking on Password tab in Firefox - Fix deprecated split() usage in xmail and directadmin drivers (#1487769) -- ldap/ldap_simple drivers: use password_ldap_samba_pwattr/password_ldap_samba_lchattr - instead of password_ldap_samba option - Added option (password_log) for logging password changes +- Virtualmin driver: Add option for setting username format (#1487781) </notes> <contents> <dir baseinstalldir="/" name="/"> |
