From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager v2 2/2] server: api: pve firewall: fix permission check
Date: Mon, 31 Aug 2026 09:08:48 +0200 [thread overview]
Message-ID: <20260831070855.568455-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260831070855.568455-1-d.csapak@proxmox.com>
This is the api call for the overall firewall status, not a specific
remote, so there isn't a 'remote' parameter to limit us to.
Instead, check the users permission against /resource/{resource} for
each remote and only show those where the user has permission.
This fixes a 403 error on the firewall panel for non root@pam users.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
server/src/api/pve/firewall.rs | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/server/src/api/pve/firewall.rs b/server/src/api/pve/firewall.rs
index 5a6a209e..ceddf205 100644
--- a/server/src/api/pve/firewall.rs
+++ b/server/src/api/pve/firewall.rs
@@ -1,8 +1,10 @@
use std::collections::HashMap;
use std::sync::Arc;
-use anyhow::Error;
+use anyhow::{Context, Error};
+use proxmox_access_control::CachedUserInfo;
+use proxmox_auth_api::types::Authid;
use proxmox_router::{Permission, Router, RpcEnvironment, SubdirMap, list_subdirs_api_method};
use proxmox_schema::api;
use proxmox_sortable_macro::sortable;
@@ -242,16 +244,26 @@ async fn fetch_node_firewall_status(
items: { type: RemoteFirewallStatus },
},
access: {
- permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false),
+ permission: &Permission::Anybody,
+ description: "A user needs `Resource.Audit` privileges on /resource/{remote}."
},
)]
/// Get firewall status of all PVE remotes.
pub async fn pve_firewall_status(
- _rpcenv: &mut dyn RpcEnvironment,
+ rpcenv: &mut dyn RpcEnvironment,
) -> Result<Vec<RemoteFirewallStatus>, Error> {
+ let auth_id: Authid = rpcenv
+ .get_auth_id()
+ .context("no authid available")?
+ .parse()?;
+ let user_info = CachedUserInfo::new()?;
+
let pve_remotes: Vec<Remote> = crate::api::remotes::RemoteIterator::new()?
.remote_type(pdm_api_types::remotes::RemoteType::Pve)
.into_remotes()
+ .filter(|remote| {
+ user_info.lookup_privs(&auth_id, &["resource", &remote.id]) & PRIV_RESOURCE_AUDIT != 0
+ })
.collect();
if pve_remotes.is_empty() {
--
2.47.3
next prev parent reply other threads:[~2026-08-31 7:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 7:08 [PATCH datacenter-manager/proxmox v2 0/2] check privilege paths during compilation Dominik Csapak
2026-08-31 7:08 ` [PATCH proxmox v2 1/2] router: compile time check privilege path parameters for existence Dominik Csapak
2026-08-31 7:08 ` Dominik Csapak [this message]
2026-08-31 7:58 ` partially-applied: [PATCH datacenter-manager v2 2/2] server: api: pve firewall: fix permission check Lukas Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260831070855.568455-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox