[pbs-devel] [PATCH proxmox-backup] fix #3060:: improve get_owner error handling

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Nov 10 12:08:13 CET 2020


log invalid owners to system log, and continue with next group just as
if permission checks fail for the following operations:
- verify store with limited permissions
- list store groups
- list store snapshots

all other call sites either handle it correctly already (sync/pull), or
operate on a single group/snapshot and can bubble up the error.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/api2/admin/datastore.rs | 16 ++++++++++++++--
 src/backup/verify.rs        |  7 ++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index b051e8dd..8256f02f 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -187,7 +187,13 @@ fn list_groups(
         let group = info.backup_dir.group();
 
         let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0;
-        let owner = datastore.get_owner(group)?;
+        let owner = match datastore.get_owner(group) {
+            Ok(auth_id) => auth_id,
+            Err(err) => {
+                println!("Failed to get owner of group '{}' - {}", group, err);
+                continue;
+            },
+        };
         if !list_all && check_backup_owner(&owner, &auth_id).is_err() {
             continue;
         }
@@ -369,7 +375,13 @@ pub fn list_snapshots (
         }
 
         let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0;
-        let owner = datastore.get_owner(group)?;
+        let owner = match datastore.get_owner(group) {
+            Ok(auth_id) => auth_id,
+            Err(err) => {
+                println!("Failed to get owner of group '{}' - {}", group, err);
+                continue;
+            },
+        };
 
         if !list_all && check_backup_owner(&owner, &auth_id).is_err() {
             continue;
diff --git a/src/backup/verify.rs b/src/backup/verify.rs
index e0e28ee9..b5bb85fc 100644
--- a/src/backup/verify.rs
+++ b/src/backup/verify.rs
@@ -516,7 +516,12 @@ pub fn verify_all_backups(
                             && !owner.is_token()
                             && group_owner.user() == owner.user())
                 },
-                Err(_) => false,
+                Err(err) => {
+                    // intentionally not in task log
+                    // the task user might not be allowed to see this group!
+                    println!("Failed to get owner of group '{}' - {}", group, err);
+                    false
+                },
             }
         } else {
             true
-- 
2.20.1






More information about the pbs-devel mailing list