all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup] cli: fix move-namespace and move-group running as root
Date: Fri, 24 Apr 2026 13:20:01 +0200	[thread overview]
Message-ID: <20260424112001.206897-1-h.laimer@proxmox.com> (raw)

The 'move-namespace' and 'move-group' commands of called their api
handler in-process via the CLI's rpcenv, so the worker task ran inside
the manager process and wrote into the datastore as root. Route them
through the api with connect_to_localhost() instead.

Reported-by: Michael Köppl <m.koeppl@proxmox.com>
Fixes: 4d74e20d ("cli: add move-namespace and move-group commands")
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 src/bin/proxmox_backup_manager/datastore.rs | 43 +++++++++++----------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs
index 0ad97fda..738d0fa5 100644
--- a/src/bin/proxmox_backup_manager/datastore.rs
+++ b/src/bin/proxmox_backup_manager/datastore.rs
@@ -325,7 +325,6 @@ async fn uuid_mount(mut param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Resul
 }
 
 #[api(
-    protected: true,
     input: {
         properties: {
             store: {
@@ -356,28 +355,27 @@ async fn uuid_mount(mut param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Resul
                     namespace, merge snapshots into it. Requires matching ownership and \
                     non-overlapping snapshot times.",
             },
+            "output-format": {
+                schema: OUTPUT_FORMAT,
+                optional: true,
+            },
         },
     },
 )]
 /// Move a backup namespace to a new location within the same datastore.
-async fn cli_move_namespace(
-    mut param: Value,
-    rpcenv: &mut dyn RpcEnvironment,
-) -> Result<(), Error> {
-    param["node"] = "localhost".into();
+async fn cli_move_namespace(store: String, mut param: Value) -> Result<(), Error> {
+    let output_format = extract_output_format(&mut param);
 
-    let info = &api2::admin::namespace::API_METHOD_MOVE_NAMESPACE;
-    let result = match info.handler {
-        ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
-        _ => unreachable!(),
-    };
+    let client = connect_to_localhost()?;
+    let path = format!("api2/json/admin/datastore/{store}/move-namespace");
+    let result = client.post(&path, Some(param)).await?;
+
+    view_task_result(&client, result, &output_format).await?;
 
-    crate::wait_for_local_worker(result.as_str().unwrap()).await?;
     Ok(())
 }
 
 #[api(
-    protected: true,
     input: {
         properties: {
             store: {
@@ -401,20 +399,23 @@ async fn cli_move_namespace(
                     snapshots into it. Requires matching ownership and non-overlapping \
                     snapshot times.",
             },
+            "output-format": {
+                schema: OUTPUT_FORMAT,
+                optional: true,
+            },
         },
     },
 )]
 /// Move a backup group to a different namespace within the same datastore.
-async fn cli_move_group(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
-    param["node"] = "localhost".into();
+async fn cli_move_group(store: String, mut param: Value) -> Result<(), Error> {
+    let output_format = extract_output_format(&mut param);
 
-    let info = &api2::admin::datastore::API_METHOD_MOVE_GROUP;
-    let result = match info.handler {
-        ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
-        _ => unreachable!(),
-    };
+    let client = connect_to_localhost()?;
+    let path = format!("api2/json/admin/datastore/{store}/move-group");
+    let result = client.post(&path, Some(param)).await?;
+
+    view_task_result(&client, result, &output_format).await?;
 
-    crate::wait_for_local_worker(result.as_str().unwrap()).await?;
     Ok(())
 }
 
-- 
2.47.3





             reply	other threads:[~2026-04-24 11:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 11:20 Hannes Laimer [this message]
2026-04-24 16:49 ` applied: [PATCH proxmox-backup] cli: fix move-namespace and move-group running as root Thomas Lamprecht

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=20260424112001.206897-1-h.laimer@proxmox.com \
    --to=h.laimer@proxmox.com \
    --cc=pbs-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal