From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 7/9] api: replication: fix usages of RPCEnvironment check method
Date: Fri, 18 Jul 2025 11:30:13 +0200 [thread overview]
Message-ID: <20250718093024.55570-8-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250718093024.55570-1-f.ebner@proxmox.com>
The RPCEnvironment's check() method is used without $noerr, so it will
already fail and raise a permission exception when the privilege is
missing.
The usage in the job_status endpoint can be simplified, as the
raise_perm_exc() there is dead code.
The other two usages actually want to set the $noerr argument. In
particular, this makes it possible to use the 'status' endpoint, when
the user does not have VM.Audit for all guests with a replication job
and to read the log with only Sys.Audit privilege on the node. Both
would previously fail, because the check for VM.Audit would raise an
exception already.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
PVE/API2/Replication.pm | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/PVE/API2/Replication.pm b/PVE/API2/Replication.pm
index 7d048f53..c8416239 100644
--- a/PVE/API2/Replication.pm
+++ b/PVE/API2/Replication.pm
@@ -236,7 +236,7 @@ __PACKAGE__->register_method({
my $data = $extract_job_status->($jobs->{$id}, $id);
my $guest = $data->{guest};
next if defined($param->{guest}) && $guest != $param->{guest};
- next if !$rpcenv->check($authuser, "/vms/$guest", ['VM.Audit']);
+ next if !$rpcenv->check($authuser, "/vms/$guest", ['VM.Audit'], 1);
push @$res, $data;
}
@@ -311,7 +311,7 @@ __PACKAGE__->register_method({
my $data = $extract_job_status->($jobcfg, $jobid);
my $guest = $data->{guest};
- raise_perm_exc() if !$rpcenv->check($authuser, "/vms/$guest", ['VM.Audit']);
+ $rpcenv->check($authuser, "/vms/$guest", ['VM.Audit']);
return $data;
},
@@ -381,8 +381,8 @@ __PACKAGE__->register_method({
my $vmid = $data->{guest};
raise_perm_exc()
if (!(
- $rpcenv->check($authuser, "/vms/$vmid", ['VM.Audit'])
- || $rpcenv->check($authuser, "/nodes/$node", ['Sys.Audit'])
+ $rpcenv->check($authuser, "/vms/$vmid", ['VM.Audit'], 1)
+ || $rpcenv->check($authuser, "/nodes/$node", ['Sys.Audit'], 1)
));
my ($count, $lines) =
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-07-18 9:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 9:30 [pve-devel] [PATCH access-control/manager/docs 0/9] close #2809: replication: add dedicated VM.Replicate privilege Fiona Ebner
2025-07-18 9:30 ` [pve-devel] [PATCH access-control 1/9] add " Fiona Ebner
2025-07-18 9:30 ` [pve-devel] [PATCH manager 2/9] api: replication: code style: order module imports Fiona Ebner
2025-07-18 9:30 ` [pve-devel] [PATCH manager 3/9] api: replication: add missing " Fiona Ebner
2025-07-18 9:30 ` [pve-devel] [PATCH manager 4/9] api: replication config: code style: order " Fiona Ebner
2025-07-18 9:30 ` [pve-devel] [PATCH manager 5/9] api: replication config: add missing " Fiona Ebner
2025-07-18 9:30 ` [pve-devel] [PATCH manager 6/9] api: replication config: remove dead code Fiona Ebner
2025-07-18 9:30 ` Fiona Ebner [this message]
2025-07-18 9:30 ` [pve-devel] [PATCH manager 8/9] close #2809: api: replication: use VM.Replicate privilege Fiona Ebner
2025-07-18 9:30 ` [pve-devel] [PATCH docs 9/9] user management: privileges: document " Fiona Ebner
2025-07-30 13:33 ` [pve-devel] applied-series: [PATCH access-control/manager/docs 0/9] close #2809: replication: add dedicated " Fabian Grünbichler
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=20250718093024.55570-8-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-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