Revision acd7e560
Added by Jim Pingle almost 6 years ago
src/usr/local/www/system_groupmanager.php | ||
---|---|---|
62 | 62 |
usort($a_group, "cpusercmp"); |
63 | 63 |
} |
64 | 64 |
|
65 |
if ($_POST['act'] == "delgroup") { |
|
65 |
/* |
|
66 |
* Check user privileges to test if the user is allowed to make changes. |
|
67 |
* Otherwise users can end up in an inconsistent state where some changes are |
|
68 |
* performed and others denied. See https://redmine.pfsense.org/issues/9259 |
|
69 |
*/ |
|
70 |
phpsession_begin(); |
|
71 |
$guiuser = getUserEntry($_SESSION['Username']); |
|
72 |
$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly")); |
|
73 |
phpsession_end(); |
|
74 |
|
|
75 |
if (!empty($_POST) && $read_only) { |
|
76 |
$input_errors = array(gettext("Insufficient privileges to make the requested change (read only).")); |
|
77 |
} |
|
78 |
|
|
79 |
if (($_POST['act'] == "delgroup") && !$read_only) { |
|
66 | 80 |
|
67 | 81 |
if (!isset($id) || !isset($_REQUEST['groupname']) || |
68 | 82 |
!isset($a_group[$id]) || |
... | ... | |
86 | 100 |
syslog($logging_level, "{$logging_prefix}: {$savemsg}"); |
87 | 101 |
} |
88 | 102 |
|
89 |
if ($_POST['act'] == "delpriv") {
|
|
103 |
if (($_POST['act'] == "delpriv") && !$read_only) {
|
|
90 | 104 |
|
91 | 105 |
if (!isset($id) || !isset($a_group[$id])) { |
92 | 106 |
pfSenseHeader("system_groupmanager.php"); |
... | ... | |
126 | 140 |
} |
127 | 141 |
} |
128 | 142 |
|
129 |
if (isset($_POST['dellall_x'])) { |
|
143 |
if (isset($_POST['dellall_x']) && !$read_only) {
|
|
130 | 144 |
|
131 | 145 |
$del_groups = $_POST['delete_check']; |
132 | 146 |
$deleted_groups = array(); |
... | ... | |
155 | 169 |
} |
156 | 170 |
} |
157 | 171 |
|
158 |
if (isset($_POST['save'])) { |
|
172 |
if (isset($_POST['save']) && !$read_only) {
|
|
159 | 173 |
unset($input_errors); |
160 | 174 |
$pconfig = $_POST; |
161 | 175 |
|
... | ... | |
265 | 279 |
} |
266 | 280 |
|
267 | 281 |
function build_priv_table() { |
268 |
global $a_group, $id; |
|
282 |
global $a_group, $id, $read_only;
|
|
269 | 283 |
|
270 | 284 |
$privhtml = '<div class="table-responsive">'; |
271 | 285 |
$privhtml .= '<table class="table table-striped table-hover table-condensed">'; |
... | ... | |
289 | 303 |
$user_has_root_priv = true; |
290 | 304 |
} |
291 | 305 |
$privhtml .= '</td>'; |
292 |
$privhtml .= '<td><a class="fa fa-trash" title="' . gettext('Delete Privilege') . '" href="system_groupmanager.php?act=delpriv&groupid=' . $id . '&privid=' . $i . '" usepost></a></td>'; |
|
306 |
if (!$read_only) { |
|
307 |
$privhtml .= '<td><a class="fa fa-trash" title="' . gettext('Delete Privilege') . '" href="system_groupmanager.php?act=delpriv&groupid=' . $id . '&privid=' . $i . '" usepost></a></td>'; |
|
308 |
} |
|
293 | 309 |
$privhtml .= '</tr>'; |
294 | 310 |
|
295 | 311 |
} |
... | ... | |
310 | 326 |
$privhtml .= '</div>'; |
311 | 327 |
|
312 | 328 |
$privhtml .= '<nav class="action-buttons">'; |
313 |
$privhtml .= '<a href="system_groupmanager_addprivs.php?groupid=' . $id . '" class="btn btn-success"><i class="fa fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>'; |
|
329 |
if (!$read_only) { |
|
330 |
$privhtml .= '<a href="system_groupmanager_addprivs.php?groupid=' . $id . '" class="btn btn-success"><i class="fa fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>'; |
|
331 |
} |
|
314 | 332 |
$privhtml .= '</nav>'; |
315 | 333 |
|
316 | 334 |
return($privhtml); |
... | ... | |
383 | 401 |
</td> |
384 | 402 |
<td> |
385 | 403 |
<a class="fa fa-pencil" title="<?=gettext("Edit group"); ?>" href="?act=edit&groupid=<?=$i?>"></a> |
386 |
<?php if ($group['scope'] != "system"): ?>
|
|
404 |
<?php if (($group['scope'] != "system") && !$read_only): ?>
|
|
387 | 405 |
<a class="fa fa-trash" title="<?=gettext("Delete group")?>" href="?act=delgroup&groupid=<?=$i?>&groupname=<?=$group['name']?>" usepost></a> |
388 | 406 |
<?php endif;?> |
389 | 407 |
</td> |
... | ... | |
398 | 416 |
</div> |
399 | 417 |
|
400 | 418 |
<nav class="action-buttons"> |
419 |
<?php if (!$read_only): ?> |
|
401 | 420 |
<a href="?act=new" class="btn btn-success btn-sm"> |
402 | 421 |
<i class="fa fa-plus icon-embed-btn"></i> |
403 | 422 |
<?=gettext("Add")?> |
404 | 423 |
</a> |
424 |
<?php endif; ?> |
|
405 | 425 |
</nav> |
406 | 426 |
<?php |
407 | 427 |
include('foot.inc'); |
src/usr/local/www/system_groupmanager_addprivs.php | ||
---|---|---|
61 | 61 |
$spriv_list = $priv_list; |
62 | 62 |
uasort($spriv_list, "compare_by_name"); |
63 | 63 |
|
64 |
if ($_POST['save']) { |
|
64 |
/* |
|
65 |
* Check user privileges to test if the user is allowed to make changes. |
|
66 |
* Otherwise users can end up in an inconsistent state where some changes are |
|
67 |
* performed and others denied. See https://redmine.pfsense.org/issues/9259 |
|
68 |
*/ |
|
69 |
phpsession_begin(); |
|
70 |
$guiuser = getUserEntry($_SESSION['Username']); |
|
71 |
$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly")); |
|
72 |
phpsession_end(); |
|
73 |
|
|
74 |
if (!empty($_POST) && $read_only) { |
|
75 |
$input_errors = array(gettext("Insufficient privileges to make the requested change (read only).")); |
|
76 |
} |
|
77 |
|
|
78 |
if ($_POST['save'] && !$read_only) { |
|
65 | 79 |
|
66 | 80 |
unset($input_errors); |
67 | 81 |
$pconfig = $_POST; |
src/usr/local/www/system_usermanager.php | ||
---|---|---|
83 | 83 |
$pconfig['disabled'] = isset($a_user[$id]['disabled']); |
84 | 84 |
} |
85 | 85 |
|
86 |
if ($_POST['act'] == "deluser") { |
|
86 |
/* |
|
87 |
* Check user privileges to test if the user is allowed to make changes. |
|
88 |
* Otherwise users can end up in an inconsistent state where some changes are |
|
89 |
* performed and others denied. See https://redmine.pfsense.org/issues/9259 |
|
90 |
*/ |
|
91 |
phpsession_begin(); |
|
92 |
$guiuser = getUserEntry($_SESSION['Username']); |
|
93 |
$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly")); |
|
94 |
phpsession_end(); |
|
95 |
|
|
96 |
if (!empty($_POST) && $read_only) { |
|
97 |
$input_errors = array(gettext("Insufficient privileges to make the requested change (read only).")); |
|
98 |
} |
|
99 |
|
|
100 |
if (($_POST['act'] == "deluser") && !$read_only) { |
|
87 | 101 |
|
88 | 102 |
if (!isset($_POST['username']) || !isset($a_user[$id]) || ($_POST['username'] != $a_user[$id]['name'])) { |
89 | 103 |
pfSenseHeader("system_usermanager.php"); |
... | ... | |
125 | 139 |
|
126 | 140 |
} |
127 | 141 |
|
128 |
if (isset($_POST['dellall'])) { |
|
142 |
if (isset($_POST['dellall']) && !$read_only) {
|
|
129 | 143 |
|
130 | 144 |
$del_users = $_POST['delete_check']; |
131 | 145 |
$deleted_users = array(); |
... | ... | |
155 | 169 |
} |
156 | 170 |
} |
157 | 171 |
|
158 |
if ($_POST['act'] == "delcert") {
|
|
172 |
if (($_POST['act'] == "delcert") && !$read_only) {
|
|
159 | 173 |
|
160 | 174 |
if (!$a_user[$id]) { |
161 | 175 |
pfSenseHeader("system_usermanager.php"); |
... | ... | |
171 | 185 |
$_POST['act'] = "edit"; |
172 | 186 |
} |
173 | 187 |
|
174 |
if ($_POST['act'] == "delprivid") {
|
|
188 |
if (($_POST['act'] == "delprivid") && !$read_only) {
|
|
175 | 189 |
$privdeleted = $priv_list[$a_user[$id]['priv'][$_POST['privid']]]['name']; |
176 | 190 |
unset($a_user[$id]['priv'][$_POST['privid']]); |
177 | 191 |
local_user_set($a_user[$id]); |
... | ... | |
181 | 195 |
$_POST['act'] = "edit"; |
182 | 196 |
} |
183 | 197 |
|
184 |
if ($_POST['save']) { |
|
198 |
if ($_POST['save'] && !$read_only) {
|
|
185 | 199 |
unset($input_errors); |
186 | 200 |
$pconfig = $_POST; |
187 | 201 |
|
... | ... | |
475 | 489 |
} |
476 | 490 |
|
477 | 491 |
function build_priv_table() { |
478 |
global $a_user, $id; |
|
492 |
global $a_user, $id, $read_only;
|
|
479 | 493 |
|
480 | 494 |
$privhtml = '<div class="table-responsive">'; |
481 | 495 |
$privhtml .= '<table class="table table-striped table-hover table-condensed">'; |
... | ... | |
508 | 522 |
} |
509 | 523 |
$privhtml .= '</td>'; |
510 | 524 |
$privhtml .= '<td>'; |
511 |
if (!$group) { |
|
525 |
if (!$group && !$read_only) {
|
|
512 | 526 |
$privhtml .= '<a class="fa fa-trash no-confirm icon-pointer" title="' . gettext('Delete Privilege') . '" id="delprivid' . $i . '"></a>'; |
513 | 527 |
} |
514 | 528 |
|
... | ... | |
536 | 550 |
$privhtml .= '</div>'; |
537 | 551 |
|
538 | 552 |
$privhtml .= '<nav class="action-buttons">'; |
539 |
$privhtml .= '<a href="system_usermanager_addprivs.php?userid=' . $id . '" class="btn btn-success"><i class="fa fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>'; |
|
553 |
if (!$read_only) { |
|
554 |
$privhtml .= '<a href="system_usermanager_addprivs.php?userid=' . $id . '" class="btn btn-success"><i class="fa fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>'; |
|
555 |
} |
|
540 | 556 |
$privhtml .= '</nav>'; |
541 | 557 |
|
542 | 558 |
return($privhtml); |
543 | 559 |
} |
544 | 560 |
|
545 | 561 |
function build_cert_table() { |
546 |
global $a_user, $id; |
|
562 |
global $a_user, $id, $read_only;
|
|
547 | 563 |
|
548 | 564 |
$certhtml = '<div class="table-responsive">'; |
549 | 565 |
$certhtml .= '<table class="table table-striped table-hover table-condensed">'; |
... | ... | |
568 | 584 |
$certhtml .= '<td>' . htmlspecialchars($cert['descr']) . $revokedstr . '</td>'; |
569 | 585 |
$certhtml .= '<td>' . htmlspecialchars($ca['descr']) . '</td>'; |
570 | 586 |
$certhtml .= '<td>'; |
571 |
$certhtml .= '<a id="delcert' . $i .'" class="fa fa-trash no-confirm icon-pointer" title="'; |
|
572 |
$certhtml .= gettext('Remove this certificate association? (Certificate will not be deleted)') . '"></a>'; |
|
587 |
if (!$read_only) { |
|
588 |
$certhtml .= '<a id="delcert' . $i .'" class="fa fa-trash no-confirm icon-pointer" title="'; |
|
589 |
$certhtml .= gettext('Remove this certificate association? (Certificate will not be deleted)') . '"></a>'; |
|
590 |
} |
|
573 | 591 |
$certhtml .= '</td>'; |
574 | 592 |
$certhtml .= '</tr>'; |
575 | 593 |
$i++; |
... | ... | |
582 | 600 |
$certhtml .= '</div>'; |
583 | 601 |
|
584 | 602 |
$certhtml .= '<nav class="action-buttons">'; |
585 |
$certhtml .= '<a href="system_certmanager.php?act=new&userid=' . $id . '" class="btn btn-success"><i class="fa fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>'; |
|
603 |
if (!$read_only) { |
|
604 |
$certhtml .= '<a href="system_certmanager.php?act=new&userid=' . $id . '" class="btn btn-success"><i class="fa fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>'; |
|
605 |
} |
|
586 | 606 |
$certhtml .= '</nav>'; |
587 | 607 |
|
588 | 608 |
return($certhtml); |
... | ... | |
659 | 679 |
<td><?=implode(",", local_user_get_groups($userent))?></td> |
660 | 680 |
<td> |
661 | 681 |
<a class="fa fa-pencil" title="<?=gettext("Edit user"); ?>" href="?act=edit&userid=<?=$i?>"></a> |
662 |
<?php if (($userent['scope'] != "system") && ($userent['name'] != $_SESSION['Username'])): ?> |
|
682 |
<?php if (($userent['scope'] != "system") && ($userent['name'] != $_SESSION['Username']) && !$read_only): ?>
|
|
663 | 683 |
<a class="fa fa-trash" title="<?=gettext("Delete user")?>" href="?act=deluser&userid=<?=$i?>&username=<?=$userent['name']?>" usepost></a> |
664 | 684 |
<?php endif; ?> |
665 | 685 |
</td> |
... | ... | |
671 | 691 |
</div> |
672 | 692 |
</div> |
673 | 693 |
<nav class="action-buttons"> |
694 |
<?php if (!$read_only): ?> |
|
695 |
|
|
674 | 696 |
<a href="?act=new" class="btn btn-sm btn-success"> |
675 | 697 |
<i class="fa fa-plus icon-embed-btn"></i> |
676 | 698 |
<?=gettext("Add")?> |
... | ... | |
680 | 702 |
<i class="fa fa-trash icon-embed-btn"></i> |
681 | 703 |
<?=gettext("Delete")?> |
682 | 704 |
</button> |
705 |
<?php endif; ?> |
|
683 | 706 |
|
684 | 707 |
</nav> |
685 | 708 |
</form> |
src/usr/local/www/system_usermanager_addprivs.php | ||
---|---|---|
58 | 58 |
$spriv_list = $priv_list; |
59 | 59 |
uasort($spriv_list, "compare_by_name"); |
60 | 60 |
|
61 |
if ($_POST['save']) { |
|
61 |
/* |
|
62 |
* Check user privileges to test if the user is allowed to make changes. |
|
63 |
* Otherwise users can end up in an inconsistent state where some changes are |
|
64 |
* performed and others denied. See https://redmine.pfsense.org/issues/9259 |
|
65 |
*/ |
|
66 |
phpsession_begin(); |
|
67 |
$guiuser = getUserEntry($_SESSION['Username']); |
|
68 |
$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly")); |
|
69 |
phpsession_end(); |
|
70 |
|
|
71 |
if (!empty($_POST) && $read_only) { |
|
72 |
$input_errors = array(gettext("Insufficient privileges to make the requested change (read only).")); |
|
73 |
} |
|
74 |
|
|
75 |
if ($_POST['save'] && !$read_only) { |
|
62 | 76 |
unset($input_errors); |
63 | 77 |
$pconfig = $_POST; |
64 | 78 |
|
Also available in: Unified diff
User & Group Manager: Improve Deny Config Write Handling. Fixes #9259
Previously it only denied the config write but some OS operations were
performed.
option to perform those actions (but are still denied if they submit the
form through other means)