thomascube
2010-12-17 db1a87cd6c506f2afbd1a37c64cb56ae11120b49
commit | author | age
5fec6d 1 <?php
T 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");
db1a87 21     fwrite($handle, "$username:$newpass\n");
5fec6d 22
T 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 }