]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl fix nasty runscript configuration parsing bug
authorEric Bollengier <eric@eb.homelinux.org>
Tue, 19 Dec 2006 20:56:46 +0000 (20:56 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Tue, 19 Dec 2006 20:56:46 +0000 (20:56 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3813 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/dird_conf.c
bacula/technotes-1.39

index 7c2636f768cd4ca48d4bb0d599195e40f955b7e6..74db53766cb2eb5c89d44c0d85d6d77f4574ed95 100644 (file)
@@ -1691,19 +1691,35 @@ static void store_short_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
    scan_to_eol(lc);
 }
 
+/* Store a bool in a bit field without modifing res_all.hdr 
+ * We can also add an option to store_bool to skip res_all.hdr
+ */
+void store_runscript_bool(LEX *lc, RES_ITEM *item, int index, int pass)
+{
+   lex_get_token(lc, T_NAME);
+   if (strcasecmp(lc->str, "yes") == 0 || strcasecmp(lc->str, "true") == 0) {
+      *(bool *)(item->value) = true;
+   } else if (strcasecmp(lc->str, "no") == 0 || strcasecmp(lc->str, "false") == 0) {
+      *(bool *)(item->value) = false;
+   } else {
+      scan_err2(lc, _("Expect %s, got: %s"), "YES, NO, TRUE, or FALSE", lc->str); /* YES and NO must not be translated */
+   }
+   scan_to_eol(lc);
+}
+
 /*
  * new RunScript items
- *   name             handler         value                                code flags default_value
+ *   name             handler              value                             code flags default_value
  */
 static RES_ITEM runscript_items[] = {
  {"command", store_runscript_cmd,    {(char **)&res_runscript},           0,  ITEM_REQUIRED, 0}, 
  {"target", store_runscript_target,  {(char **)&res_runscript},            0,  0, 0}, 
  {"runsonsuccess",    store_bool,    {(char **)&res_runscript.on_success}, 0,  0, 0},
  {"runsonfailure",    store_bool,    {(char **)&res_runscript.on_failure}, 0,  0, 0},
  {"abortjobonerror", store_bool,     {(char **)&res_runscript.abort_on_error}, 0, 0,   0},
  {"runswhen", store_runscript_when,  {(char **)&res_runscript.when},       0,  0, 0},
  {"runsonclient", store_runscript_target,  {(char **)&res_runscript},       0,  0, 0}, /* TODO */
  {NULL, NULL, {0}, 0, 0, 0}
{"command",        store_runscript_cmd,  {(char **)&res_runscript},           0,  ITEM_REQUIRED, 0}, 
{"target",         store_runscript_target,{(char **)&res_runscript},          0,  0, 0}, 
{"runsonsuccess",  store_runscript_bool, {(char **)&res_runscript.on_success},0,  0, 0},
{"runsonfailure",  store_runscript_bool, {(char **)&res_runscript.on_failure},0,  0, 0},
{"abortjobonerror",store_runscript_bool, {(char **)&res_runscript.abort_on_error},0, 0, 0},
{"runswhen",       store_runscript_when, {(char **)&res_runscript.when},      0,  0, 0},
{"runsonclient",   store_runscript_target,{(char **)&res_runscript},          0,  0, 0}, /* TODO */
+ {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*
index 918d20244ddd4de192dfc75b9efa91c98fe3073d..e1b2d026ee9922c767ff91b7643bb2f5c9b2880a 100644 (file)
@@ -1,6 +1,8 @@
               Technical notes on version 1.39  
 
 General:
+19Dec06
+ebl  Fix runscript configuration parsing bug.
 17Dec06
 kes  Add ENABLE_NLS (as suggested by Eric) to correct NLS problems.
      Remove NLS kludge from baconfig.h.  This fixes bug #729.