]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_run.c
Eliminate FORTIFY_CODE=2 bug, and make first cut at removing
[bacula/bacula] / bacula / src / dird / ua_run.c
index 65bdb036cfc5efb4cc38695d705e8c5f4d861f7c..ec201ab598875e7eff77facaf1027757fba605a1 100644 (file)
@@ -1,14 +1,14 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    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
@@ -46,7 +46,7 @@ public:
    char *when, *verify_job_name, *catalog_name;
    char *previous_job_name;
    char *since;
-   char *verify_list;
+   const char *verify_list;
    JOB *job;
    JOB *verify_job;
    JOB *previous_job;
@@ -69,7 +69,7 @@ public:
 /* Forward referenced subroutines */
 static void select_job_level(UAContext *ua, JCR *jcr);
 static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, 
-                char *verify_list, char *jid, const char *replace,
+                const char *verify_list, char *jid, const char *replace,
                 char *client_name);
 static void select_where_regexp(UAContext *ua, JCR *jcr);
 static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc);
@@ -122,6 +122,9 @@ try_again:
    jcr->verify_job = rc.verify_job;
    jcr->previous_job = rc.previous_job;
    jcr->pool = rc.pool;
+   if (jcr->pool != jcr->job->pool) {
+      pm_strcpy(jcr->pool_source, _("User input"));
+   }
    set_rwstorage(jcr, rc.store);
    jcr->client = rc.client;
    pm_strcpy(jcr->client_name, rc.client->name());
@@ -129,6 +132,7 @@ try_again:
    jcr->ExpectedFiles = rc.files;
    if (rc.catalog) {
       jcr->catalog = rc.catalog;
+      pm_strcpy(jcr->catalog_source, _("User input"));
    }
    if (rc.where) {
       if (jcr->where) {
@@ -201,7 +205,7 @@ try_again:
 
 
    /* If pool changed, update migration write storage */
-   if (jcr->JobType == JT_MIGRATE) {
+   if (jcr->JobType == JT_MIGRATE || jcr->JobType == JT_COPY) {
       if (!set_migration_wstorage(jcr, rc.pool)) {
          goto bail_out;
       }
@@ -217,10 +221,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? */
@@ -241,8 +247,8 @@ try_again:
       goto bail_out;
    }
 
-   if (ua->cmd[0] == '.' && strncasecmp(ua->cmd, ".mod ", 5) == 0) {
-      Dmsg1(000, "got: %s\n", ua->cmd);
+   if (strncasecmp(ua->cmd, ".mod ", 5) == 0 || 
+       (strncasecmp(ua->cmd, "mod ", 4) == 0 && strlen(ua->cmd) > 6)) {
       parse_ua_args(ua);
       rc.mod = true;
       if (!scan_command_line_arguments(ua, rc)) {
@@ -270,6 +276,7 @@ try_again:
       add_prompt(ua, _("When"));             /* 5 */
       add_prompt(ua, _("Priority"));         /* 6 */
       if (jcr->JobType == JT_BACKUP ||
+          jcr->JobType == JT_COPY ||
           jcr->JobType == JT_MIGRATE ||
           jcr->JobType == JT_VERIFY) {
          add_prompt(ua, _("Pool"));          /* 7 */
@@ -351,6 +358,7 @@ try_again:
       case 7:
          /* Pool or Bootstrap depending on JobType */
          if (jcr->JobType == JT_BACKUP ||
+             jcr->JobType == JT_COPY ||
              jcr->JobType == JT_MIGRATE ||
              jcr->JobType == JT_VERIFY) {      /* Pool */
             rc.pool = select_pool_resource(ua);
@@ -374,8 +382,9 @@ try_again:
             jcr->RestoreBootstrap = bstrdup(ua->cmd);
             fd = fopen(jcr->RestoreBootstrap, "rb");
             if (!fd) {
+               berrno be;
                ua->send_msg(_("Warning cannot open %s: ERR=%s\n"),
-                  jcr->RestoreBootstrap, strerror(errno));
+                  jcr->RestoreBootstrap, be.bstrerror());
                free(jcr->RestoreBootstrap);
                jcr->RestoreBootstrap = NULL;
             } else {
@@ -421,6 +430,7 @@ try_again:
          }
          opt = do_prompt(ua, "", _("Select replace option"), NULL, 0);
          if (opt >=  0) {
+            rc.replace = ReplaceOptions[opt].name;
             jcr->replace = ReplaceOptions[opt].token;
          }
          goto try_again;
@@ -445,8 +455,11 @@ try_again:
       Dmsg1(800, "Calling run_job job=%x\n", jcr->job);
 
 start_job:
-      Dmsg1(100, "Using pool %s\n", jcr->pool->name());
+      Dmsg3(100, "JobId=%u using pool %s priority=%d\n", (int)jcr->JobId, 
+            jcr->pool->name(), jcr->JobPriority);
       JobId = run_job(jcr);
+      Dmsg4(100, "JobId=%u NewJobId=%d using pool %s priority=%d\n", (int)jcr->JobId, 
+            JobId, jcr->pool->name(), jcr->JobPriority);
       free_jcr(jcr);                  /* release jcr */
       if (JobId == 0) {
          ua->error_msg(_("Job failed.\n"));
@@ -656,7 +669,7 @@ static void select_job_level(UAContext *ua, JCR *jcr)
    return;
 }
 
-static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, char *verify_list,
+static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char *verify_list,
    char *jid, const char *replace, char *client_name) 
 {
    Dmsg1(800, "JobType=%c\n", jcr->JobType);
@@ -841,10 +854,17 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, char *veri
               jcr->JobPriority);
       }
       break;
+   case JT_COPY:
    case JT_MIGRATE:
+      char *prt_type;
+      if (jcr->JobType == JT_COPY) {
+         prt_type = _("Run Copy job\n");
+      } else {
+         prt_type = _("Run Migration job\n");
+      }
       jcr->JobLevel = L_FULL;      /* default level */
       if (ua->api) ua->signal(BNET_RUN_CMD);   
-      ua->send_msg(_("Run Migration job\n"
+      ua->send_msg("%s"
                      "JobName:       %s\n"
                      "Bootstrap:     %s\n"
                      "Client:        %s\n"
@@ -855,7 +875,8 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, char *veri
                      "JobId:         %s\n"
                      "When:          %s\n"
                      "Catalog:       %s\n"
-                     "Priority:      %d\n"),
+                     "Priority:      %d\n",
+           prt_type,
            job->name(),
            NPRT(jcr->RestoreBootstrap),
            jcr->client->name(),
@@ -930,7 +951,7 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
             /* Note, yes and run have no value, so do not fail */
             if (!ua->argv[i] && j != YES_POS /*yes*/) {
                ua->send_msg(_("Value missing for keyword %s\n"), ua->argk[i]);
-               return true;
+               return false;
             }
             Dmsg1(800, "Got keyword=%s\n", NPRT(kw[j]));
             switch (j) {
@@ -1206,7 +1227,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());