[Svn] r4546 - in trunk/plugins/password: . drivers

trac at roundcube.net trac at roundcube.net
Tue Feb 15 13:26:36 CET 2011


Author: alec
Date: 2011-02-15 06:26:26 -0600 (Tue, 15 Feb 2011)
New Revision: 4546

Modified:
   trunk/plugins/password/README
   trunk/plugins/password/config.inc.php.dist
   trunk/plugins/password/drivers/virtualmin.php
   trunk/plugins/password/package.xml
Log:
- Virtualmin driver: Add option for setting username format (#1487781)


Modified: trunk/plugins/password/README
===================================================================
--- trunk/plugins/password/README	2011-02-15 12:05:27 UTC (rev 4545)
+++ trunk/plugins/password/README	2011-02-15 12:26:26 UTC (rev 4546)
@@ -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)

Modified: trunk/plugins/password/config.inc.php.dist
===================================================================
--- trunk/plugins/password/config.inc.php.dist	2011-02-15 12:05:27 UTC (rev 4545)
+++ trunk/plugins/password/config.inc.php.dist	2011-02-15 12:26:26 UTC (rev 4546)
@@ -285,3 +285,16 @@
     'Password' => 'password' // windows user password
 );
 
+
+// Virtualmin Driver options
+// -------------------------
+// Username format:
+// 0: username at 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;

Modified: trunk/plugins/password/drivers/virtualmin.php
===================================================================
--- trunk/plugins/password/drivers/virtualmin.php	2011-02-15 12:05:27 UTC (rev 4545)
+++ trunk/plugins/password/drivers/virtualmin.php	2011-02-15 12:26:26 UTC (rev 4546)
@@ -10,16 +10,51 @@
  * 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 at 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);
 
     if ($returnvalue == 0) {

Modified: trunk/plugins/password/package.xml
===================================================================
--- trunk/plugins/password/package.xml	2011-02-15 12:05:27 UTC (rev 4545)
+++ trunk/plugins/password/package.xml	2011-02-15 12:26:26 UTC (rev 4546)
@@ -15,8 +15,8 @@
 		<email>alec at 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="/">

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list