From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 8/9] close #2809: api: replication: use VM.Replicate privilege
Date: Fri, 18 Jul 2025 11:30:14 +0200 [thread overview]
Message-ID: <20250718093024.55570-9-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250718093024.55570-1-f.ebner@proxmox.com>
Currently, guest replication is guarded with Datastore.Allocate on
'/storage', which is rather surprising. One could require
Datastore.AllocateSpace on all involved storages, but having a
dedicated privilege like for other VM operations like migration and
snapshot seems to be more natural.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
PVE/API2/Replication.pm | 8 +++++++-
PVE/API2/ReplicationConfig.pm | 25 +++++++++++++++++++++----
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/PVE/API2/Replication.pm b/PVE/API2/Replication.pm
index c8416239..c23649f3 100644
--- a/PVE/API2/Replication.pm
+++ b/PVE/API2/Replication.pm
@@ -402,7 +402,8 @@ __PACKAGE__->register_method({
proxyto => 'node',
protected => 1,
permissions => {
- check => ['perm', '/storage', ['Datastore.Allocate']],
+ description => "Requires the VM.Replicate permission on /vms/<vmid>.",
+ user => 'all',
},
parameters => {
additionalProperties => 0,
@@ -417,7 +418,12 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
my $jobid = $param->{id};
+ my ($vmid) = PVE::ReplicationConfig::parse_replication_job_id($jobid);
+ $rpcenv->check($authuser, "/vms/$vmid", ['VM.Replicate']);
my $cfg = PVE::ReplicationConfig->new();
my $jobcfg = $cfg->{ids}->{$jobid};
diff --git a/PVE/API2/ReplicationConfig.pm b/PVE/API2/ReplicationConfig.pm
index 1c6ac765..307ebe69 100644
--- a/PVE/API2/ReplicationConfig.pm
+++ b/PVE/API2/ReplicationConfig.pm
@@ -107,19 +107,24 @@ __PACKAGE__->register_method({
method => 'POST',
description => "Create a new replication job",
permissions => {
- check => ['perm', '/storage', ['Datastore.Allocate']],
+ description => "Requires the VM.Replicate permission on /vms/<vmid>.",
+ user => 'all',
},
parameters => PVE::ReplicationConfig->createSchema(),
returns => { type => 'null' },
code => sub {
my ($param) = @_;
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
my $type = extract_param($param, 'type');
my $plugin = PVE::ReplicationConfig->lookup($type);
my $id = extract_param($param, 'id');
# extract guest ID from job ID
my ($guest) = PVE::ReplicationConfig::parse_replication_job_id($id);
+ $rpcenv->check($authuser, "/vms/$guest", ['VM.Replicate']);
my $nodelist = PVE::Cluster::get_members();
my $vmlist = PVE::Cluster::get_vmlist();
@@ -176,17 +181,24 @@ __PACKAGE__->register_method({
method => 'PUT',
description => "Update replication job configuration.",
permissions => {
- check => ['perm', '/storage', ['Datastore.Allocate']],
+ description => "Requires the VM.Replicate permission on /vms/<vmid>.",
+ user => 'all',
},
parameters => PVE::ReplicationConfig->updateSchema(),
returns => { type => 'null' },
code => sub {
my ($param) = @_;
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
my $id = extract_param($param, 'id');
my $digest = extract_param($param, 'digest');
my $delete = extract_param($param, 'delete');
+ my ($vmid) = PVE::ReplicationConfig::parse_replication_job_id($id);
+ $rpcenv->check($authuser, "/vms/$vmid", ['VM.Replicate']);
+
my $code = sub {
my $cfg = PVE::ReplicationConfig->new();
@@ -231,7 +243,8 @@ __PACKAGE__->register_method({
method => 'DELETE',
description => "Mark replication job for removal.",
permissions => {
- check => ['perm', '/storage', ['Datastore.Allocate']],
+ description => "Requires the VM.Replicate permission on /vms/<vmid>.",
+ user => 'all',
},
parameters => {
additionalProperties => 0,
@@ -256,11 +269,15 @@ __PACKAGE__->register_method({
my ($param) = @_;
my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
+ my $id = extract_param($param, 'id');
+ my ($vmid) = PVE::ReplicationConfig::parse_replication_job_id($id);
+ $rpcenv->check($authuser, "/vms/$vmid", ['VM.Replicate']);
my $code = sub {
my $cfg = PVE::ReplicationConfig->new();
- my $id = $param->{id};
if ($param->{force}) {
raise_param_exc({ 'keep' => "conflicts with parameter 'force'" })
if $param->{keep};
--
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 " 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 ` [pve-devel] [PATCH manager 7/9] api: replication: fix usages of RPCEnvironment check method Fiona Ebner
2025-07-18 9:30 ` Fiona Ebner [this message]
2025-07-18 9:30 ` [pve-devel] [PATCH docs 9/9] user management: privileges: document VM.Replicate privilege 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-9-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