]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_cmds.c
07Jan06
[bacula/bacula] / bacula / src / dird / ua_cmds.c
index 692a7b69ed2b639c787d990c3c494a213b93e571..8a224741f7d8d185d7edfc9aa42d4855466db635 100644 (file)
@@ -7,7 +7,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -143,10 +143,16 @@ int do_a_command(UAContext *ua, const char *cmd)
       return 1;
    }
 
+   while (ua->jcr->storage->size()) {
+      ua->jcr->storage->remove(0);
+   }
+
    len = strlen(ua->argk[0]);
    for (i=0; i<comsize; i++) {     /* search for command */
       if (strncasecmp(ua->argk[0],  _(commands[i].key), len) == 0) {
-         if (!acl_access_ok(ua, Command_ACL, ua->argk[0], len)) {
+         /* Check if command permitted, but "quit" is always OK */
+         if (strcmp(ua->argk[0], "quit") != 0 &&
+             !acl_access_ok(ua, Command_ACL, ua->argk[0], len)) {
             break;
          }
          stat = (*commands[i].func)(ua, cmd);   /* go execute command */
@@ -396,12 +402,11 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
       /* Count Jobs running */
       foreach_jcr(jcr) {
          if (jcr->JobId == 0) {      /* this is us */
-            free_jcr(jcr);
             continue;
          }
-         free_jcr(jcr);
          njobs++;
       }
+      endeach_jcr(jcr);
 
       if (njobs == 0) {
          bsendmsg(ua, _("No Jobs running.\n"));
@@ -411,13 +416,12 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
       foreach_jcr(jcr) {
          char ed1[50];
          if (jcr->JobId == 0) {      /* this is us */
-            free_jcr(jcr);
             continue;
          }
          bsnprintf(buf, sizeof(buf), _("JobId=%s Job=%s"), edit_int64(jcr->JobId, ed1), jcr->Job);
          add_prompt(ua, buf);
-         free_jcr(jcr);
       }
+      endeach_jcr(jcr);
 
       if (do_prompt(ua, _("Job"),  _("Choose Job to cancel"), buf, sizeof(buf)) < 0) {
          return 1;
@@ -902,7 +906,6 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
    JOB *job = NULL;
    CLIENT *client = NULL;
    FILESET *fileset = NULL;
-   FILESET_DBR fsr;
    int listing = 0;
    char since[MAXSTRING];
    JCR *jcr = ua->jcr;
@@ -973,7 +976,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
    if (!get_or_create_client_record(jcr)) {
       return 1;
    }
-   if (!get_or_create_fileset_record(jcr, &fsr)) {
+   if (!get_or_create_fileset_record(jcr)) {
       return 1;
    }
 
@@ -1253,16 +1256,16 @@ static void do_mount_cmd(UAContext *ua, const char *command)
    }
    Dmsg2(120, "%s: %s\n", command, ua->UA_sock->msg);
 
-   store = get_storage_resource(ua, true/*use default*/);
+   store = get_storage_resource(ua, true/*arg is storage*/);
    if (!store) {
       return;
    }
-   drive = ua->int32_val;
+   set_storage(jcr, store);
+   drive = get_storage_drive(ua, store);
 
    Dmsg3(120, "Found storage, MediaType=%s DevName=%s drive=%d\n",
       store->media_type, store->dev_name(), drive);
 
-   set_storage(jcr, store);
    if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
       bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
       return;
@@ -1351,11 +1354,11 @@ int wait_cmd(UAContext *ua, const char *cmd)
       foreach_jcr(jcr) {
          if (jcr->JobId != 0) {
             running = true;
-            free_jcr(jcr);
             break;
          }
-         free_jcr(jcr);
       }
+      endeach_jcr(jcr);
+
       if (running) {
          bmicrosleep(1, 0);
       }