Aleksander Machniak
2016-01-25 4473dc558828a94e9e251c302235358af1d08712
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
4baf96 16  *
AM 17  * Copyright (C) 2005-2013, The Roundcube Dev Team
18  *
19  * This program is free software: you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation, either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see http://www.gnu.org/licenses/.
48e9c1 31  */
T 32
33 class rcube_dbmail_password
34 {
18a9b4 35     function save($currpass, $newpass)
48e9c1 36     {
e2e2e8 37         $curdir   = RCUBE_PLUGINS_DIR . 'password/helpers';
7c9664 38         $username = escapeshellarg($_SESSION['username']);
AM 39         $password = escapeshellarg($newpass);
48e9c1 40         $args     = rcmail::get_instance()->config->get('password_dbmail_args', '');
7c9664 41         $command  = "$curdir/chgdbmailusers -c $username -w $password $args";
48e9c1 42
8ef598 43         exec($command, $output, $return_value);
7c9664 44
8ef598 45         if ($return_value == 0) {
48e9c1 46             return PASSWORD_SUCCESS;
T 47         }
48         else {
61be82 49             rcube::raise_error(array(
48e9c1 50                 'code' => 600,
T 51                 'type' => 'php',
52                 'file' => __FILE__, 'line' => __LINE__,
53                 'message' => "Password plugin: Unable to execute $curdir/chgdbmailusers"
54                 ), true, false);
55         }
56
57         return PASSWORD_ERROR;
58     }
59 }