commit | author | age
|
48e9c1
|
1 |
<?php |
T |
2 |
|
|
3 |
/** |
|
4 |
* expect Driver |
|
5 |
* |
|
6 |
* Driver that adds functionality to change the systems user password via |
|
7 |
* the 'expect' command. |
|
8 |
* |
|
9 |
* For installation instructions please read the README file. |
|
10 |
* |
|
11 |
* @version 2.0 |
|
12 |
* @author Andy Theuninck <gohanman@gmail.com) |
|
13 |
* |
|
14 |
* Based on chpasswd roundcubemail password driver by |
|
15 |
* @author Alex Cartwright <acartwright@mutinydesign.co.uk) |
|
16 |
* and expect horde passwd driver by |
|
17 |
* @author Gaudenz Steinlin <gaudenz@soziologie.ch> |
|
18 |
* |
|
19 |
* Configuration settings: |
|
20 |
* password_expect_bin => location of expect (e.g. /usr/bin/expect) |
|
21 |
* password_expect_script => path to "password-expect" file |
|
22 |
* password_expect_params => arguments for the expect script |
|
23 |
* see the password-expect file for details. This is probably |
|
24 |
* a good starting default: |
|
25 |
* -telent -host localhost -output /tmp/passwd.log -log /tmp/passwd.log |
|
26 |
*/ |
|
27 |
|
|
28 |
class rcube_expect_password |
|
29 |
{ |
|
30 |
public function save($currpass, $newpass) |
|
31 |
{ |
|
32 |
$rcmail = rcmail::get_instance(); |
|
33 |
$bin = $rcmail->config->get('password_expect_bin'); |
|
34 |
$script = $rcmail->config->get('password_expect_script'); |
|
35 |
$params = $rcmail->config->get('password_expect_params'); |
|
36 |
$username = $_SESSION['username']; |
|
37 |
|
|
38 |
$cmd = $bin . ' -f ' . $script . ' -- ' . $params; |
|
39 |
$handle = popen($cmd, "w"); |
|
40 |
fwrite($handle, "$username\n"); |
|
41 |
fwrite($handle, "$currpass\n"); |
|
42 |
fwrite($handle, "$newpass\n"); |
|
43 |
|
|
44 |
if (pclose($handle) == 0) { |
|
45 |
return PASSWORD_SUCCESS; |
|
46 |
} |
|
47 |
else { |
61be82
|
48 |
rcube::raise_error(array( |
48e9c1
|
49 |
'code' => 600, |
T |
50 |
'type' => 'php', |
|
51 |
'file' => __FILE__, 'line' => __LINE__, |
|
52 |
'message' => "Password plugin: Unable to execute $cmd" |
|
53 |
), true, false); |
|
54 |
} |
|
55 |
|
|
56 |
return PASSWORD_ERROR; |
|
57 |
} |
|
58 |
} |