[dev] [PATCH] passwd2.2 vpopmail fix

jason at bitstream.net jason at bitstream.net
Wed Feb 4 17:06:34 PST 2004


The attached file contains some minor changes I needed to make to passwd
2.2 to get the vpopmail driver to work correctly.

changes:

Horde::getDriverConfig() seems to have dissappeared.  The reference to it
in vpopmail.php was removed.

A new password type, newcrypt, was added to support the glibc2 md5 crypt
password format.

A change was made to default the userid in the password form to
the full username that they authenticated as (user at host.com).  The default
for other password drivers is still to truncate the username (omitting
@host.com).

Please let me know if you have any questions.

Thanks!

Jason M. Striegel
-------------- next part --------------
diff -ru oldpasswd/lib/Driver/vpopmail.php passwd/lib/Driver/vpopmail.php
--- oldpasswd/lib/Driver/vpopmail.php	2004-02-04 15:36:27.000000000 -0600
+++ passwd/lib/Driver/vpopmail.php	2004-02-04 18:39:51.000000000 -0600
@@ -39,13 +39,12 @@
             return PEAR::raiseError(_("Required 'phptype' not specified in SQL configuration."));
         }
 
-        /* Use defaults from Horde */
-        $defaults = Horde::getDriverConfig('', 'sql');
-        $this->_params['hostspec']   = array_key_exists('hostspec', $params)   ? $params['hostspec'] : $defaults['hostspec'];
-        $this->_params['protocol']   = array_key_exists('protocol', $params)   ? $params['protocol'] : $defaults['protocol'];
-        $this->_params['username']   = array_key_exists('username', $params)   ? $params['username'] : $defaults['username'];
-        $this->_params['password']   = array_key_exists('password', $params)   ? $params['password'] : $defaults['password'];
-        $this->_params['database']   = array_key_exists('database', $params)   ? $params['database'] : $defaults['database'];
+        /* Defaults to match vpopmail defaults */
+        $this->_params['hostspec']   = array_key_exists('hostspec', $params)   ? $params['hostspec'] : 'localhost';
+        $this->_params['protocol']   = array_key_exists('protocol', $params)   ? $params['protocol'] : '';
+        $this->_params['username']   = array_key_exists('username', $params)   ? $params['username'] : 'vpopmail';
+        $this->_params['password']   = array_key_exists('password', $params)   ? $params['password'] : 'vpopmail';
+        $this->_params['database']   = array_key_exists('database', $params)   ? $params['database'] : 'vpopmail';
 
         /* Defaults to match Auth::sql default */
         $this->_params['table']      = array_key_exists('table', $params)      ? $params['table'] : 'horde_users';
diff -ru oldpasswd/lib/Driver.php passwd/lib/Driver.php
--- oldpasswd/lib/Driver.php	2004-02-04 15:36:27.000000000 -0600
+++ passwd/lib/Driver.php	2004-02-04 18:00:39.000000000 -0600
@@ -110,6 +110,12 @@
                     return true;
                 }
                 break;
+            case 'newcrypt':
+	        list($ignore, $ncflag, $salt, $enc) = explode('$',$encrypted);
+                if ($encrypted == crypt($plaintext, '$' . $ncflag . '$'. $salt)) {
+                    return true;
+                }
+                break;
             case 'sha':
                 $encrypted = substr($encrypted, 5);
                 if ($encrypted == base64_encode(mHash(MHASH_SHA1, $plaintext)))
@@ -160,6 +166,10 @@
                 // The salt is left out, generated by php
                 $newPassword = "{crypt}" . crypt($newPassword);
                 break;
+            case "newcrypt":
+                // The salt is left out, generated by php
+                $newPassword = crypt($newPassword);
+		break;
             case "md5-hex":
                 $newPassword = md5($newPassword);
                 break;
diff -ru oldpasswd/main.php passwd/main.php
--- oldpasswd/main.php	2004-02-04 15:36:27.000000000 -0600
+++ passwd/main.php	2004-02-04 19:03:15.000000000 -0600
@@ -226,8 +226,16 @@
                                      Auth::getAuth());
         }
     } else {
-        $splitted  = split("@", Auth::getAuth());
-        $userid = @$splitted[0];
+        $driver = $backends[$backend_key]['driver'];
+        switch ($driver) {
+	    case 'vpopmail':
+                $userid = Auth::getAuth();
+                break;
+            default:
+                $splitted = split("@", Auth::getAuth());
+                $userid = @$splitted[0];
+                break;
+        }
     }
 }
 


More information about the dev mailing list