1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
<?php
/*
* system_usermanager_passwordmg.php
*
* part of pfSense (https://www.pfsense.org)
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
##|+PRIV
##|*IDENT=page-system-usermanager-passwordmg
##|*NAME=System: User Password Manager
##|*DESCR=Allow access to the 'System: User Password Manager' page.
##|*MATCH=system_usermanager_passwordmg.php*
##|-PRIV
require_once("auth.inc");
require_once("certs.inc");
require_once("guiconfig.inc");
$pgtitle = array(gettext("System"), gettext("User Password"));
if (isset($_POST['save'])) {
unset($input_errors);
/* input validation */
$reqdfields = explode(" ", "passwordfld1");
$reqdfieldsn = array(gettext("Password"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if ($_POST['passwordfld1'] != $_POST['passwordfld2']) {
$input_errors[] = gettext("The passwords do not match.");
}
if (!$input_errors) {
if (!session_id()) {
session_start();
}
// all values are okay --> saving changes
$userent =& $config['system']['user'][$userindex[$_SESSION['Username']]];
local_user_set_password($userent, $_POST['passwordfld1']);
local_user_set($userent);
unset($userent);
session_commit();
write_config();
$savemsg = gettext("Password successfully changed.");
}
}
if (!session_id()) {
session_start();
}
/* determine if user is not local to system */
$islocal = false;
foreach ($config['system']['user'] as $user) {
if ($user['name'] == $_SESSION['Username']) {
$islocal = true;
}
}
session_commit();
include("head.inc");
if ($input_errors) {
print_input_errors($input_errors);
}
if ($savemsg) {
print_info_box($savemsg, 'success');
}
if ($islocal == false) {
echo gettext("The password cannot be changed for a non-local user.");
include("foot.inc");
exit;
}
$form = new Form();
$section = new Form_Section('Update Password');
$section->addInput(new Form_Input(
'passwordfld1',
'Password',
'password'
));
$section->addInput(new Form_Input(
'passwordfld2',
'Confirmation',
'password'
))->setHelp('Select a new password');
$form->add($section);
print($form);
include("foot.inc");
|