]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_run.c
Fix bat seg fault
[bacula/bacula] / bacula / src / dird / ua_run.c
index 5a25811eb483bf3e64f85efa1bf7d7742927e59e..1d79adccd37a822e1981891a16563c9615671b65 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2010 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
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -31,7 +31,6 @@
  *
  *     Kern Sibbald, December MMI
  *
- *   Version $Id$
  */
 
 #include "bacula.h"
@@ -41,7 +40,7 @@ class run_ctx {
 public:
    char *job_name, *level_name, *jid, *store_name, *pool_name;
    char *where, *fileset_name, *client_name, *bootstrap, *regexwhere;
-   char *restore_client_name;
+   char *restore_client_name, *comment;
    const char *replace;
    char *when, *verify_job_name, *catalog_name;
    char *previous_job_name;
@@ -122,6 +121,11 @@ int run_cmd(UAContext *ua, const char *cmd)
       jcr->unlink_bsr = ua->jcr->unlink_bsr;    /* copy unlink flag from caller */
       ua->jcr->unlink_bsr = false;
    }
+   /* Transfer JobIds to new restore Job */
+   if (ua->jcr->JobIds) {
+      jcr->JobIds = ua->jcr->JobIds;
+      ua->jcr->JobIds = NULL;
+   }
 
 try_again:
    if (!reset_restore_context(ua, jcr, rc)) {
@@ -438,6 +442,9 @@ static bool reset_restore_context(UAContext *ua, JCR *jcr, run_ctx &rc)
       jcr->catalog = rc.catalog;
       pm_strcpy(jcr->catalog_source, _("User input"));
    }
+
+   pm_strcpy(jcr->comment, rc.comment);
+
    if (rc.where) {
       if (jcr->where) {
          free(jcr->where);
@@ -538,7 +545,7 @@ static bool reset_restore_context(UAContext *ua, JCR *jcr, run_ctx &rc)
       rc.level_name = NULL;
    }
    if (rc.jid) {
-      /* Note, this is also MigrateJobId */
+      /* Note, this is also MigrateJobId and a VerifyJobId */
       jcr->RestoreJobId = str_to_int64(rc.jid);
       rc.jid = 0;
    }
@@ -745,10 +752,11 @@ static void select_job_level(UAContext *ua, JCR *jcr)
 static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char *verify_list,
    char *jid, const char *replace, char *client_name) 
 {
+   char ec1[30];
+   char dt[MAX_TIME_LENGTH];
+
    Dmsg1(800, "JobType=%c\n", jcr->getJobType());
    switch (jcr->getJobType()) {
-      char ec1[30];
-      char dt[MAX_TIME_LENGTH];
    case JT_ADMIN:
       if (ua->api) ua->signal(BNET_RUN_CMD);   
       ua->send_msg(_("Run %s job\n"
@@ -794,9 +802,19 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                  jcr->plugin_options?jcr->plugin_options:"",
                  jcr->plugin_options?"\n":"");
       } else {  /* JT_VERIFY */
+         JOB_DBR jr;
          const char *Name;
          if (jcr->verify_job) {
             Name = jcr->verify_job->name();
+         } else if (jcr->RestoreJobId) { /* Display job name if jobid requested */
+            memset(&jr, 0, sizeof(jr));
+            jr.JobId = jcr->RestoreJobId;
+            if (!db_get_job_record(jcr, ua->db, &jr)) {
+               ua->error_msg(_("Could not get job record for selected JobId. ERR=%s"),
+                    db_strerror(ua->db));
+               return false;
+            }
+            Name = jr.Job;
          } else {
             Name = "";
          }
@@ -1012,6 +1030,7 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
       "restoreclient",                /* 24 */
       "pluginoptions",                /* 25 */
       "spooldata",                    /* 26 */
+      "comment",                      /* 27 */
       NULL};
 
 #define YES_POS 14
@@ -1026,7 +1045,7 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
    rc.verify_job_name = NULL;
    rc.previous_job_name = NULL;
    rc.spool_data_set = 0;
-
+   rc.comment = NULL;
 
    for (i=1; i<ua->argc; i++) {
       Dmsg2(800, "Doing arg %d = %s\n", i, ua->argk[i]);
@@ -1244,6 +1263,9 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
                   ua->send_msg(_("Invalid spooldata flag.\n"));
                }
                break;
+            case 27: /* comment */
+               rc.comment = ua->argv[i];
+               kw_ok = true;
             default:
                break;
             }
@@ -1269,7 +1291,11 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
    } /* end argc loop */
              
    Dmsg0(800, "Done scan.\n");
-
+   if (rc.comment) {
+      if (!is_comment_legal(ua, rc.comment)) {
+         return false;
+      }
+   }
    if (rc.catalog_name) {
        rc.catalog = GetCatalogResWithName(rc.catalog_name);
        if (rc.catalog == NULL) {