Aleksander Machniak
2016-01-21 a7fac6afb6936becefa632088c9652fbe87cd205
commit | author | age
48e9c1 1 <?php
T 2
3 /**
4  * DBMail Password Driver
5  *
6  * Driver that adds functionality to change the users DBMail password.
7  * The code is derrived from the Squirrelmail "Change SASL Password" Plugin
8  * by Galen Johnson.
9  *
10  * It only works with dbmail-users on the same host where Roundcube runs
11  * and requires shell access and gcc in order to compile the binary.
12  *
13  * For installation instructions please read the README file.
14  *
15  * @version 1.0
16  */
17
18 class rcube_dbmail_password
19 {
3505d5 20     function save($currpass, $newpass)
48e9c1 21     {
e2e2e8 22         $curdir   = RCUBE_PLUGINS_DIR . 'password/helpers';
f6336f 23         $username = escapeshellarg($_SESSION['username']);
AM 24         $password = escapeshellarg($newpass);
48e9c1 25         $args     = rcmail::get_instance()->config->get('password_dbmail_args', '');
f6336f 26         $command  = "$curdir/chgdbmailusers -c $username -w $password $args";
48e9c1 27
a7fac6 28         exec($command, $output, $return_value);
f6336f 29
a7fac6 30         if ($return_value == 0) {
48e9c1 31             return PASSWORD_SUCCESS;
T 32         }
33         else {
61be82 34             rcube::raise_error(array(
48e9c1 35                 'code' => 600,
T 36                 'type' => 'php',
37                 'file' => __FILE__, 'line' => __LINE__,
38                 'message' => "Password plugin: Unable to execute $curdir/chgdbmailusers"
39                 ), true, false);
40         }
41
42         return PASSWORD_ERROR;
43     }
44 }