Thomas Bruederli
2013-06-20 07c6c69eca8751c0e96a846afb30c24ab2638b1f
commit | author | age
48e9c1 1 <?php
T 2
3 /**
4  * pw_usermod Driver
5  *
6  * Driver that adds functionality to change the systems user password via
7  * the 'pw usermod' 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  * @author Adamson Huang <adomputer@gmail.com>
14  */
15
16 class rcube_pw_usermod_password
17 {
18     public function save($currpass, $newpass)
19     {
20         $username = $_SESSION['username'];
21         $cmd = rcmail::get_instance()->config->get('password_pw_usermod_cmd');
22         $cmd .= " $username > /dev/null";
23
24         $handle = popen($cmd, "w");
25         fwrite($handle, "$newpass\n");
26
27         if (pclose($handle) == 0) {
28             return PASSWORD_SUCCESS;
29         }
30         else {
61be82 31             rcube::raise_error(array(
48e9c1 32                 'code' => 600,
T 33                 'type' => 'php',
34                 'file' => __FILE__, 'line' => __LINE__,
35                 'message' => "Password plugin: Unable to execute $cmd"
36                 ), true, false);
37         }
38
39         return PASSWORD_ERROR;
40     }
41 }