]> git.donarmstrong.com Git - roundcube.git/blob - plugins/password/drivers/virtualmin.php
Imported Debian patch 0.5.1+dfsg-7
[roundcube.git] / plugins / password / drivers / virtualmin.php
1 <?php
2
3 /**
4  * Virtualmin Password Driver
5  *
6  * Driver that adds functionality to change the users Virtualmin password.
7  * The code is derrived from the Squirrelmail "Change Cyrus/SASL Password" Plugin
8  * by Thomas Bruederli.
9  *
10  * It only works with virtualmin on the same host where Roundcube runs
11  * and requires shell access and gcc in order to compile the binary.
12  *
13  * @version 1.0
14  * @author Martijn de Munnik
15  */
16
17 function password_save($currpass, $newpass)
18 {
19     $curdir = realpath(dirname(__FILE__));
20     $username = escapeshellcmd($_SESSION['username']);
21     $domain = substr(strrchr($username, "@"), 1);
22
23     exec("$curdir/chgvirtualminpasswd modify-user --domain $domain --user $username --pass $newpass", $output, $returnvalue);
24
25     if ($returnvalue == 0) {
26         return PASSWORD_SUCCESS;
27     }
28     else {
29         raise_error(array(
30             'code' => 600,
31             'type' => 'php',
32             'file' => __FILE__, 'line' => __LINE__,
33             'message' => "Password plugin: Unable to execute $curdir/chgvirtualminpasswd"
34             ), true, false);
35     }
36
37     return PASSWORD_ERROR;
38 }
39
40 ?>