alecpl
2009-10-06 ffeab7fe7e0ccf1d458d6a863600359c38769950
commit | author | age
6bd74d 1  -----------------------------------------------------------------------
A 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  -----------------------------------------------------------------------
4534ab 9  This program is free software; you can redistribute it and/or modify
A 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
6bd74d 18  You should have received a copy of the GNU General Public License along
A 19  with this program; if not, write to the Free Software Foundation, Inc.,
4534ab 20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6bd74d 21
A 22  @version 1.2
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)
4534ab 31  2.3.    Poppassd/Courierpassd (poppassd)
c8a1e6 32  2.4.    LDAP (ldap)
613471 33  2.5.    DirectAdmin Control Panel
1bf9a8 34  2.6.   cPanel
6bd74d 35  3.    Driver API
A 36
37
38  1. Configuration
39  ----------------
40
be6c97 41  Copy config.inc.php.dist to config.inc.php and set the options as described
T 42  within the file.
6bd74d 43
A 44
45  2. Drivers
46  ----------
47
48  Password plugin supports many password change mechanisms which are
49  handled by included drivers. Just pass driver name in 'password_driver' option.
50
51
52  2.1. Database (sql)
53  -------------------
54
55  You can specify which database to connect by 'password_db_dsn' option and
56  what SQL query to execute by 'password_query'. See main.inc.php file for
57  more info.
4534ab 58
6bd74d 59  Example implementations of an update_passwd function:
A 60
61  - This is for use with LMS (http://lms.org.pl) database and postgres:
62
63     CREATE OR REPLACE FUNCTION update_passwd(hash text, account text) RETURNS integer AS $$
64     DECLARE
65             res integer;
66     BEGIN
67             UPDATE passwd SET password = hash
68         WHERE login = split_part(account, '@', 1)
69         AND domainid = (SELECT id FROM domains WHERE name = split_part(account, '@', 2))
70         RETURNING id INTO res;
71         RETURN res;
72     END;
73     $$ LANGUAGE plpgsql SECURITY DEFINER;
74
75  - This is for use with a SELECT update_passwd(%o,%c,%u) query
76     Updates the password only when the old password matches the MD5 password
77     in the database
78
79     CREATE FUNCTION update_password (oldpass text, cryptpass text, user text) RETURNS text
80             MODIFIES SQL DATA
81     BEGIN
82         DECLARE currentsalt varchar(20);
83         DECLARE error text;
84         SET error = 'incorrect current password';
85         SELECT substring_index(substr(user.password,4),_latin1'$',1) INTO currentsalt FROM users WHERE username=user;
86         SELECT '' INTO error FROM users WHERE username=user AND password=ENCRYPT(oldpass,currentsalt);
87         UPDATE users SET password=cryptpass WHERE username=user AND password=ENCRYPT(oldpass,currentsalt);
88         RETURN error;
89     END
90
91  Example SQL UPDATEs:
4534ab 92
6bd74d 93  - Plain text passwords:
A 94     UPDATE users SET password=%p WHERE username=%u AND password=%o AND domain=%h LIMIT 1
4534ab 95
6bd74d 96  - Crypt text passwords:
A 97     UPDATE users SET password=%c WHERE username=%u LIMIT 1
98
99  - Use a MYSQL crypt function (*nix only) with random 8 character salt
100     UPDATE users SET password=ENCRYPT(%p,concat(_utf8'$1$',right(md5(rand()),8),_utf8'$')) WHERE username=%u LIMIT 1
4534ab 101
6bd74d 102  - MD5 stored passwords:
A 103     UPDATE users SET password=MD5(%p) WHERE username=%u AND password=MD5(%o) LIMIT 1
104
105
106  2.2. Cyrus/SASL (sasl)
107  ----------------------
108
109  Cyrus SASL database authentication allows your Cyrus+RoundCube
110  installation to host mail users without requiring a Unix Shell account!
111
112  This driver only covers the "sasldb" case when using Cyrus SASL. Kerberos
113  and PAM authentication mechanisms will require other techniques to enable
114  user password manipulations.
115
116  Cyrus SASL includes a shell utility called "saslpasswd" for manipulating
117  user passwords in the "sasldb" database.  This plugin attempts to use
118  this utility to perform password manipulations required by your webmail
119  users without any administrative interaction. Unfortunately, this
120  scheme requires that the "saslpasswd" utility be run as the "cyrus"
121  user - kind of a security problem since we have chosen to SUID a small
122  script which will allow this to happen.
123
124  This driver is based on the Squirrelmail Change SASL Password Plugin.
125  See http://www.squirrelmail.org/plugin_view.php?id=107 for details.
126
127  Installation:
128
8e9a55 129  Change into the drivers directory. Edit the chgsaslpasswd.c file as is
T 130  documented within it.
6bd74d 131
A 132  Compile the wrapper program:
133     gcc -o chgsaslpasswd chgsaslpasswd.c
134
8e9a55 135  Chown the compiled chgsaslpasswd binary to the cyrus user and group
6bd74d 136  that your browser runs as, then chmod them to 4550.
A 137
138  For example, if your cyrus user is 'cyrus' and the apache server group is
139  'nobody' (I've been told Redhat runs Apache as user 'apache'):
140
141     chown cyrus:nobody chgsaslpasswd
142     chmod 4550 chgsaslpasswd
143
144  Stephen Carr has suggested users should try to run the scripts on a test
145  account as the cyrus user eg;
146
147     su cyrus -c "./chgsaslpasswd -p test_account"
148
149  This will allow you to make sure that the script will work for your setup.
150  Should the script not work, make sure that:
151  1) the user the script runs as has access to the saslpasswd|saslpasswd2
152    file and proper permissions
153  2) make sure the user in the chgsaslpasswd.c file is set correctly.
154    This could save you some headaches if you are the paranoid type.
155
156
4534ab 157  2.3. Poppassd/Courierpassd (poppassd)
c8a1e6 158  -------------------------------------
4534ab 159
A 160  You can specify which host to connect to via `password_pop_host` and
161  what port via `password_pop_port`. See config.inc.php file for more info.
162
163
c8a1e6 164  2.4. LDAP (ldap)
A 165  ----------------
613471 166
c8a1e6 167  See config.inc.php file. Requires PEAR::Net_LDAP2 package.
A 168
169
613471 170  2.5. DirectAdmin Control Panel
A 171  -------------------------------------
172
173  You can specify which host to connect to via `password_directadmin_host` 
174  and what port via `password_direactadmin_port`. See config.inc.php file 
175  for more info.
176
177
1bf9a8 178  2.6. cPanel
A 179  -----------
180
181  You can specify parameters for HTTP connection to cPanel's admin
182  interface. See config.inc.php file for more info.
183
184
6bd74d 185  3. Driver API
A 186  -------------
4534ab 187
6bd74d 188  Driver file (<driver_name>.php) must define 'password_save' function with
A 189  two arguments. First - current password, second - new password. Function
4534ab 190  may return PASSWORD_SUCCESS on success or any of PASSWORD_CONNECT_ERROR,
A 191  PASSWORD_CRYPT_ERROR, PASSWORD_ERROR when driver was unable to change password.
6bd74d 192  See existing drivers in drivers/ directory for examples.