]> git.donarmstrong.com Git - roundcube.git/blob - plugins/password/drivers/sasl.php
f8ac5c60687046802cf53125ef0d709fabe39d53
[roundcube.git] / plugins / password / drivers / sasl.php
1 <?php
2
3 /**
4  * SASL Password Driver
5  *
6  * Driver that adds functionality to change the users Cyrus/SASL password.
7  * The code is derrived from the Squirrelmail "Change SASL Password" Plugin
8  * by Galen Johnson.
9  *
10  * It only works with saslpasswd2 on the same host where Roundcube runs
11  * and requires shell access and gcc in order to compile the binary.
12  *
13  * For installation instructions please read the README file.
14  *
15  * @version 1.0
16  * @author Thomas Bruederli
17  */
18  
19 function password_save($currpass, $newpass)
20 {
21     $curdir = realpath(dirname(__FILE__));
22     $username = escapeshellcmd($_SESSION['username']);
23     $args = rcmail::get_instance()->config->get('password_saslpasswd_args', '');
24
25     if ($fh = popen("$curdir/chgsaslpasswd -p $args $username", 'w')) {
26         fwrite($fh, $newpass."\n");
27         $code = pclose($fh);
28
29         if ($code == 0)
30             return PASSWORD_SUCCESS;
31     }
32     else {
33         raise_error(array(
34             'code' => 600,
35             'type' => 'php',
36             'file' => __FILE__, 'line' => __LINE__,
37             'message' => "Password plugin: Unable to execute $curdir/chgsaslpasswd"
38             ), true, false);
39     }
40
41     return PASSWORD_ERROR;
42 }
43
44 ?>