-/*
- * Main configuration file parser for Bacula Directors,
- * some parts may be split into separate files such as
- * the schedule configuration (run_config.c).
- *
- * Note, the configuration file parser consists of three parts
- *
- * 1. The generic lexical scanner in lib/lex.c and lib/lex.h
- *
- * 2. The generic config scanner in lib/parse_config.c and
- * lib/parse_config.h.
- * These files contain the parser code, some utility
- * routines, and the common store routines (name, int,
- * string).
- *
- * 3. The daemon specific file, which contains the Resource
- * definitions as well as any specific store routines
- * for the resource records.
- *
- * Kern Sibbald, January MM
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 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.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Main configuration file parser for Bacula Directors,
+ * some parts may be split into separate files such as
+ * the schedule configuration (run_config.c).
+ *
+ * Note, the configuration file parser consists of three parts
+ *
+ * 1. The generic lexical scanner in lib/lex.c and lib/lex.h
+ *
+ * 2. The generic config scanner in lib/parse_config.c and
+ * lib/parse_config.h.
+ * These files contain the parser code, some utility
+ * routines, and the common store routines (name, int,
+ * string).
+ *
+ * 3. The daemon specific file, which contains the Resource
+ * definitions as well as any specific store routines
+ * for the resource records.
+ *
+ * Kern Sibbald, January MM
+ *
+ * Version $Id$
+ */
+
#include "bacula.h"
#include "dird.h"
{"tlscacertificatedir", store_dir, ITEM(res_client.tls_ca_certdir), 0, 0, 0},
{"tlscertificate", store_dir, ITEM(res_client.tls_certfile), 0, 0, 0},
{"tlskey", store_dir, ITEM(res_client.tls_keyfile), 0, 0, 0},
+ {"tlsallowedcn", store_alist_str, ITEM(res_client.tls_allowed_cns), 0, 0, 0},
{NULL, NULL, {0}, 0, 0, 0}
};
{"storage", store_alist_res, ITEM(res_pool.storage), R_STORAGE, 0, 0},
{"autoprune", store_bool, ITEM(res_pool.AutoPrune), 0, ITEM_DEFAULT, true},
{"recycle", store_bool, ITEM(res_pool.Recycle), 0, ITEM_DEFAULT, true},
+ {"recyclepool", store_res, ITEM(res_pool.RecyclePool), R_POOL, 0, 0},
{NULL, NULL, {0}, 0, 0, 0}
};
NPRT(res->res_pool.label_format));
sendit(sock, _(" CleaningPrefix=%s LabelType=%d\n"),
NPRT(res->res_pool.cleaning_prefix), res->res_pool.LabelType);
- sendit(sock, _(" RecyleOldest=%d PurgeOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n"),
+ sendit(sock, _(" RecyleOldest=%d PurgeOldest=%d\n"),
res->res_pool.recycle_oldest_volume,
- res->res_pool.purge_oldest_volume,
- res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
+ res->res_pool.purge_oldest_volume);
+ sendit(sock, _(" MaxVolJobs=%d MaxVolFiles=%d MaxVolBytes=%s\n"),
+ res->res_pool.MaxVolJobs,
+ res->res_pool.MaxVolFiles,
+ edit_uint64(res->res_pool.MaxVolFiles, ed1));
sendit(sock, _(" MigTime=%s MigHiBytes=%s MigLoBytes=%s\n"),
edit_utime(res->res_pool.MigrationTime, ed1, sizeof(ed1)),
edit_uint64(res->res_pool.MigrationHighBytes, ed2),
edit_uint64(res->res_pool.MigrationLowBytes, ed3));
if (res->res_pool.NextPool) {
- sendit(sock, _(" --> "));
- dump_resource(-R_POOL, (RES *)res->res_pool.NextPool, sendit, sock);
+ sendit(sock, _(" NextPool=%s\n"), res->res_pool.NextPool->name());
+ }
+ if (res->res_pool.RecyclePool) {
+ sendit(sock, _(" RecyclePool=%s\n"), res->res_pool.RecyclePool->name());
}
if (res->res_pool.storage) {
STORE *store;
if (res->res_client.tls_keyfile) {
free(res->res_client.tls_keyfile);
}
+ if (res->res_client.tls_allowed_cns) {
+ delete res->res_client.tls_allowed_cns;
+ }
break;
case R_STORAGE:
if (res->res_store.address) {
}
/* Explicitly copy resource pointers from this pass (res_all) */
res->res_pool.NextPool = res_all.res_pool.NextPool;
+ res->res_pool.RecyclePool = res_all.res_pool.RecyclePool;
res->res_pool.storage = res_all.res_pool.storage;
break;
case R_CONSOLE:
Emsg1(M_ERROR_TERM, 0, _("Cannot find Client resource %s\n"), res_all.res_client.hdr.name);
}
res->res_client.catalog = res_all.res_client.catalog;
+ res->res_client.tls_allowed_cns = res_all.res_client.tls_allowed_cns;
break;
case R_SCHEDULE:
/*
error = true;
break;
default:
- printf(_("Unknown resource type %d in save_resrouce.\n"), type);
+ printf(_("Unknown resource type %d in save_resource.\n"), type);
error = true;
break;
}
Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
res->res_dir.hdr.name, rindex);
} else {
- RES *next;
+ 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]);
}
/* Add new res to end of chain */
- for (next=res_head[rindex]; next->next; next=next->next) {
+ 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"),
resources[rindex].name, res->res_dir.hdr.name);
}
}
- next->next = (RES *)res;
+ last->next = (RES *)res;
Dmsg4(900, _("Inserting %s res: %s index=%d pass=%d\n"), res_to_str(type),
res->res_dir.hdr.name, rindex, pass);
}
if (pass == 2) {
if (strcmp(lc->str, "%c") == 0) {
((RUNSCRIPT*) item->value)->set_target(lc->str);
- } else if (strcmp(lc->str, "yes") == 0) {
+ } else if (strcasecmp(lc->str, "yes") == 0) {
((RUNSCRIPT*) item->value)->set_target("%c");
- } else if (strcmp(lc->str, "no") == 0) {
+ } else if (strcasecmp(lc->str, "no") == 0) {
((RUNSCRIPT*) item->value)->set_target("");
} else {
RES *res = GetResWithName(R_CLIENT, lc->str);
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}
};
/*