]> git.donarmstrong.com Git - roundcube.git/blob - plugins/password/drivers/chpasswd.php
Imported Upstream version 0.5
[roundcube.git] / plugins / password / drivers / chpasswd.php
1 <?php
2
3 /**
4  * chpasswd Driver
5  *
6  * Driver that adds functionality to change the systems user password via
7  * the 'chpasswd' command.
8  *
9  * For installation instructions please read the README file.
10  *
11  * @version 1.0
12  * @author Alex Cartwright <acartwright@mutinydesign.co.uk)
13  */
14
15 function password_save($currpass, $newpass)
16 {
17     $cmd = rcmail::get_instance()->config->get('password_chpasswd_cmd');
18     $username = $_SESSION['username'];
19
20     $handle = popen($cmd, "w");
21     fwrite($handle, "$username:$newpass\n");
22
23     if (pclose($handle) == 0) {
24         return PASSWORD_SUCCESS;
25     }
26     else {
27         raise_error(array(
28             'code' => 600,
29             'type' => 'php',
30             'file' => __FILE__, 'line' => __LINE__,
31             'message' => "Password plugin: Unable to execute $cmd"
32             ), true, false);
33     }
34
35     return PASSWORD_ERROR;
36 }