]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #9968 Adapt delete volume with restricted consoles
authorEric Bollengier <eric@baculasystems.com>
Tue, 21 Mar 2023 19:46:38 +0000 (20:46 +0100)
committerEric Bollengier <eric@baculasystems.com>
Tue, 2 May 2023 07:07:18 +0000 (09:07 +0200)
bacula/src/dird/ua_cmds.c

index a5bcbedb7865d22e0957edaf6d4ad2c21ceb41ed..3b0aaf37f95dc2d4b262493e9765221673dfdb4d 100644 (file)
@@ -2245,7 +2245,26 @@ static int delete_a_volume(UAContext *ua, MEDIA_DBR *mr)
          return 1;
       }
       if (lst.count) {
-         purge_jobs_from_catalog(ua, lst.list);
+         POOL_MEM tmp;
+         db_get_jobids(ua->jcr, ua->db, lst.list, tmp.handle(), false);
+         purge_jobs_from_catalog(ua, tmp.c_str());
+
+         /* We use ACLs filtering, so in this case we cannot delete blindly
+          * the jobs from the volume, we delete what we can, and if some
+          * records are still on the volume, we cannot delete it
+          */
+         if (strcmp(tmp.c_str(), lst.list) != 0) {
+            /* Not the same list, do extra check */
+            lst.count = 0;
+            if (!db_get_volume_jobids(ua->jcr, ua->db, mr, &lst)) {
+               ua->error_msg(_("Can't list jobs on this volume\n"));
+               return 1;
+            }
+            if (lst.count > 0) {
+               ua->error_msg(_("Can't purge all jobs from this volume\n"));
+               return 1;
+            }
+         }
       }
    }