Mercurial > hg > rc1
comparison plugins/password/drivers/pam.php @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e000243b222 |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * PAM Password Driver | |
5 * | |
6 * @version 2.0 | |
7 * @author Aleksander Machniak | |
8 * | |
9 * Copyright (C) 2005-2013, The Roundcube Dev Team | |
10 * | |
11 * This program is free software: you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation, either version 3 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program. If not, see http://www.gnu.org/licenses/. | |
23 */ | |
24 | |
25 class rcube_pam_password | |
26 { | |
27 function save($currpass, $newpass) | |
28 { | |
29 $user = $_SESSION['username']; | |
30 $error = ''; | |
31 | |
32 if (extension_loaded('pam') || extension_loaded('pam_auth')) { | |
33 if (pam_auth($user, $currpass, $error, false)) { | |
34 if (pam_chpass($user, $currpass, $newpass)) { | |
35 return PASSWORD_SUCCESS; | |
36 } | |
37 } | |
38 else { | |
39 rcube::raise_error(array( | |
40 'code' => 600, | |
41 'type' => 'php', | |
42 'file' => __FILE__, 'line' => __LINE__, | |
43 'message' => "Password plugin: PAM authentication failed for user $user: $error" | |
44 ), true, false); | |
45 } | |
46 } | |
47 else { | |
48 rcube::raise_error(array( | |
49 'code' => 600, | |
50 'type' => 'php', | |
51 'file' => __FILE__, 'line' => __LINE__, | |
52 'message' => "Password plugin: PECL-PAM module not loaded" | |
53 ), true, false); | |
54 } | |
55 | |
56 return PASSWORD_ERROR; | |
57 } | |
58 } |