0
|
1 <?php
|
|
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 * Copyright (C) 2005-2013, The Roundcube Dev Team
|
|
16 *
|
|
17 * This program is free software: you can redistribute it and/or modify
|
|
18 * it under the terms of the GNU General Public License as published by
|
|
19 * the Free Software Foundation, either version 3 of the License, or
|
|
20 * (at your option) any later version.
|
|
21 *
|
|
22 * This program is distributed in the hope that it will be useful,
|
|
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25 * GNU General Public License for more details.
|
|
26 *
|
|
27 * You should have received a copy of the GNU General Public License
|
|
28 * along with this program. If not, see http://www.gnu.org/licenses/.
|
|
29 */
|
|
30
|
|
31 class rcube_pw_usermod_password
|
|
32 {
|
|
33 public function save($currpass, $newpass)
|
|
34 {
|
|
35 $username = $_SESSION['username'];
|
|
36 $cmd = rcmail::get_instance()->config->get('password_pw_usermod_cmd');
|
|
37 $cmd .= " $username > /dev/null";
|
|
38
|
|
39 $handle = popen($cmd, "w");
|
|
40 fwrite($handle, "$newpass\n");
|
|
41
|
|
42 if (pclose($handle) == 0) {
|
|
43 return PASSWORD_SUCCESS;
|
|
44 }
|
|
45 else {
|
|
46 rcube::raise_error(array(
|
|
47 'code' => 600,
|
|
48 'type' => 'php',
|
|
49 'file' => __FILE__, 'line' => __LINE__,
|
|
50 'message' => "Password plugin: Unable to execute $cmd"
|
|
51 ), true, false);
|
|
52 }
|
|
53
|
|
54 return PASSWORD_ERROR;
|
|
55 }
|
|
56 }
|