| 1 | ----------------------------------------------------------------------- |
|---|
| 2 | Password Plugin for Roundcube |
|---|
| 3 | ----------------------------------------------------------------------- |
|---|
| 4 | |
|---|
| 5 | Plugin that adds a possibility to change user password using many |
|---|
| 6 | methods (drivers) via Settings/Password tab. |
|---|
| 7 | |
|---|
| 8 | ----------------------------------------------------------------------- |
|---|
| 9 | This program is free software; you can redistribute it and/or modify |
|---|
| 10 | it under the terms of the GNU General Public License version 2 |
|---|
| 11 | as published by the Free Software Foundation. |
|---|
| 12 | |
|---|
| 13 | This program is distributed in the hope that it will be useful, |
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | GNU General Public License for more details. |
|---|
| 17 | |
|---|
| 18 | You should have received a copy of the GNU General Public License along |
|---|
| 19 | with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|---|
| 21 | |
|---|
| 22 | @version @package_version@ |
|---|
| 23 | @author Aleksander 'A.L.E.C' Machniak <alec@alec.pl> |
|---|
| 24 | @author <see driver files for driver authors> |
|---|
| 25 | ----------------------------------------------------------------------- |
|---|
| 26 | |
|---|
| 27 | 1. Configuration |
|---|
| 28 | 2. Drivers |
|---|
| 29 | 2.1. Database (sql) |
|---|
| 30 | 2.2. Cyrus/SASL (sasl) |
|---|
| 31 | 2.3. Poppassd/Courierpassd (poppassd) |
|---|
| 32 | 2.4. LDAP (ldap) |
|---|
| 33 | 2.5. DirectAdmin Control Panel (directadmin) |
|---|
| 34 | 2.6. cPanel (cpanel) |
|---|
| 35 | 2.7. XIMSS/Communigate (ximms) |
|---|
| 36 | 2.8. Virtualmin (virtualmin) |
|---|
| 37 | 2.9. hMailServer (hmail) |
|---|
| 38 | 2.10. PAM (pam) |
|---|
| 39 | 2.11. Chpasswd (chpasswd) |
|---|
| 40 | 3. Driver API |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | 1. Configuration |
|---|
| 44 | ---------------- |
|---|
| 45 | |
|---|
| 46 | Copy config.inc.php.dist to config.inc.php and set the options as described |
|---|
| 47 | within the file. |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | 2. Drivers |
|---|
| 51 | ---------- |
|---|
| 52 | |
|---|
| 53 | Password plugin supports many password change mechanisms which are |
|---|
| 54 | handled by included drivers. Just pass driver name in 'password_driver' option. |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | 2.1. Database (sql) |
|---|
| 58 | ------------------- |
|---|
| 59 | |
|---|
| 60 | You can specify which database to connect by 'password_db_dsn' option and |
|---|
| 61 | what SQL query to execute by 'password_query'. See main.inc.php file for |
|---|
| 62 | more info. |
|---|
| 63 | |
|---|
| 64 | Example implementations of an update_passwd function: |
|---|
| 65 | |
|---|
| 66 | - This is for use with LMS (http://lms.org.pl) database and postgres: |
|---|
| 67 | |
|---|
| 68 | CREATE OR REPLACE FUNCTION update_passwd(hash text, account text) RETURNS integer AS $$ |
|---|
| 69 | DECLARE |
|---|
| 70 | res integer; |
|---|
| 71 | BEGIN |
|---|
| 72 | UPDATE passwd SET password = hash |
|---|
| 73 | WHERE login = split_part(account, '@', 1) |
|---|
| 74 | AND domainid = (SELECT id FROM domains WHERE name = split_part(account, '@', 2)) |
|---|
| 75 | RETURNING id INTO res; |
|---|
| 76 | RETURN res; |
|---|
| 77 | END; |
|---|
| 78 | $$ LANGUAGE plpgsql SECURITY DEFINER; |
|---|
| 79 | |
|---|
| 80 | - This is for use with a SELECT update_passwd(%o,%c,%u) query |
|---|
| 81 | Updates the password only when the old password matches the MD5 password |
|---|
| 82 | in the database |
|---|
| 83 | |
|---|
| 84 | CREATE FUNCTION update_password (oldpass text, cryptpass text, user text) RETURNS text |
|---|
| 85 | MODIFIES SQL DATA |
|---|
| 86 | BEGIN |
|---|
| 87 | DECLARE currentsalt varchar(20); |
|---|
| 88 | DECLARE error text; |
|---|
| 89 | SET error = 'incorrect current password'; |
|---|
| 90 | SELECT substring_index(substr(user.password,4),_latin1'$',1) INTO currentsalt FROM users WHERE username=user; |
|---|
| 91 | SELECT '' INTO error FROM users WHERE username=user AND password=ENCRYPT(oldpass,currentsalt); |
|---|
| 92 | UPDATE users SET password=cryptpass WHERE username=user AND password=ENCRYPT(oldpass,currentsalt); |
|---|
| 93 | RETURN error; |
|---|
| 94 | END |
|---|
| 95 | |
|---|
| 96 | Example SQL UPDATEs: |
|---|
| 97 | |
|---|
| 98 | - Plain text passwords: |
|---|
| 99 | UPDATE users SET password=%p WHERE username=%u AND password=%o AND domain=%h LIMIT 1 |
|---|
| 100 | |
|---|
| 101 | - Crypt text passwords: |
|---|
| 102 | UPDATE users SET password=%c WHERE username=%u LIMIT 1 |
|---|
| 103 | |
|---|
| 104 | - Use a MYSQL crypt function (*nix only) with random 8 character salt |
|---|
| 105 | UPDATE users SET password=ENCRYPT(%p,concat(_utf8'$1$',right(md5(rand()),8),_utf8'$')) WHERE username=%u LIMIT 1 |
|---|
| 106 | |
|---|
| 107 | - MD5 stored passwords: |
|---|
| 108 | UPDATE users SET password=MD5(%p) WHERE username=%u AND password=MD5(%o) LIMIT 1 |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | 2.2. Cyrus/SASL (sasl) |
|---|
| 112 | ---------------------- |
|---|
| 113 | |
|---|
| 114 | Cyrus SASL database authentication allows your Cyrus+RoundCube |
|---|
| 115 | installation to host mail users without requiring a Unix Shell account! |
|---|
| 116 | |
|---|
| 117 | This driver only covers the "sasldb" case when using Cyrus SASL. Kerberos |
|---|
| 118 | and PAM authentication mechanisms will require other techniques to enable |
|---|
| 119 | user password manipulations. |
|---|
| 120 | |
|---|
| 121 | Cyrus SASL includes a shell utility called "saslpasswd" for manipulating |
|---|
| 122 | user passwords in the "sasldb" database. This plugin attempts to use |
|---|
| 123 | this utility to perform password manipulations required by your webmail |
|---|
| 124 | users without any administrative interaction. Unfortunately, this |
|---|
| 125 | scheme requires that the "saslpasswd" utility be run as the "cyrus" |
|---|
| 126 | user - kind of a security problem since we have chosen to SUID a small |
|---|
| 127 | script which will allow this to happen. |
|---|
| 128 | |
|---|
| 129 | This driver is based on the Squirrelmail Change SASL Password Plugin. |
|---|
| 130 | See http://www.squirrelmail.org/plugin_view.php?id=107 for details. |
|---|
| 131 | |
|---|
| 132 | Installation: |
|---|
| 133 | |
|---|
| 134 | Change into the drivers directory. Edit the chgsaslpasswd.c file as is |
|---|
| 135 | documented within it. |
|---|
| 136 | |
|---|
| 137 | Compile the wrapper program: |
|---|
| 138 | gcc -o chgsaslpasswd chgsaslpasswd.c |
|---|
| 139 | |
|---|
| 140 | Chown the compiled chgsaslpasswd binary to the cyrus user and group |
|---|
| 141 | that your browser runs as, then chmod them to 4550. |
|---|
| 142 | |
|---|
| 143 | For example, if your cyrus user is 'cyrus' and the apache server group is |
|---|
| 144 | 'nobody' (I've been told Redhat runs Apache as user 'apache'): |
|---|
| 145 | |
|---|
| 146 | chown cyrus:nobody chgsaslpasswd |
|---|
| 147 | chmod 4550 chgsaslpasswd |
|---|
| 148 | |
|---|
| 149 | Stephen Carr has suggested users should try to run the scripts on a test |
|---|
| 150 | account as the cyrus user eg; |
|---|
| 151 | |
|---|
| 152 | su cyrus -c "./chgsaslpasswd -p test_account" |
|---|
| 153 | |
|---|
| 154 | This will allow you to make sure that the script will work for your setup. |
|---|
| 155 | Should the script not work, make sure that: |
|---|
| 156 | 1) the user the script runs as has access to the saslpasswd|saslpasswd2 |
|---|
| 157 | file and proper permissions |
|---|
| 158 | 2) make sure the user in the chgsaslpasswd.c file is set correctly. |
|---|
| 159 | This could save you some headaches if you are the paranoid type. |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | 2.3. Poppassd/Courierpassd (poppassd) |
|---|
| 163 | ------------------------------------- |
|---|
| 164 | |
|---|
| 165 | You can specify which host to connect to via 'password_pop_host' and |
|---|
| 166 | what port via 'password_pop_port'. See config.inc.php file for more info. |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | 2.4. LDAP (ldap) |
|---|
| 170 | ---------------- |
|---|
| 171 | |
|---|
| 172 | See config.inc.php file. Requires PEAR::Net_LDAP2 package. |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | 2.5. DirectAdmin Control Panel (directadmin) |
|---|
| 176 | -------------------------------------------- |
|---|
| 177 | |
|---|
| 178 | You can specify which host to connect to via 'password_directadmin_host' |
|---|
| 179 | and what port via 'password_direactadmin_port'. See config.inc.php file |
|---|
| 180 | for more info. |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | 2.6. cPanel (cpanel) |
|---|
| 184 | -------------------- |
|---|
| 185 | |
|---|
| 186 | You can specify parameters for HTTP connection to cPanel's admin |
|---|
| 187 | interface. See config.inc.php file for more info. |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | 2.7. XIMSS/Communigate (ximms) |
|---|
| 191 | ------------------------------ |
|---|
| 192 | |
|---|
| 193 | You can specify which host and port to connect to via 'password_ximss_host' |
|---|
| 194 | and 'password_ximss_port'. See config.inc.php file for more info. |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | 2.8. Virtualmin (virtualmin) |
|---|
| 198 | ---------------------------- |
|---|
| 199 | |
|---|
| 200 | As in sasl driver this one allows to change password using shell |
|---|
| 201 | utility called "virtualmin". See drivers/chgvirtualminpasswd.c for |
|---|
| 202 | installation instructions. |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | 2.9. hMailServer (hmail) |
|---|
| 206 | ------------------------ |
|---|
| 207 | |
|---|
| 208 | Requires PHP COM (Windows only). |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | 2.10. PAM (pam) |
|---|
| 212 | --------------- |
|---|
| 213 | |
|---|
| 214 | This driver is for changing passwords of shell users authenticated with PAM. |
|---|
| 215 | Requires PECL's PAM exitension to be installed (http://pecl.php.net/package/PAM). |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | 2.11. Chpasswd (chpasswd) |
|---|
| 219 | ------------------------- |
|---|
| 220 | |
|---|
| 221 | Driver that adds functionality to change the systems user password via |
|---|
| 222 | the 'chpasswd' command. See config.inc.php file. |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | 3. Driver API |
|---|
| 226 | ------------- |
|---|
| 227 | |
|---|
| 228 | Driver file (<driver_name>.php) must define 'password_save' function with |
|---|
| 229 | two arguments. First - current password, second - new password. Function |
|---|
| 230 | may return PASSWORD_SUCCESS on success or any of PASSWORD_CONNECT_ERROR, |
|---|
| 231 | PASSWORD_CRYPT_ERROR, PASSWORD_ERROR when driver was unable to change password. |
|---|
| 232 | See existing drivers in drivers/ directory for examples. |
|---|