Aleksander Machniak
2015-02-05 f6336f7f7ec7e65290b6fde23b8fd64627fe15b8
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
f6336f 28         if (strlen($command) > 1024) {
AM 29             rcube::raise_error(array(
30                 'code' => 600,
31                 'type' => 'php',
32                 'file' => __FILE__, 'line' => __LINE__,
33                 'message' => "Password plugin: The command is too long."
34                 ), true, false);
35
36             return PASSWORD_ERROR;
37         }
38
39         exec($command, $output, $returnvalue);
48e9c1 40
T 41         if ($returnvalue == 0) {
42             return PASSWORD_SUCCESS;
43         }
44         else {
61be82 45             rcube::raise_error(array(
48e9c1 46                 'code' => 600,
T 47                 'type' => 'php',
48                 'file' => __FILE__, 'line' => __LINE__,
49                 'message' => "Password plugin: Unable to execute $curdir/chgdbmailusers"
50                 ), true, false);
51         }
52
53         return PASSWORD_ERROR;
54     }
55 }