]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_run.c
Fix seg fault introduced during restore cut and paste
[bacula/bacula] / bacula / src / dird / ua_run.c
index 0a8e12468d6db2f0d8e80c26236cb0c116dfed16..9786ce025020bb6f9336bfa723bd5d2f598e3cde 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"
@@ -750,28 +749,68 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
       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"
+      if (ua->api) {
+         ua->signal(BNET_RUN_CMD);   
+         ua->send_msg("Type: Admin\n"
+                     "Title: Run Admin Job\n"
+                     "JobName:  %s\n"
+                     "FileSet:  %s\n"
+                     "Client:   %s\n"
+                     "Storage:  %s\n"
+                     "When:     %s\n"
+                     "Priority: %d\n",
+                 job->name(),
+                 jcr->fileset->name(),
+                 NPRT(jcr->client->name()),
+                 jcr->wstore?jcr->wstore->name():"*None*",
+                 bstrutime(dt, sizeof(dt), jcr->sched_time),
+                 jcr->JobPriority);
+      } else {
+         ua->send_msg(_("Run Admin Job\n"
                      "JobName:  %s\n"
                      "FileSet:  %s\n"
                      "Client:   %s\n"
                      "Storage:  %s\n"
                      "When:     %s\n"
                      "Priority: %d\n"),
-                 _("Admin"),
                  job->name(),
                  jcr->fileset->name(),
                  NPRT(jcr->client->name()),
                  jcr->wstore?jcr->wstore->name():"*None*",
                  bstrutime(dt, sizeof(dt), jcr->sched_time),
                  jcr->JobPriority);
+      }
       jcr->set_JobLevel(L_FULL);
       break;
    case JT_BACKUP:
    case JT_VERIFY:
       if (jcr->getJobType() == JT_BACKUP) {
-         if (ua->api) ua->signal(BNET_RUN_CMD);   
-         ua->send_msg(_("Run %s job\n"
+         if (ua->api) {
+            ua->signal(BNET_RUN_CMD);   
+            ua->send_msg("Type: Backup\n"
+                        "Title: Run Backup Job\n"
+                        "JobName:  %s\n"
+                        "Level:    %s\n"
+                        "Client:   %s\n"
+                        "FileSet:  %s\n"
+                        "Pool:     %s\n"
+                        "Storage:  %s\n"
+                        "When:     %s\n"
+                        "Priority: %d\n"
+                        "%s%s%s",
+                 job->name(),
+                 level_to_str(jcr->getJobLevel()),
+                 jcr->client->name(),
+                 jcr->fileset->name(),
+                 NPRT(jcr->pool->name()),
+                 jcr->wstore?jcr->wstore->name():"*None*",
+                 bstrutime(dt, sizeof(dt), jcr->sched_time),
+                 jcr->JobPriority,
+                 jcr->plugin_options?"Plugin Options: ":"",
+                 jcr->plugin_options?jcr->plugin_options:"",
+                 jcr->plugin_options?"\n":"");
+         } else {
+            ua->send_msg(_("Run Backup job\n"
                         "JobName:  %s\n"
                         "Level:    %s\n"
                         "Client:   %s\n"
@@ -781,7 +820,6 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                         "When:     %s\n"
                         "Priority: %d\n"
                         "%s%s%s"),
-                 _("Backup"),
                  job->name(),
                  level_to_str(jcr->getJobLevel()),
                  jcr->client->name(),
@@ -793,6 +831,7 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                  jcr->plugin_options?"Plugin Options: ":"",
                  jcr->plugin_options?jcr->plugin_options:"",
                  jcr->plugin_options?"\n":"");
+         }
       } else {  /* JT_VERIFY */
          const char *Name;
          if (jcr->verify_job) {
@@ -806,8 +845,32 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
          if (!verify_list) {
             verify_list = "";
          }
-         if (ua->api) ua->signal(BNET_RUN_CMD);   
-         ua->send_msg(_("Run %s job\n"
+         if (ua->api) {
+            ua->signal(BNET_RUN_CMD);   
+            ua->send_msg("Type: Verify\n"
+                        "Title: Run Verify Job\n"
+                        "JobName:     %s\n"
+                        "Level:       %s\n"
+                        "Client:      %s\n"
+                        "FileSet:     %s\n"
+                        "Pool:        %s (From %s)\n"
+                        "Storage:     %s (From %s)\n"
+                        "Verify Job:  %s\n"
+                        "Verify List: %s\n"
+                        "When:        %s\n"
+                        "Priority:    %d\n",
+              job->name(),
+              level_to_str(jcr->getJobLevel()),
+              jcr->client->name(),
+              jcr->fileset->name(),
+              NPRT(jcr->pool->name()), jcr->pool_source,
+              jcr->rstore->name(), jcr->rstore_source,
+              Name,
+              verify_list,
+              bstrutime(dt, sizeof(dt), jcr->sched_time),
+              jcr->JobPriority);
+         } else {
+            ua->send_msg(_("Run Verify Job\n"
                         "JobName:     %s\n"
                         "Level:       %s\n"
                         "Client:      %s\n"
@@ -818,7 +881,6 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                         "Verify List: %s\n"
                         "When:        %s\n"
                         "Priority:    %d\n"),
-              _("Verify"),
               job->name(),
               level_to_str(jcr->getJobLevel()),
               jcr->client->name(),
@@ -829,6 +891,7 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
               verify_list,
               bstrutime(dt, sizeof(dt), jcr->sched_time),
               jcr->JobPriority);
+         }
       }
       break;
    case JT_RESTORE:
@@ -845,10 +908,38 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
       jcr->set_JobLevel(L_FULL);      /* default level */
       Dmsg1(800, "JobId to restore=%d\n", jcr->RestoreJobId);
       if (jcr->RestoreJobId == 0) {
-         if (ua->api) ua->signal(BNET_RUN_CMD);   
          /* RegexWhere is take before RestoreWhere */
          if (jcr->RegexWhere || (job->RegexWhere && !jcr->where)) {
-            ua->send_msg(_("Run Restore job\n"
+            if (ua->api) {
+               ua->signal(BNET_RUN_CMD);   
+               ua->send_msg("Type: Restore\n"
+                        "Title: Run Restore Job\n"
+                        "JobName:         %s\n"
+                        "Bootstrap:       %s\n"
+                        "RegexWhere:      %s\n"
+                        "Replace:         %s\n"
+                        "FileSet:         %s\n"
+                        "Backup Client:   %s\n"
+                        "Restore Client:  %s\n"
+                        "Storage:         %s\n"
+                        "When:            %s\n"
+                        "Catalog:         %s\n"
+                        "Priority:        %d\n"
+                        "Plugin Options:  %s\n",
+                 job->name(),
+                 NPRT(jcr->RestoreBootstrap), 
+                 jcr->RegexWhere?jcr->RegexWhere:job->RegexWhere,
+                 replace,
+                 jcr->fileset->name(),
+                 client_name,
+                 jcr->client->name(),
+                 jcr->rstore->name(),
+                 bstrutime(dt, sizeof(dt), jcr->sched_time),
+                 jcr->catalog->name(),
+                 jcr->JobPriority,
+                 NPRT(jcr->plugin_options));
+            } else {
+               ua->send_msg(_("Run Restore job\n"
                         "JobName:         %s\n"
                         "Bootstrap:       %s\n"
                         "RegexWhere:      %s\n"
@@ -873,9 +964,38 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                  jcr->catalog->name(),
                  jcr->JobPriority,
                  NPRT(jcr->plugin_options));
-
+            }
          } else {
-            ua->send_msg(_("Run Restore job\n"
+            if (ua->api) {
+               ua->signal(BNET_RUN_CMD);   
+               ua->send_msg("Type: Restore\n"
+                        "Title: Run Restore job\n"
+                        "JobName:         %s\n"
+                        "Bootstrap:       %s\n"
+                        "Where:           %s\n"
+                        "Replace:         %s\n"
+                        "FileSet:         %s\n"
+                        "Backup Client:   %s\n"
+                        "Restore Client:  %s\n"
+                        "Storage:         %s\n"
+                        "When:            %s\n"
+                        "Catalog:         %s\n"
+                        "Priority:        %d\n"
+                        "Plugin Options:  %s\n",
+                 job->name(),
+                 NPRT(jcr->RestoreBootstrap), 
+                 jcr->where?jcr->where:NPRT(job->RestoreWhere), 
+                 replace,
+                 jcr->fileset->name(),
+                 client_name,
+                 jcr->client->name(),
+                 jcr->rstore->name(),
+                 bstrutime(dt, sizeof(dt), jcr->sched_time),
+                 jcr->catalog->name(),
+                 jcr->JobPriority,
+                 NPRT(jcr->plugin_options));
+            } else {
+               ua->send_msg(_("Run Restore job\n"
                         "JobName:         %s\n"
                         "Bootstrap:       %s\n"
                         "Where:           %s\n"
@@ -900,9 +1020,11 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                  jcr->catalog->name(),
                  jcr->JobPriority,
                  NPRT(jcr->plugin_options));
+            }
          }
 
       } else {
+         /* ***FIXME*** This needs to be fixed for bat */
          if (ua->api) ua->signal(BNET_RUN_CMD);   
          ua->send_msg(_("Run Restore job\n"
                         "JobName:    %s\n"
@@ -939,15 +1061,46 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
       break;
    case JT_COPY:
    case JT_MIGRATE:
-      const char *prt_type;
-      if (jcr->getJobType() == JT_COPY) {
-         prt_type = _("Run Copy job\n");
-      } else {
-         prt_type = _("Run Migration job\n");
-      }
+      char *prt_type;
       jcr->set_JobLevel(L_FULL);      /* default level */
-      if (ua->api) ua->signal(BNET_RUN_CMD);   
-      ua->send_msg("%s"
+      if (ua->api) {
+         ua->signal(BNET_RUN_CMD);
+         if (jcr->getJobType() == JT_COPY) {
+            prt_type = (char *)"Type: Copy\nTitle: Run Copy Job\n";
+         } else {
+            prt_type = (char *)"Type: Migration\nTitle: Run Migration Job\n";
+         }
+         ua->send_msg("%s"
+                     "JobName:       %s\n"
+                     "Bootstrap:     %s\n"
+                     "Client:        %s\n"
+                     "FileSet:       %s\n"
+                     "Pool:          %s\n"
+                     "Read Storage:  %s\n"
+                     "Write Storage: %s\n"
+                     "JobId:         %s\n"
+                     "When:          %s\n"
+                     "Catalog:       %s\n"
+                     "Priority:      %d\n",
+           prt_type,
+           job->name(),
+           NPRT(jcr->RestoreBootstrap),
+           jcr->client->name(),
+           jcr->fileset->name(),
+           NPRT(jcr->pool->name()),
+           jcr->rstore->name(),
+           jcr->wstore?jcr->wstore->name():"*None*",
+           jcr->MigrateJobId==0?"*None*":edit_uint64(jcr->MigrateJobId, ec1),
+           bstrutime(dt, sizeof(dt), jcr->sched_time),
+           jcr->catalog->name(),
+           jcr->JobPriority);
+      } else {
+         if (jcr->getJobType() == JT_COPY) {
+            prt_type = _("Run Copy job\n");
+         } else {
+            prt_type = _("Run Migration job\n");
+         }
+         ua->send_msg("%s"
                      "JobName:       %s\n"
                      "Bootstrap:     %s\n"
                      "Client:        %s\n"
@@ -971,6 +1124,7 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
            bstrutime(dt, sizeof(dt), jcr->sched_time),
            jcr->catalog->name(),
            jcr->JobPriority);
+      }
       break;
    default:
       ua->error_msg(_("Unknown Job Type=%d\n"), jcr->getJobType());