]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_run.c
kes Fix %g in filename returned by SQL for browse tree reported by
[bacula/bacula] / bacula / src / dird / ua_run.c
index a83145f6153d1073352d548f767735db9293b752..5baf9d9c6a03e182defef81187f8da33c5b9726d 100644 (file)
@@ -7,8 +7,8 @@
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
    modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -90,7 +90,7 @@ extern struct s_kw ReplaceOptions[];
  */
 int run_cmd(UAContext *ua, const char *cmd)
 {
-   JCR *jcr;
+   JCR *jcr = NULL;
    run_ctx rc;
    int i, opt;
 
@@ -102,14 +102,22 @@ int run_cmd(UAContext *ua, const char *cmd)
       return 0;
    }
 
+   if (find_arg(ua, NT_("fdcalled")) > 0) {
+      jcr->file_bsock = dup_bsock(ua->UA_sock);
+      ua->quit = true;
+   }
+
+try_again:
    /*
     * Create JCR to run job.  NOTE!!! after this point, free_jcr()
     *  before returning.
     */
-   jcr = new_jcr(sizeof(JCR), dird_free_jcr);
-   set_jcr_defaults(jcr, rc.job);
-   jcr->unlink_bsr = ua->jcr->unlink_bsr;    /* copy unlink flag from caller */
-   ua->jcr->unlink_bsr = false;
+   if (!jcr) {
+      jcr = new_jcr(sizeof(JCR), dird_free_jcr);
+      set_jcr_defaults(jcr, rc.job);
+      jcr->unlink_bsr = ua->jcr->unlink_bsr;    /* copy unlink flag from caller */
+      ua->jcr->unlink_bsr = false;
+   }
 
    jcr->verify_job = rc.verify_job;
    jcr->previous_job = rc.previous_job;
@@ -119,7 +127,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    pm_strcpy(jcr->client_name, rc.client->name());
    jcr->fileset = rc.fileset;
    jcr->ExpectedFiles = rc.files;
-   if (rc.catalog != NULL) {
+   if (rc.catalog) {
       jcr->catalog = rc.catalog;
    }
    if (rc.where) {
@@ -127,6 +135,7 @@ int run_cmd(UAContext *ua, const char *cmd)
          free(jcr->where);
       }
       jcr->where = bstrdup(rc.where);
+      rc.where = NULL;
    }
 
    if (rc.regexwhere) {
@@ -134,6 +143,7 @@ int run_cmd(UAContext *ua, const char *cmd)
          free(jcr->RegexWhere);
       }
       jcr->RegexWhere = bstrdup(rc.regexwhere);       
+      rc.regexwhere = NULL;
    }
 
    if (rc.when) {
@@ -142,6 +152,7 @@ int run_cmd(UAContext *ua, const char *cmd)
          ua->send_msg(_("Invalid time, using current time.\n"));
          jcr->sched_time = time(NULL);
       }
+      rc.when = NULL;
    }
 
    if (rc.bootstrap) {
@@ -149,6 +160,7 @@ int run_cmd(UAContext *ua, const char *cmd)
          free(jcr->RestoreBootstrap);
       }
       jcr->RestoreBootstrap = bstrdup(rc.bootstrap);
+      rc.bootstrap = NULL;
    }
 
    if (rc.replace) {
@@ -167,9 +179,11 @@ int run_cmd(UAContext *ua, const char *cmd)
    } else {
       jcr->replace = REPLACE_ALWAYS;
    }
+   rc.replace = NULL;
 
    if (rc.Priority) {
       jcr->JobPriority = rc.Priority;
+      rc.Priority = 0;
    }
 
    if (rc.since) {
@@ -177,16 +191,15 @@ int run_cmd(UAContext *ua, const char *cmd)
          jcr->stime = get_pool_memory(PM_MESSAGE);
       }
       pm_strcpy(jcr->stime, rc.since);
+      rc.since = NULL;
    }
 
-   jcr->cloned = rc.cloned;
-
-   if (find_arg(ua, NT_("fdcalled")) > 0) {
-      jcr->file_bsock = dup_bsock(ua->UA_sock);
-      ua->quit = true;
+   if (rc.cloned) {
+      jcr->cloned = rc.cloned;
+      rc.cloned = false;
    }
 
-try_again:
+
    /* If pool changed, update migration write storage */
    if (jcr->JobType == JT_MIGRATE) {
       if (!set_migration_wstorage(jcr, rc.pool)) {
@@ -204,10 +217,12 @@ try_again:
          ua->send_msg(_("Level %s not valid.\n"), rc.level_name);
          goto bail_out;
       }
+      rc.level_name = NULL;
    }
    if (rc.jid) {
       /* Note, this is also MigrateJobId */
       jcr->RestoreJobId = str_to_int64(rc.jid);
+      rc.jid = 0;
    }
 
    /* Run without prompting? */
@@ -228,7 +243,8 @@ try_again:
       goto bail_out;
    }
 
-   if (ua->cmd[0] == '.' && strncasecmp(ua->cmd, ".mod ", 5) == 0) {
+   if (strncasecmp(ua->cmd, ".mod ", 5) == 0 || 
+       (strncasecmp(ua->cmd, "mod ", 4) == 0 && strlen(ua->cmd) > 6)) {
       Dmsg1(000, "got: %s\n", ua->cmd);
       parse_ua_args(ua);
       rc.mod = true;
@@ -1193,7 +1209,7 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
    }
    if (!rc.store->store) {
       ua->error_msg(_("No storage specified.\n"));
-      return true;
+      return false;
    } else if (!acl_access_ok(ua, Storage_ACL, rc.store->store->name())) {
       ua->error_msg(_("No authorization. Storage \"%s\".\n"),
                rc.store->store->name());