0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 * kpasswd Driver
|
|
5 *
|
|
6 * Driver that adds functionality to change the systems user password via
|
|
7 * the 'kpasswd' command.
|
|
8 *
|
|
9 * For installation instructions please read the README file.
|
|
10 *
|
|
11 * @version 1.0
|
|
12 * @author Peter Allgeyer <peter.allgeyer@salzburgresearch.at>
|
|
13 *
|
|
14 * Based on chpasswd roundcubemail password driver by
|
|
15 * @author Alex Cartwright <acartwright@mutinydesign.co.uk>
|
|
16 */
|
|
17
|
|
18 class rcube_kpasswd_password
|
|
19 {
|
|
20 public function save($currpass, $newpass)
|
|
21 {
|
|
22 $bin = rcmail::get_instance()->config->get('password_kpasswd_cmd', '/usr/bin/kpasswd');
|
|
23 $username = $_SESSION['username'];
|
|
24 $cmd = $bin . ' "' . $username . '" 2>&1';
|
|
25
|
|
26 $handle = popen($cmd, "w");
|
|
27 fwrite($handle, $currpass."\n");
|
|
28 fwrite($handle, $newpass."\n");
|
|
29 fwrite($handle, $newpass."\n");
|
|
30
|
|
31 if (pclose($handle) == 0) {
|
|
32 return PASSWORD_SUCCESS;
|
|
33 }
|
|
34 else {
|
|
35 rcube::raise_error(array(
|
|
36 'code' => 600,
|
|
37 'type' => 'php',
|
|
38 'file' => __FILE__, 'line' => __LINE__,
|
|
39 'message' => "Password plugin: Unable to execute $cmd"
|
|
40 ), true, false);
|
|
41 }
|
|
42
|
|
43 return PASSWORD_ERROR;
|
|
44 }
|
|
45 }
|