]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_cmds.c
- Fix the block listing bug pointed out by Arno.
[bacula/bacula] / bacula / src / dird / ua_cmds.c
index 6ab82d7ff22b81203aab62115cc374acb29f66de..1ecc80c8193ae11af06a331d56e2b02be8bcbade 100644 (file)
@@ -1237,9 +1237,11 @@ static void do_job_delete(UAContext *ua, JobId_t JobId)
 
    Mmsg(query, "DELETE FROM Job WHERE JobId=%s", edit_int64(JobId, ed1));
    db_sql_query(ua->db, query, NULL, (void *)NULL);
-   Mmsg(query, "DELETE FROM File WHERE JobId=%s", edit_int64(JobId, ed1));
+   Mmsg(query, "DELETE FROM MAC WHERE JobId=%s", ed1);
    db_sql_query(ua->db, query, NULL, (void *)NULL);
-   Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%s", edit_int64(JobId, ed1));
+   Mmsg(query, "DELETE FROM File WHERE JobId=%s", ed1);
+   db_sql_query(ua->db, query, NULL, (void *)NULL);
+   Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%s", ed1);
    db_sql_query(ua->db, query, NULL, (void *)NULL);
    free_pool_memory(query);
    bsendmsg(ua, _("Job %s and associated records deleted from the catalog.\n"), edit_int64(JobId, ed1));
@@ -1447,10 +1449,10 @@ static int version_cmd(UAContext *ua, const char *cmd)
  * a "use catalog xxx" command, we simply find the first
  * catalog resource and open it.
  */
-int open_db(UAContext *ua)
+bool open_db(UAContext *ua)
 {
    if (ua->db) {
-      return 1;
+      return true;
    }
    if (!ua->catalog) {
       LockRes();
@@ -1458,7 +1460,11 @@ int open_db(UAContext *ua)
       UnlockRes();
       if (!ua->catalog) {
          bsendmsg(ua, _("Could not find a Catalog resource\n"));
-         return 0;
+         return false;
+      } else if (!acl_access_ok(ua, Catalog_ACL, ua->catalog->hdr.name)) {
+         bsendmsg(ua, _("You must specify a \"use <catalog-name>\" command before continuing.\n"));
+         ua->catalog = NULL;
+         return false;
       } else {
          bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"),
             ua->catalog->hdr.name, ua->catalog->db_name);
@@ -1479,11 +1485,11 @@ int open_db(UAContext *ua)
          bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       close_db(ua);
-      return 0;
+      return false;
    }
    ua->jcr->db = ua->db;
    Dmsg1(150, "DB %s opened\n", ua->catalog->db_name);
-   return 1;
+   return true;
 }
 
 void close_db(UAContext *ua)