Thomas Bruederli
2013-06-20 07c6c69eca8751c0e96a846afb30c24ab2638b1f
commit | author | age
48e9c1 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 2.0
12  * @author Alex Cartwright <acartwright@mutinydesign.co.uk>
13  */
14
15 class rcube_chpasswd_password
16 {
17     public function save($currpass, $newpass)
18     {
19         $cmd = rcmail::get_instance()->config->get('password_chpasswd_cmd');
20         $username = $_SESSION['username'];
21
22         $handle = popen($cmd, "w");
23         fwrite($handle, "$username:$newpass\n");
24
25         if (pclose($handle) == 0) {
26             return PASSWORD_SUCCESS;
27         }
28         else {
61be82 29             rcube::raise_error(array(
48e9c1 30                 'code' => 600,
T 31                 'type' => 'php',
32                 'file' => __FILE__, 'line' => __LINE__,
33                 'message' => "Password plugin: Unable to execute $cmd"
34                 ), true, false);
35         }
36
37         return PASSWORD_ERROR;
38     }
39 }