]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dird_conf.c
Make another attempt to resolve bug #2176
[bacula/bacula] / bacula / src / dird / dird_conf.c
index 9e237116c5383cffaec0d3b9ab7b22634d43ead1..5cad2b9d6b0e8eb7d51c6dba7531bbf2a0f17d68 100644 (file)
@@ -1,8 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2016 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -253,6 +252,11 @@ static RES_ITEM cat_items[] = {
    {"DbName",   store_str,      ITEM(res_cat.db_name),     0, ITEM_REQUIRED, 0},
    {"dbdriver", store_str,      ITEM(res_cat.db_driver),   0, 0, 0},
    {"DbSocket", store_str,      ITEM(res_cat.db_socket),   0, 0, 0},
+   {"dbsslkey", store_str,      ITEM(res_cat.db_ssl_key),  0, 0, 0},
+   {"dbsslcert", store_str,     ITEM(res_cat.db_ssl_cert),  0, 0, 0},
+   {"dbsslca", store_str,       ITEM(res_cat.db_ssl_ca),  0, 0, 0},
+   {"dbsslcapath", store_str,   ITEM(res_cat.db_ssl_capath),  0, 0, 0},
+   {"dbsslcipher", store_str,   ITEM(res_cat.db_ssl_cipher),  0, 0, 0},
    /* Turned off for the moment */
    {"MultipleConnections", store_bit, ITEM(res_cat.mult_db_connections), 0, 0, 0},
    {"DisableBatchInsert", store_bool, ITEM(res_cat.disable_batch_insert), 0, ITEM_DEFAULT, false},
@@ -321,11 +325,13 @@ RES_ITEM job_items[] = {
    {"SpoolSize",   store_size64, ITEM(res_job.spool_size), 0, 0, 0},
    {"ReRunFailedLevels",   store_bool, ITEM(res_job.rerun_failed_levels), 0, ITEM_DEFAULT, false},
    {"PreferMountedVolumes", store_bool, ITEM(res_job.PreferMountedVolumes), 0, ITEM_DEFAULT, true},
-   {"runbeforejob", store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
-   {"runafterjob",  store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
-   {"runafterfailedjob",  store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
-   {"clientrunbeforejob", store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
-   {"clientrunafterjob",  store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
+   {"RunBeforeJob", store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
+   {"RunAfterJob",  store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
+   {"RunAfterFailedJob",  store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
+   {"ClientRunBeforeJob", store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
+   {"ClientRunAfterJob",  store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
+   {"ConsoleRunBeforeJob", store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
+   {"ConsoleRunAfterJob",  store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
    {"Runscript",          store_runscript, ITEM(res_job.RunScripts), 0, ITEM_NO_EQUALS, 0},
    {"MaximumConcurrentJobs", store_pint32, ITEM(res_job.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
    {"MaximumSpawnedJobs", store_pint32, ITEM(res_job.MaxSpawnedJobs), 0, ITEM_DEFAULT, 600},
@@ -707,6 +713,9 @@ void dump_resource(int type, RES *ares, void sendit(void *sock, const char *fmt,
       if (res->res_job.JobType == JT_MIGRATE || res->res_job.JobType == JT_COPY) {
          sendit(sock, _("     SelectionType=%d\n"), res->res_job.selection_type);
       }
+      if (res->res_job.JobType == JT_RESTORE) {
+         sendit(sock, _("     PrefixLinks=%d\n"), res->res_job.PrefixLinks);
+      }
       if (res->res_job.client) {
          sendit(sock, _("  --> "));
          dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
@@ -1312,6 +1321,21 @@ void free_resource(RES *rres, int type)
       if (res->res_cat.db_password) {
          free(res->res_cat.db_password);
       }
+      if (res->res_cat.db_ssl_key) {
+         free(res->res_cat.db_ssl_key);
+      }
+      if (res->res_cat.db_ssl_cert) {
+         free(res->res_cat.db_ssl_cert);
+      }
+      if (res->res_cat.db_ssl_ca) {
+         free(res->res_cat.db_ssl_ca);
+      }
+      if (res->res_cat.db_ssl_capath) {
+         free(res->res_cat.db_ssl_capath);
+      }
+      if (res->res_cat.db_ssl_cipher) {
+         free(res->res_cat.db_ssl_cipher);
+      }
       break;
    case R_FILESET:
       if ((num=res->res_fs.num_includes)) {
@@ -1440,13 +1464,13 @@ void save_resource(int type, RES_ITEM *items, int pass)
       for (i=0; items[i].name; i++) {
          if (items[i].flags & ITEM_REQUIRED) {
             if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
-                Emsg2(M_ERROR_TERM, 0, _("%s item is required in %s resource, but not found.\n"),
-                    items[i].name, resources[rindex]);
+                Emsg2(M_ERROR_TERM, 0, _("\"%s\" directive is required in \"%s\" resource, but not found.\n"),
+                    items[i].name, resources[rindex].name);
             }
          }
          /* If this triggers, take a look at lib/parse_conf.h */
          if (i >= MAX_RES_ITEMS) {
-            Emsg1(M_ERROR_TERM, 0, _("Too many items in %s resource\n"), resources[rindex]);
+            Emsg1(M_ERROR_TERM, 0, _("Too many directive in \"%s\" resource\n"), resources[rindex].name);
          }
       }
    } else if (type == R_JOB) {
@@ -1455,8 +1479,8 @@ void save_resource(int type, RES_ITEM *items, int pass)
        */
       if (items[0].flags & ITEM_REQUIRED) {
          if (!bit_is_set(0, res_all.res_dir.hdr.item_present)) {
-             Emsg2(M_ERROR_TERM, 0, _("%s item is required in %s resource, but not found.\n"),
-                   items[0].name, resources[rindex]);
+             Emsg2(M_ERROR_TERM, 0, _("\"%s\" directive is required in \"%s\" resource, but not found.\n"),
+                   items[0].name, resources[rindex].name);
          }
       }
    }
@@ -1671,15 +1695,15 @@ void save_resource(int type, RES_ITEM *items, int pass)
       } else {
          RES *next, *last;
          if (res->res_dir.hdr.name == NULL) {
-            Emsg1(M_ERROR_TERM, 0, _("Name item is required in %s resource, but not found.\n"),
-                  resources[rindex]);
+            Emsg1(M_ERROR_TERM, 0, _("A Name directive is required in \"%s\" resource, but not found.\n"),
+                  resources[rindex].name);
          }
          /* Add new res to end of chain */
          for (last=next=res_head[rindex]; next; next=next->next) {
             last = next;
             if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
                Emsg2(M_ERROR_TERM, 0,
-                  _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
+                  _("Attempt to define second \"%s\" resource named \"%s\" is not permitted.\n"),
                   resources[rindex].name, res->res_dir.hdr.name);
             }
          }
@@ -1965,6 +1989,12 @@ static void store_short_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
          script->on_failure = false;
          script->set_target("");
 
+      } else if (strcasecmp(item->name, "clientrunbeforejob") == 0) {
+         script->old_proto = true;
+         script->when = SCRIPT_Before;
+         script->set_target("%c");
+         script->fail_on_error = true;
+
       } else if (strcasecmp(item->name, "clientrunafterjob") == 0) {
          script->old_proto = true;
          script->when = SCRIPT_After;
@@ -1972,11 +2002,18 @@ static void store_short_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
          script->on_success = true;
          script->on_failure = false;
 
-      } else if (strcasecmp(item->name, "clientrunbeforejob") == 0) {
-         script->old_proto = true;
+      } else if (strcasecmp(item->name, "consolerunbeforejob") == 0) {
          script->when = SCRIPT_Before;
-         script->set_target("%c");
+         script->set_target("");
          script->fail_on_error = true;
+         script->set_command(NPRT(script->command), CONSOLE_CMD);
+
+      } else if (strcasecmp(item->name, "consolerunafterjob") == 0) {
+         script->when = SCRIPT_After;
+         script->set_target("");
+         script->on_success = true;
+         script->on_failure = false;
+         script->set_command(NPRT(script->command), CONSOLE_CMD);
 
       } else if (strcasecmp(item->name, "runafterfailedjob") == 0) {
          script->when = SCRIPT_After;
@@ -2126,6 +2163,11 @@ extern "C" char *job_code_callback_director(JCR *jcr, const char* param)
 {
    static char yes[] = "yes";
    static char no[] = "no";
+   static char nothing[] = "";
+
+   if (jcr == NULL) {
+      return nothing;
+   }
    switch (param[0]) {
       case 'f':
          if (jcr->fileset) {
@@ -2133,7 +2175,7 @@ extern "C" char *job_code_callback_director(JCR *jcr, const char* param)
          }
          break;
       case 'h':
-         if (jcr->client) {
+         if (jcr->client && jcr->client->address) {
             return jcr->client->address;
          }
          break;
@@ -2154,7 +2196,7 @@ extern "C" char *job_code_callback_director(JCR *jcr, const char* param)
       case 'C':
          return jcr->cloned ? yes : no;
    }
-   return NULL;
+   return nothing;
 }
 
 bool parse_dir_config(CONFIG *config, const char *configfile, int exit_code)