[pbs-devel] [PATCH proxmox-backup] datastore: cleanup newly created group dir if setting owner failed

Christian Ebner c.ebner at proxmox.com
Wed Aug 6 12:51:28 CEST 2025


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 at proxmox.com>
Signed-off-by: Christian Ebner <c.ebner at 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





More information about the pbs-devel mailing list