all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] datastore: cleanup newly created group dir if setting owner failed
Date: Wed,  6 Aug 2025 12:51:28 +0200	[thread overview]
Message-ID: <20250806105128.401379-1-c.ebner@proxmox.com> (raw)

Setting the owner might fail for various reasons, e.g. the user might
run out of space or the upload to the backend might fail in case of
datastores backed by s3. Currently, this would result in the newly
created but still empty group directory to be left behind, no owner
file being present. That will however cause issues as the owner check
is performed if the group folder is present, expecting the owner file
to be present.

To fix this, simply clean up the newly created backup group directory
in case setting the owner failed.

Reported-by: Daniel Kral <d.kral@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-datastore/src/datastore.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index f039bd9a9..7cf020fc0 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1008,7 +1008,10 @@ impl DataStore {
                 let guard = backup_group.lock().with_context(|| {
                     format!("while creating new locked backup group '{backup_group:?}'")
                 })?;
-                self.set_owner(ns, backup_group.group(), auth_id, false)?;
+                if let Err(err) = self.set_owner(ns, backup_group.group(), auth_id, false) {
+                    let _ = std::fs::remove_dir(&full_path);
+                    return Err(err);
+                }
                 let owner = self.get_owner(ns, backup_group.group())?; // just to be sure
                 Ok((owner, guard))
             }
-- 
2.47.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


             reply	other threads:[~2025-08-06 10:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 10:51 Christian Ebner [this message]
2025-08-11 11:52 ` [pbs-devel] applied: " 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=20250806105128.401379-1-c.ebner@proxmox.com \
    --to=c.ebner@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