diff --git a/src/usr/local/www/system_groupmanager.php b/src/usr/local/www/system_groupmanager.php
index 4463ed4d66..ec8d9cc1d5 100644
--- a/src/usr/local/www/system_groupmanager.php
+++ b/src/usr/local/www/system_groupmanager.php
@@ -62,7 +62,21 @@ function admin_groups_sort() {
usort($a_group, "cpusercmp");
}
-if ($_POST['act'] == "delgroup") {
+/*
+ * Check user privileges to test if the user is allowed to make changes.
+ * Otherwise users can end up in an inconsistent state where some changes are
+ * performed and others denied. See https://redmine.pfsense.org/issues/9259
+ */
+phpsession_begin();
+$guiuser = getUserEntry($_SESSION['Username']);
+$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly"));
+phpsession_end();
+
+if (!empty($_POST) && $read_only) {
+ $input_errors = array(gettext("Insufficient privileges to make the requested change (read only)."));
+}
+
+if (($_POST['act'] == "delgroup") && !$read_only) {
if (!isset($id) || !isset($_REQUEST['groupname']) ||
!isset($a_group[$id]) ||
@@ -86,7 +100,7 @@ if ($_POST['act'] == "delgroup") {
syslog($logging_level, "{$logging_prefix}: {$savemsg}");
}
-if ($_POST['act'] == "delpriv") {
+if (($_POST['act'] == "delpriv") && !$read_only) {
if (!isset($id) || !isset($a_group[$id])) {
pfSenseHeader("system_groupmanager.php");
@@ -126,7 +140,7 @@ if ($act == "edit") {
}
}
-if (isset($_POST['dellall_x'])) {
+if (isset($_POST['dellall_x']) && !$read_only) {
$del_groups = $_POST['delete_check'];
$deleted_groups = array();
@@ -155,7 +169,7 @@ if (isset($_POST['dellall_x'])) {
}
}
-if (isset($_POST['save'])) {
+if (isset($_POST['save']) && !$read_only) {
unset($input_errors);
$pconfig = $_POST;
@@ -265,7 +279,7 @@ if (isset($_POST['save'])) {
}
function build_priv_table() {
- global $a_group, $id;
+ global $a_group, $id, $read_only;
$privhtml = '
';
$privhtml .= '
';
@@ -289,7 +303,9 @@ function build_priv_table() {
$user_has_root_priv = true;
}
$privhtml .= '';
- $privhtml .= ' ';
+ if (!$read_only) {
+ $privhtml .= ' ';
+ }
$privhtml .= '';
}
@@ -310,7 +326,9 @@ function build_priv_table() {
$privhtml .= '';
$privhtml .= '';
- $privhtml .= ' ' . gettext("Add") . ' ';
+ if (!$read_only) {
+ $privhtml .= ' ' . gettext("Add") . ' ';
+ }
$privhtml .= ' ';
return($privhtml);
@@ -383,7 +401,7 @@ if (!($act == "new" || $act == "edit")) {
" href="?act=edit&groupid==$i?>">
-
+
" href="?act=delgroup&groupid==$i?>&groupname==$group['name']?>" usepost>
@@ -398,10 +416,12 @@ if (!($act == "new" || $act == "edit")) {
+
=gettext("Add")?>
+
';
$privhtml .= '';
@@ -508,7 +522,7 @@ function build_priv_table() {
}
$privhtml .= '';
$privhtml .= '';
- if (!$group) {
+ if (!$group && !$read_only) {
$privhtml .= ' ';
}
@@ -536,14 +550,16 @@ function build_priv_table() {
$privhtml .= '';
$privhtml .= '';
- $privhtml .= ' ' . gettext("Add") . ' ';
+ if (!$read_only) {
+ $privhtml .= ' ' . gettext("Add") . ' ';
+ }
$privhtml .= ' ';
return($privhtml);
}
function build_cert_table() {
- global $a_user, $id;
+ global $a_user, $id, $read_only;
$certhtml = '';
$certhtml .= '
';
@@ -568,8 +584,10 @@ function build_cert_table() {
$certhtml .= '' . htmlspecialchars($cert['descr']) . $revokedstr . ' ';
$certhtml .= '' . htmlspecialchars($ca['descr']) . ' ';
$certhtml .= '';
- $certhtml .= ' ';
+ if (!$read_only) {
+ $certhtml .= ' ';
+ }
$certhtml .= ' ';
$certhtml .= '';
$i++;
@@ -582,7 +600,9 @@ function build_cert_table() {
$certhtml .= '';
$certhtml .= '';
- $certhtml .= ' ' . gettext("Add") . ' ';
+ if (!$read_only) {
+ $certhtml .= ' ' . gettext("Add") . ' ';
+ }
$certhtml .= ' ';
return($certhtml);
@@ -659,7 +679,7 @@ foreach ($a_user as $i => $userent):
=implode(",", local_user_get_groups($userent))?>
" href="?act=edit&userid==$i?>">
-
+
" href="?act=deluser&userid==$i?>&username==$userent['name']?>" usepost>
@@ -671,6 +691,8 @@ foreach ($a_user as $i => $userent):
+
+
=gettext("Add")?>
@@ -680,6 +702,7 @@ foreach ($a_user as $i => $userent):
=gettext("Delete")?>
+
diff --git a/src/usr/local/www/system_usermanager_addprivs.php b/src/usr/local/www/system_usermanager_addprivs.php
index af8596e19f..611263ef1c 100644
--- a/src/usr/local/www/system_usermanager_addprivs.php
+++ b/src/usr/local/www/system_usermanager_addprivs.php
@@ -58,7 +58,21 @@ if (!is_array($a_user['priv'])) {
$spriv_list = $priv_list;
uasort($spriv_list, "compare_by_name");
-if ($_POST['save']) {
+/*
+ * Check user privileges to test if the user is allowed to make changes.
+ * Otherwise users can end up in an inconsistent state where some changes are
+ * performed and others denied. See https://redmine.pfsense.org/issues/9259
+ */
+phpsession_begin();
+$guiuser = getUserEntry($_SESSION['Username']);
+$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly"));
+phpsession_end();
+
+if (!empty($_POST) && $read_only) {
+ $input_errors = array(gettext("Insufficient privileges to make the requested change (read only)."));
+}
+
+if ($_POST['save'] && !$read_only) {
unset($input_errors);
$pconfig = $_POST;