2 * Main configuration file parser for Bacula Directors,
3 * some parts may be split into separate files such as
4 * the schedule configuration (run_config.c).
6 * Note, the configuration file parser consists of three parts
8 * 1. The generic lexical scanner in lib/lex.c and lib/lex.h
10 * 2. The generic config scanner in lib/parse_config.c and
12 * These files contain the parser code, some utility
13 * routines, and the common store routines (name, int,
16 * 3. The daemon specific file, which contains the Resource
17 * definitions as well as any specific store routines
18 * for the resource records.
20 * Kern Sibbald, January MM
25 Copyright (C) 2000-2004 Kern Sibbald and John Walker
27 This program is free software; you can redistribute it and/or
28 modify it under the terms of the GNU General Public License as
29 published by the Free Software Foundation; either version 2 of
30 the License, or (at your option) any later version.
32 This program is distributed in the hope that it will be useful,
33 but WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 General Public License for more details.
37 You should have received a copy of the GNU General Public
38 License along with this program; if not, write to the Free
39 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
47 /* Define the first and last resource ID record
48 * types. Note, these should be unique for each
49 * daemon though not a requirement.
51 int r_first = R_FIRST;
53 static RES *sres_head[R_LAST - R_FIRST + 1];
54 RES **res_head = sres_head;
56 /* Imported subroutines */
57 extern void store_run(LEX *lc, RES_ITEM *item, int index, int pass);
58 extern void store_finc(LEX *lc, RES_ITEM *item, int index, int pass);
59 extern void store_inc(LEX *lc, RES_ITEM *item, int index, int pass);
62 /* Forward referenced subroutines */
64 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass);
65 void store_level(LEX *lc, RES_ITEM *item, int index, int pass);
66 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass);
67 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass);
70 /* We build the current resource here as we are
71 * scanning the resource configuration definition,
72 * then move it to allocated memory when the resource
76 int res_all_size = sizeof(res_all);
79 /* Definition of records permitted within each
80 * resource with the routine to process the record
81 * information. NOTE! quoted names must be in lower case.
86 * name handler value code flags default_value
88 static RES_ITEM dir_items[] = {
89 {"name", store_name, ITEM(res_dir.hdr.name), 0, ITEM_REQUIRED, 0},
90 {"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0},
91 {"messages", store_res, ITEM(res_dir.messages), R_MSGS, 0, 0},
92 {"dirport", store_addresses_port, ITEM(res_dir.DIRaddrs), 0, ITEM_DEFAULT, 9101},
93 {"diraddress", store_addresses_address, ITEM(res_dir.DIRaddrs), 0, ITEM_DEFAULT, 9101},
94 {"diraddresses",store_addresses, ITEM(res_dir.DIRaddrs), 0, ITEM_DEFAULT, 9101},
95 {"queryfile", store_dir, ITEM(res_dir.query_file), 0, ITEM_REQUIRED, 0},
96 {"workingdirectory", store_dir, ITEM(res_dir.working_directory), 0, ITEM_REQUIRED, 0},
97 {"piddirectory",store_dir, ITEM(res_dir.pid_directory), 0, ITEM_REQUIRED, 0},
98 {"subsysdirectory", store_dir, ITEM(res_dir.subsys_directory), 0, 0, 0},
99 {"requiressl", store_yesno, ITEM(res_dir.require_ssl), 1, ITEM_DEFAULT, 0},
100 {"enablessl", store_yesno, ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0},
101 {"maximumconcurrentjobs", store_pint, ITEM(res_dir.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
102 {"password", store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0},
103 {"fdconnecttimeout", store_time,ITEM(res_dir.FDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
104 {"sdconnecttimeout", store_time,ITEM(res_dir.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
105 {NULL, NULL, NULL, 0, 0, 0}
111 * name handler value code flags default_value
113 static RES_ITEM con_items[] = {
114 {"name", store_name, ITEM(res_con.hdr.name), 0, ITEM_REQUIRED, 0},
115 {"description", store_str, ITEM(res_con.hdr.desc), 0, 0, 0},
116 {"enablessl", store_yesno, ITEM(res_con.enable_ssl), 1, ITEM_DEFAULT, 0},
117 {"password", store_password, ITEM(res_con.password), 0, ITEM_REQUIRED, 0},
118 {"jobacl", store_acl, ITEM(res_con.ACL_lists), Job_ACL, 0, 0},
119 {"clientacl", store_acl, ITEM(res_con.ACL_lists), Client_ACL, 0, 0},
120 {"storageacl", store_acl, ITEM(res_con.ACL_lists), Storage_ACL, 0, 0},
121 {"scheduleacl", store_acl, ITEM(res_con.ACL_lists), Schedule_ACL, 0, 0},
122 {"runacl", store_acl, ITEM(res_con.ACL_lists), Run_ACL, 0, 0},
123 {"poolacl", store_acl, ITEM(res_con.ACL_lists), Pool_ACL, 0, 0},
124 {"commandacl", store_acl, ITEM(res_con.ACL_lists), Command_ACL, 0, 0},
125 {"filesetacl", store_acl, ITEM(res_con.ACL_lists), FileSet_ACL, 0, 0},
126 {"catalogacl", store_acl, ITEM(res_con.ACL_lists), Catalog_ACL, 0, 0},
127 {NULL, NULL, NULL, 0, 0, 0}
132 * Client or File daemon resource
134 * name handler value code flags default_value
137 static RES_ITEM cli_items[] = {
138 {"name", store_name, ITEM(res_client.hdr.name), 0, ITEM_REQUIRED, 0},
139 {"description", store_str, ITEM(res_client.hdr.desc), 0, 0, 0},
140 {"address", store_str, ITEM(res_client.address), 0, ITEM_REQUIRED, 0},
141 {"fdaddress", store_str, ITEM(res_client.address), 0, 0, 0},
142 {"fdport", store_pint, ITEM(res_client.FDport), 0, ITEM_DEFAULT, 9102},
143 {"password", store_password, ITEM(res_client.password), 0, ITEM_REQUIRED, 0},
144 {"fdpassword", store_password, ITEM(res_client.password), 0, 0, 0},
145 {"catalog", store_res, ITEM(res_client.catalog), R_CATALOG, ITEM_REQUIRED, 0},
146 {"fileretention", store_time, ITEM(res_client.FileRetention), 0, ITEM_DEFAULT, 60*60*24*60},
147 {"jobretention", store_time, ITEM(res_client.JobRetention), 0, ITEM_DEFAULT, 60*60*24*180},
148 {"autoprune", store_yesno, ITEM(res_client.AutoPrune), 1, ITEM_DEFAULT, 1},
149 {"enablessl", store_yesno, ITEM(res_client.enable_ssl), 1, ITEM_DEFAULT, 0},
150 {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
151 {NULL, NULL, NULL, 0, 0, 0}
154 /* Storage daemon resource
156 * name handler value code flags default_value
158 static RES_ITEM store_items[] = {
159 {"name", store_name, ITEM(res_store.hdr.name), 0, ITEM_REQUIRED, 0},
160 {"description", store_str, ITEM(res_store.hdr.desc), 0, 0, 0},
161 {"sdport", store_pint, ITEM(res_store.SDport), 0, ITEM_DEFAULT, 9103},
162 {"address", store_str, ITEM(res_store.address), 0, ITEM_REQUIRED, 0},
163 {"sdaddress", store_str, ITEM(res_store.address), 0, 0, 0},
164 {"password", store_password, ITEM(res_store.password), 0, ITEM_REQUIRED, 0},
165 {"sdpassword", store_password, ITEM(res_store.password), 0, 0, 0},
166 {"device", store_strname, ITEM(res_store.dev_name), 0, ITEM_REQUIRED, 0},
167 {"sddevicename", store_strname, ITEM(res_store.dev_name), 0, 0, 0},
168 {"mediatype", store_strname, ITEM(res_store.media_type), 0, ITEM_REQUIRED, 0},
169 {"autochanger", store_yesno, ITEM(res_store.autochanger), 1, ITEM_DEFAULT, 0},
170 {"enablessl", store_yesno, ITEM(res_store.enable_ssl), 1, ITEM_DEFAULT, 0},
171 {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
172 {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */
173 {NULL, NULL, NULL, 0, 0, 0}
177 * Catalog Resource Directives
179 * name handler value code flags default_value
181 static RES_ITEM cat_items[] = {
182 {"name", store_name, ITEM(res_cat.hdr.name), 0, ITEM_REQUIRED, 0},
183 {"description", store_str, ITEM(res_cat.hdr.desc), 0, 0, 0},
184 {"address", store_str, ITEM(res_cat.db_address), 0, 0, 0},
185 {"dbaddress", store_str, ITEM(res_cat.db_address), 0, 0, 0},
186 {"dbport", store_pint, ITEM(res_cat.db_port), 0, 0, 0},
187 /* keep this password as store_str for the moment */
188 {"password", store_str, ITEM(res_cat.db_password), 0, 0, 0},
189 {"dbpassword", store_str, ITEM(res_cat.db_password), 0, 0, 0},
190 {"user", store_str, ITEM(res_cat.db_user), 0, 0, 0},
191 {"dbname", store_str, ITEM(res_cat.db_name), 0, ITEM_REQUIRED, 0},
192 {"dbsocket", store_str, ITEM(res_cat.db_socket), 0, 0, 0},
193 {NULL, NULL, NULL, 0, 0, 0}
197 * Job Resource Directives
199 * name handler value code flags default_value
201 RES_ITEM job_items[] = {
202 {"name", store_name, ITEM(res_job.hdr.name), 0, ITEM_REQUIRED, 0},
203 {"description", store_str, ITEM(res_job.hdr.desc), 0, 0, 0},
204 {"type", store_jobtype, ITEM(res_job.JobType), 0, ITEM_REQUIRED, 0},
205 {"level", store_level, ITEM(res_job.level), 0, 0, 0},
206 {"messages", store_res, ITEM(res_job.messages), R_MSGS, ITEM_REQUIRED, 0},
207 {"storage", store_res, ITEM(res_job.storage), R_STORAGE, ITEM_REQUIRED, 0},
208 {"pool", store_res, ITEM(res_job.pool), R_POOL, ITEM_REQUIRED, 0},
209 {"fullbackuppool", store_res, ITEM(res_job.full_pool), R_POOL, 0, 0},
210 {"incrementalbackuppool", store_res, ITEM(res_job.inc_pool), R_POOL, 0, 0},
211 {"differentialbackuppool", store_res, ITEM(res_job.dif_pool), R_POOL, 0, 0},
212 {"client", store_res, ITEM(res_job.client), R_CLIENT, ITEM_REQUIRED, 0},
213 {"fileset", store_res, ITEM(res_job.fileset), R_FILESET, ITEM_REQUIRED, 0},
214 {"schedule", store_res, ITEM(res_job.schedule), R_SCHEDULE, 0, 0},
215 {"verifyjob", store_res, ITEM(res_job.verify_job), R_JOB, 0, 0},
216 {"jobdefs", store_res, ITEM(res_job.jobdefs), R_JOBDEFS, 0, 0},
217 {"where", store_dir, ITEM(res_job.RestoreWhere), 0, 0, 0},
218 {"bootstrap",store_dir, ITEM(res_job.RestoreBootstrap), 0, 0, 0},
219 {"writebootstrap",store_dir, ITEM(res_job.WriteBootstrap), 0, 0, 0},
220 {"replace", store_replace, ITEM(res_job.replace), 0, ITEM_DEFAULT, REPLACE_ALWAYS},
221 {"maxruntime", store_time, ITEM(res_job.MaxRunTime), 0, 0, 0},
222 {"maxwaittime", store_time, ITEM(res_job.MaxWaitTime), 0, 0, 0},
223 {"maxstartdelay",store_time, ITEM(res_job.MaxStartDelay), 0, 0, 0},
224 {"jobretention", store_time, ITEM(res_job.JobRetention), 0, 0, 0},
225 {"prefixlinks", store_yesno, ITEM(res_job.PrefixLinks), 1, ITEM_DEFAULT, 0},
226 {"prunejobs", store_yesno, ITEM(res_job.PruneJobs), 1, ITEM_DEFAULT, 0},
227 {"prunefiles", store_yesno, ITEM(res_job.PruneFiles), 1, ITEM_DEFAULT, 0},
228 {"prunevolumes",store_yesno, ITEM(res_job.PruneVolumes), 1, ITEM_DEFAULT, 0},
229 {"spoolattributes",store_yesno, ITEM(res_job.SpoolAttributes), 1, ITEM_DEFAULT, 0},
230 {"spooldata", store_yesno, ITEM(res_job.spool_data), 1, ITEM_DEFAULT, 0},
231 {"runbeforejob", store_str, ITEM(res_job.RunBeforeJob), 0, 0, 0},
232 {"runafterjob", store_str, ITEM(res_job.RunAfterJob), 0, 0, 0},
233 {"runafterfailedjob", store_str, ITEM(res_job.RunAfterFailedJob), 0, 0, 0},
234 {"clientrunbeforejob", store_str, ITEM(res_job.ClientRunBeforeJob), 0, 0, 0},
235 {"clientrunafterjob", store_str, ITEM(res_job.ClientRunAfterJob), 0, 0, 0},
236 {"maximumconcurrentjobs", store_pint, ITEM(res_job.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
237 {"rescheduleonerror", store_yesno, ITEM(res_job.RescheduleOnError), 1, ITEM_DEFAULT, 0},
238 {"rescheduleinterval", store_time, ITEM(res_job.RescheduleInterval), 0, ITEM_DEFAULT, 60 * 30},
239 {"rescheduletimes", store_pint, ITEM(res_job.RescheduleTimes), 0, 0, 0},
240 {"priority", store_pint, ITEM(res_job.Priority), 0, ITEM_DEFAULT, 10},
241 {NULL, NULL, NULL, 0, 0, 0}
246 * name handler value code flags default_value
248 static RES_ITEM fs_items[] = {
249 {"name", store_name, ITEM(res_fs.hdr.name), 0, ITEM_REQUIRED, 0},
250 {"description", store_str, ITEM(res_fs.hdr.desc), 0, 0, 0},
251 {"include", store_inc, NULL, 0, ITEM_NO_EQUALS, 0},
252 {"exclude", store_inc, NULL, 1, ITEM_NO_EQUALS, 0},
253 {"ignorefilesetchanges", store_yesno, ITEM(res_fs.ignore_fs_changes), 1, ITEM_DEFAULT, 0},
254 {NULL, NULL, NULL, 0, 0, 0}
257 /* Schedule -- see run_conf.c */
260 * name handler value code flags default_value
262 static RES_ITEM sch_items[] = {
263 {"name", store_name, ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0},
264 {"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0},
265 {"run", store_run, ITEM(res_sch.run), 0, 0, 0},
266 {NULL, NULL, NULL, 0, 0, 0}
271 * name handler value code flags default_value
273 static RES_ITEM pool_items[] = {
274 {"name", store_name, ITEM(res_pool.hdr.name), 0, ITEM_REQUIRED, 0},
275 {"description", store_str, ITEM(res_pool.hdr.desc), 0, 0, 0},
276 {"pooltype", store_strname, ITEM(res_pool.pool_type), 0, ITEM_REQUIRED, 0},
277 {"labelformat", store_strname, ITEM(res_pool.label_format), 0, 0, 0},
278 {"cleaningprefix", store_strname, ITEM(res_pool.cleaning_prefix), 0, 0, 0},
279 {"usecatalog", store_yesno, ITEM(res_pool.use_catalog), 1, ITEM_DEFAULT, 1},
280 {"usevolumeonce", store_yesno, ITEM(res_pool.use_volume_once), 1, 0, 0},
281 {"purgeoldestvolume", store_yesno, ITEM(res_pool.purge_oldest_volume), 1, 0, 0},
282 {"recycleoldestvolume", store_yesno, ITEM(res_pool.recycle_oldest_volume), 1, 0, 0},
283 {"recyclecurrentvolume", store_yesno, ITEM(res_pool.recycle_current_volume), 1, 0, 0},
284 {"maximumvolumes", store_pint, ITEM(res_pool.max_volumes), 0, 0, 0},
285 {"maximumvolumejobs", store_pint, ITEM(res_pool.MaxVolJobs), 0, 0, 0},
286 {"maximumvolumefiles", store_pint, ITEM(res_pool.MaxVolFiles), 0, 0, 0},
287 {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes), 0, 0, 0},
288 {"acceptanyvolume", store_yesno, ITEM(res_pool.accept_any_volume), 1, ITEM_DEFAULT, 1},
289 {"catalogfiles", store_yesno, ITEM(res_pool.catalog_files), 1, ITEM_DEFAULT, 1},
290 {"volumeretention", store_time, ITEM(res_pool.VolRetention), 0, ITEM_DEFAULT, 60*60*24*365},
291 {"volumeuseduration", store_time, ITEM(res_pool.VolUseDuration),0, 0, 0},
292 {"autoprune", store_yesno, ITEM(res_pool.AutoPrune), 1, ITEM_DEFAULT, 1},
293 {"recycle", store_yesno, ITEM(res_pool.Recycle), 1, ITEM_DEFAULT, 1},
294 {NULL, NULL, NULL, 0, 0, 0}
299 * name handler value code flags default_value
301 static RES_ITEM counter_items[] = {
302 {"name", store_name, ITEM(res_counter.hdr.name), 0, ITEM_REQUIRED, 0},
303 {"description", store_str, ITEM(res_counter.hdr.desc), 0, 0, 0},
304 {"minimum", store_int, ITEM(res_counter.MinValue), 0, ITEM_DEFAULT, 0},
305 {"maximum", store_pint, ITEM(res_counter.MaxValue), 0, ITEM_DEFAULT, INT32_MAX},
306 {"wrapcounter", store_res, ITEM(res_counter.WrapCounter), R_COUNTER, 0, 0},
307 {"catalog", store_res, ITEM(res_counter.Catalog), R_CATALOG, 0, 0},
308 {NULL, NULL, NULL, 0, 0, 0}
312 /* Message resource */
313 extern RES_ITEM msgs_items[];
316 * This is the master resource definition.
317 * It must have one item for each of the resources.
319 * NOTE!!! keep it in the same order as the R_codes
320 * or eliminate all resources[rindex].name
322 * name items rcode res_head
324 RES_TABLE resources[] = {
325 {"director", dir_items, R_DIRECTOR},
326 {"client", cli_items, R_CLIENT},
327 {"job", job_items, R_JOB},
328 {"storage", store_items, R_STORAGE},
329 {"catalog", cat_items, R_CATALOG},
330 {"schedule", sch_items, R_SCHEDULE},
331 {"fileset", fs_items, R_FILESET},
332 {"pool", pool_items, R_POOL},
333 {"messages", msgs_items, R_MSGS},
334 {"counter", counter_items, R_COUNTER},
335 {"console", con_items, R_CONSOLE},
336 {"jobdefs", job_items, R_JOBDEFS},
341 /* Keywords (RHS) permitted in Job Level records
343 * level_name level job_type
345 struct s_jl joblevels[] = {
346 {"Full", L_FULL, JT_BACKUP},
347 {"Base", L_BASE, JT_BACKUP},
348 {"Incremental", L_INCREMENTAL, JT_BACKUP},
349 {"Differential", L_DIFFERENTIAL, JT_BACKUP},
350 {"Since", L_SINCE, JT_BACKUP},
351 {"Catalog", L_VERIFY_CATALOG, JT_VERIFY},
352 {"InitCatalog", L_VERIFY_INIT, JT_VERIFY},
353 {"VolumeToCatalog", L_VERIFY_VOLUME_TO_CATALOG, JT_VERIFY},
354 {"DiskToCatalog", L_VERIFY_DISK_TO_CATALOG, JT_VERIFY},
355 {"Data", L_VERIFY_DATA, JT_VERIFY},
356 {" ", L_NONE, JT_ADMIN},
357 {" ", L_NONE, JT_RESTORE},
361 /* Keywords (RHS) permitted in Job type records
365 struct s_jt jobtypes[] = {
366 {"backup", JT_BACKUP},
368 {"verify", JT_VERIFY},
369 {"restore", JT_RESTORE},
373 #ifdef old_deprecated_code
375 /* Keywords (RHS) permitted in Backup and Verify records */
376 static struct s_kw BakVerFields[] = {
383 /* Keywords (RHS) permitted in Restore records */
384 static struct s_kw RestoreFields[] = {
387 {"jobid", 'J'}, /* JobId to restore */
388 {"where", 'W'}, /* root of restore */
389 {"replace", 'R'}, /* replacement options */
390 {"bootstrap", 'B'}, /* bootstrap file */
395 /* Options permitted in Restore replace= */
396 struct s_kw ReplaceOptions[] = {
397 {"always", REPLACE_ALWAYS},
398 {"ifnewer", REPLACE_IFNEWER},
399 {"ifolder", REPLACE_IFOLDER},
400 {"never", REPLACE_NEVER},
404 const char *level_to_str(int level)
407 static char level_no[30];
408 const char *str = level_no;
410 bsnprintf(level_no, sizeof(level_no), "%d", level); /* default if not found */
411 for (i=0; joblevels[i].level_name; i++) {
412 if (level == joblevels[i].level) {
413 str = joblevels[i].level_name;
420 /* Dump contents of resource */
421 void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
423 URES *res = (URES *)reshdr;
425 char ed1[100], ed2[100];
428 sendit(sock, "No %s resource defined\n", res_to_str(type));
431 if (type < 0) { /* no recursion */
437 sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n",
438 reshdr->name, res->res_dir.MaxConcurrentJobs,
439 edit_uint64(res->res_dir.FDConnectTimeout, ed1),
440 edit_uint64(res->res_dir.SDConnectTimeout, ed2));
441 if (res->res_dir.query_file) {
442 sendit(sock, " query_file=%s\n", res->res_dir.query_file);
444 if (res->res_dir.messages) {
445 sendit(sock, " --> ");
446 dump_resource(-R_MSGS, (RES *)res->res_dir.messages, sendit, sock);
450 sendit(sock, "Console: name=%s SSL=%d\n",
451 res->res_con.hdr.name, res->res_con.enable_ssl);
454 if (res->res_counter.WrapCounter) {
455 sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n",
456 res->res_counter.hdr.name, res->res_counter.MinValue,
457 res->res_counter.MaxValue, res->res_counter.CurrentValue,
458 res->res_counter.WrapCounter->hdr.name);
460 sendit(sock, "Counter: name=%s min=%d max=%d\n",
461 res->res_counter.hdr.name, res->res_counter.MinValue,
462 res->res_counter.MaxValue);
464 if (res->res_counter.Catalog) {
465 sendit(sock, " --> ");
466 dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock);
471 sendit(sock, "Client: name=%s address=%s FDport=%d MaxJobs=%u\n",
472 res->res_client.hdr.name, res->res_client.address, res->res_client.FDport,
473 res->res_client.MaxConcurrentJobs);
474 sendit(sock, " JobRetention=%s FileRetention=%s AutoPrune=%d\n",
475 edit_utime(res->res_client.JobRetention, ed1, sizeof(ed1)),
476 edit_utime(res->res_client.FileRetention, ed2, sizeof(ed2)),
477 res->res_client.AutoPrune);
478 if (res->res_client.catalog) {
479 sendit(sock, " --> ");
480 dump_resource(-R_CATALOG, (RES *)res->res_client.catalog, sendit, sock);
484 sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n\
485 DeviceName=%s MediaType=%s\n",
486 res->res_store.hdr.name, res->res_store.address, res->res_store.SDport,
487 res->res_store.MaxConcurrentJobs,
488 res->res_store.dev_name, res->res_store.media_type);
491 sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n\
493 res->res_cat.hdr.name, NPRT(res->res_cat.db_address),
494 res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user));
498 sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n",
499 type == R_JOB ? "Job" : "JobDefs",
500 res->res_job.hdr.name, res->res_job.JobType,
501 level_to_str(res->res_job.level), res->res_job.Priority,
502 res->res_job.MaxConcurrentJobs);
503 sendit(sock, " Resched=%d Times=%d Interval=%s Spool=%d\n",
504 res->res_job.RescheduleOnError, res->res_job.RescheduleTimes,
505 edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1),
506 res->res_job.spool_data);
507 if (res->res_job.client) {
508 sendit(sock, " --> ");
509 dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
511 if (res->res_job.fileset) {
512 sendit(sock, " --> ");
513 dump_resource(-R_FILESET, (RES *)res->res_job.fileset, sendit, sock);
515 if (res->res_job.schedule) {
516 sendit(sock, " --> ");
517 dump_resource(-R_SCHEDULE, (RES *)res->res_job.schedule, sendit, sock);
519 if (res->res_job.RestoreWhere) {
520 sendit(sock, " --> Where=%s\n", NPRT(res->res_job.RestoreWhere));
522 if (res->res_job.RestoreBootstrap) {
523 sendit(sock, " --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap));
525 if (res->res_job.RunBeforeJob) {
526 sendit(sock, " --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob));
528 if (res->res_job.RunAfterJob) {
529 sendit(sock, " --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob));
531 if (res->res_job.RunAfterFailedJob) {
532 sendit(sock, " --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob));
534 if (res->res_job.WriteBootstrap) {
535 sendit(sock, " --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap));
537 if (res->res_job.storage) {
538 sendit(sock, " --> ");
539 dump_resource(-R_STORAGE, (RES *)res->res_job.storage, sendit, sock);
541 if (res->res_job.pool) {
542 sendit(sock, " --> ");
543 dump_resource(-R_POOL, (RES *)res->res_job.pool, sendit, sock);
545 if (res->res_job.full_pool) {
546 sendit(sock, " --> ");
547 dump_resource(-R_POOL, (RES *)res->res_job.full_pool, sendit, sock);
549 if (res->res_job.inc_pool) {
550 sendit(sock, " --> ");
551 dump_resource(-R_POOL, (RES *)res->res_job.inc_pool, sendit, sock);
553 if (res->res_job.dif_pool) {
554 sendit(sock, " --> ");
555 dump_resource(-R_POOL, (RES *)res->res_job.dif_pool, sendit, sock);
557 if (res->res_job.verify_job) {
558 sendit(sock, " --> ");
559 dump_resource(-type, (RES *)res->res_job.verify_job, sendit, sock);
562 if (res->res_job.messages) {
563 sendit(sock, " --> ");
564 dump_resource(-R_MSGS, (RES *)res->res_job.messages, sendit, sock);
570 sendit(sock, "FileSet: name=%s\n", res->res_fs.hdr.name);
571 for (i=0; i<res->res_fs.num_includes; i++) {
572 INCEXE *incexe = res->res_fs.include_items[i];
573 for (j=0; j<incexe->num_opts; j++) {
574 FOPTS *fo = incexe->opts_list[j];
575 sendit(sock, " O %s\n", fo->opts);
576 for (k=0; k<fo->regex.size(); k++) {
577 sendit(sock, " R %s\n", fo->regex.get(k));
579 for (k=0; k<fo->wild.size(); k++) {
580 sendit(sock, " W %s\n", fo->wild.get(k));
582 for (k=0; k<fo->base.size(); k++) {
583 sendit(sock, " B %s\n", fo->base.get(k));
586 sendit(sock, " D %s\n", fo->reader);
589 sendit(sock, " T %s\n", fo->writer);
591 sendit(sock, " N\n");
593 for (j=0; j<incexe->name_list.size(); j++) {
594 sendit(sock, " I %s\n", incexe->name_list.get(j));
596 if (incexe->name_list.size()) {
597 sendit(sock, " N\n");
601 for (i=0; i<res->res_fs.num_excludes; i++) {
602 INCEXE *incexe = res->res_fs.exclude_items[i];
603 for (j=0; j<incexe->name_list.size(); j++) {
604 sendit(sock, " E %s\n", incexe->name_list.get(j));
606 if (incexe->name_list.size()) {
607 sendit(sock, " N\n");
613 if (res->res_sch.run) {
615 RUN *run = res->res_sch.run;
616 char buf[1000], num[30];
617 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
622 sendit(sock, " --> Run Level=%s\n", level_to_str(run->level));
623 bstrncpy(buf, " hour=", sizeof(buf));
624 for (i=0; i<24; i++) {
625 if (bit_is_set(i, run->hour)) {
626 bsnprintf(num, sizeof(num), "%d ", i);
627 bstrncat(buf, num, sizeof(buf));
630 bstrncat(buf, "\n", sizeof(buf));
632 bstrncpy(buf, " mday=", sizeof(buf));
633 for (i=0; i<31; i++) {
634 if (bit_is_set(i, run->mday)) {
635 bsnprintf(num, sizeof(num), "%d ", i);
636 bstrncat(buf, num, sizeof(buf));
639 bstrncat(buf, "\n", sizeof(buf));
641 bstrncpy(buf, " month=", sizeof(buf));
642 for (i=0; i<12; i++) {
643 if (bit_is_set(i, run->month)) {
644 bsnprintf(num, sizeof(num), "%d ", i);
645 bstrncat(buf, num, sizeof(buf));
648 bstrncat(buf, "\n", sizeof(buf));
650 bstrncpy(buf, " wday=", sizeof(buf));
651 for (i=0; i<7; i++) {
652 if (bit_is_set(i, run->wday)) {
653 bsnprintf(num, sizeof(num), "%d ", i);
654 bstrncat(buf, num, sizeof(buf));
657 bstrncat(buf, "\n", sizeof(buf));
659 bstrncpy(buf, " wom=", sizeof(buf));
660 for (i=0; i<5; i++) {
661 if (bit_is_set(i, run->wom)) {
662 bsnprintf(num, sizeof(num), "%d ", i);
663 bstrncat(buf, num, sizeof(buf));
666 bstrncat(buf, "\n", sizeof(buf));
668 bstrncpy(buf, " woy=", sizeof(buf));
669 for (i=0; i<54; i++) {
670 if (bit_is_set(i, run->woy)) {
671 bsnprintf(num, sizeof(num), "%d ", i);
672 bstrncat(buf, num, sizeof(buf));
675 bstrncat(buf, "\n", sizeof(buf));
677 sendit(sock, " mins=%d\n", run->minute);
679 sendit(sock, " --> ");
680 dump_resource(-R_POOL, (RES *)run->pool, sendit, sock);
683 sendit(sock, " --> ");
684 dump_resource(-R_STORAGE, (RES *)run->storage, sendit, sock);
687 sendit(sock, " --> ");
688 dump_resource(-R_MSGS, (RES *)run->msgs, sendit, sock);
690 /* If another Run record is chained in, go print it */
696 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
700 sendit(sock, "Pool: name=%s PoolType=%s\n", res->res_pool.hdr.name,
701 res->res_pool.pool_type);
702 sendit(sock, " use_cat=%d use_once=%d acpt_any=%d cat_files=%d\n",
703 res->res_pool.use_catalog, res->res_pool.use_volume_once,
704 res->res_pool.accept_any_volume, res->res_pool.catalog_files);
705 sendit(sock, " max_vols=%d auto_prune=%d VolRetention=%s\n",
706 res->res_pool.max_volumes, res->res_pool.AutoPrune,
707 edit_utime(res->res_pool.VolRetention, ed1, sizeof(ed1)));
708 sendit(sock, " VolUse=%s recycle=%d LabelFormat=%s\n",
709 edit_utime(res->res_pool.VolUseDuration, ed1, sizeof(ed1)),
710 res->res_pool.Recycle,
711 NPRT(res->res_pool.label_format));
712 sendit(sock, " CleaningPrefix=%s\n",
713 NPRT(res->res_pool.cleaning_prefix));
714 sendit(sock, " recyleOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n",
715 res->res_pool.purge_oldest_volume,
716 res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
719 sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
720 if (res->res_msgs.mail_cmd)
721 sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd);
722 if (res->res_msgs.operator_cmd)
723 sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd);
726 sendit(sock, "Unknown resource type %d in dump_resource.\n", type);
729 if (recurse && res->res_dir.hdr.next) {
730 dump_resource(type, res->res_dir.hdr.next, sendit, sock);
735 * Free all the members of an INCEXE structure
737 static void free_incexe(INCEXE *incexe)
739 incexe->name_list.destroy();
740 for (int i=0; i<incexe->num_opts; i++) {
741 FOPTS *fopt = incexe->opts_list[i];
742 fopt->regex.destroy();
743 fopt->wild.destroy();
744 fopt->base.destroy();
753 if (incexe->opts_list) {
754 free(incexe->opts_list);
760 * Free memory of resource -- called when daemon terminates.
761 * NB, we don't need to worry about freeing any references
762 * to other resources as they will be freed when that
763 * resource chain is traversed. Mainly we worry about freeing
764 * allocated strings (names).
766 void free_resource(RES *sres, int type)
769 RES *nres; /* next resource if linked */
770 URES *res = (URES *)sres;
775 /* common stuff -- free the resource name and description */
776 nres = (RES *)res->res_dir.hdr.next;
777 if (res->res_dir.hdr.name) {
778 free(res->res_dir.hdr.name);
780 if (res->res_dir.hdr.desc) {
781 free(res->res_dir.hdr.desc);
786 if (res->res_dir.working_directory) {
787 free(res->res_dir.working_directory);
789 if (res->res_dir.pid_directory) {
790 free(res->res_dir.pid_directory);
792 if (res->res_dir.subsys_directory) {
793 free(res->res_dir.subsys_directory);
795 if (res->res_dir.password) {
796 free(res->res_dir.password);
798 if (res->res_dir.query_file) {
799 free(res->res_dir.query_file);
801 if (res->res_dir.DIRaddrs) {
802 free_addresses(res->res_dir.DIRaddrs);
808 if (res->res_con.password) {
809 free(res->res_con.password);
811 for (int i=0; i<Num_ACL; i++) {
812 if (res->res_con.ACL_lists[i]) {
813 delete res->res_con.ACL_lists[i];
814 res->res_con.ACL_lists[i] = NULL;
819 if (res->res_client.address) {
820 free(res->res_client.address);
822 if (res->res_client.password) {
823 free(res->res_client.password);
827 if (res->res_store.address) {
828 free(res->res_store.address);
830 if (res->res_store.password) {
831 free(res->res_store.password);
833 if (res->res_store.media_type) {
834 free(res->res_store.media_type);
836 if (res->res_store.dev_name) {
837 free(res->res_store.dev_name);
841 if (res->res_cat.db_address) {
842 free(res->res_cat.db_address);
844 if (res->res_cat.db_socket) {
845 free(res->res_cat.db_socket);
847 if (res->res_cat.db_user) {
848 free(res->res_cat.db_user);
850 if (res->res_cat.db_name) {
851 free(res->res_cat.db_name);
853 if (res->res_cat.db_password) {
854 free(res->res_cat.db_password);
858 if ((num=res->res_fs.num_includes)) {
860 free_incexe(res->res_fs.include_items[num]);
862 free(res->res_fs.include_items);
864 res->res_fs.num_includes = 0;
865 if ((num=res->res_fs.num_excludes)) {
867 free_incexe(res->res_fs.exclude_items[num]);
869 free(res->res_fs.exclude_items);
871 res->res_fs.num_excludes = 0;
874 if (res->res_pool.pool_type) {
875 free(res->res_pool.pool_type);
877 if (res->res_pool.label_format) {
878 free(res->res_pool.label_format);
880 if (res->res_pool.cleaning_prefix) {
881 free(res->res_pool.cleaning_prefix);
885 if (res->res_sch.run) {
887 nrun = res->res_sch.run;
897 if (res->res_job.RestoreWhere) {
898 free(res->res_job.RestoreWhere);
900 if (res->res_job.RestoreBootstrap) {
901 free(res->res_job.RestoreBootstrap);
903 if (res->res_job.WriteBootstrap) {
904 free(res->res_job.WriteBootstrap);
906 if (res->res_job.RunBeforeJob) {
907 free(res->res_job.RunBeforeJob);
909 if (res->res_job.RunAfterJob) {
910 free(res->res_job.RunAfterJob);
912 if (res->res_job.RunAfterFailedJob) {
913 free(res->res_job.RunAfterFailedJob);
915 if (res->res_job.ClientRunBeforeJob) {
916 free(res->res_job.ClientRunBeforeJob);
918 if (res->res_job.ClientRunAfterJob) {
919 free(res->res_job.ClientRunAfterJob);
923 if (res->res_msgs.mail_cmd) {
924 free(res->res_msgs.mail_cmd);
926 if (res->res_msgs.operator_cmd) {
927 free(res->res_msgs.operator_cmd);
929 free_msgs_res((MSGS *)res); /* free message resource */
933 printf("Unknown resource type %d in free_resource.\n", type);
935 /* Common stuff again -- free the resource, recurse to next one */
940 free_resource(nres, type);
945 * Save the new resource by chaining it into the head list for
946 * the resource. If this is pass 2, we update any resource
947 * pointers because they may not have been defined until
950 void save_resource(int type, RES_ITEM *items, int pass)
953 int rindex = type - r_first;
957 /* Check Job requirements after applying JobDefs */
958 if (type != R_JOB && type != R_JOBDEFS) {
960 * Ensure that all required items are present
962 for (i=0; items[i].name; i++) {
963 if (items[i].flags & ITEM_REQUIRED) {
964 if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
965 Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n",
966 items[i].name, resources[rindex]);
969 /* If this triggers, take a look at lib/parse_conf.h */
970 if (i >= MAX_RES_ITEMS) {
971 Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]);
977 * During pass 2 in each "store" routine, we looked up pointers
978 * to all the resources referrenced in the current resource, now we
979 * must copy their addresses from the static record to the allocated
984 /* Resources not containing a resource */
993 /* Resources containing another resource */
995 if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) {
996 Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name);
998 res->res_dir.messages = res_all.res_dir.messages;
1002 if ((res = (URES *)GetResWithName(type, res_all.res_dir.hdr.name)) == NULL) {
1003 Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n",
1004 res_all.res_dir.hdr.name);
1006 res->res_job.messages = res_all.res_job.messages;
1007 res->res_job.schedule = res_all.res_job.schedule;
1008 res->res_job.client = res_all.res_job.client;
1009 res->res_job.fileset = res_all.res_job.fileset;
1010 res->res_job.storage = res_all.res_job.storage;
1011 res->res_job.pool = res_all.res_job.pool;
1012 res->res_job.full_pool = res_all.res_job.full_pool;
1013 res->res_job.inc_pool = res_all.res_job.inc_pool;
1014 res->res_job.dif_pool = res_all.res_job.dif_pool;
1015 res->res_job.verify_job = res_all.res_job.verify_job;
1016 res->res_job.jobdefs = res_all.res_job.jobdefs;
1019 if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) {
1020 Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name);
1022 res->res_counter.Catalog = res_all.res_counter.Catalog;
1023 res->res_counter.WrapCounter = res_all.res_counter.WrapCounter;
1027 if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_client.hdr.name)) == NULL) {
1028 Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name);
1030 res->res_client.catalog = res_all.res_client.catalog;
1034 * Schedule is a bit different in that it contains a RUN record
1035 * chain which isn't a "named" resource. This chain was linked
1036 * in by run_conf.c during pass 2, so here we jam the pointer
1037 * into the Schedule resource.
1039 if ((res = (URES *)GetResWithName(R_SCHEDULE, res_all.res_client.hdr.name)) == NULL) {
1040 Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name);
1042 res->res_sch.run = res_all.res_sch.run;
1045 Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type);
1049 /* Note, the resource name was already saved during pass 1,
1050 * so here, we can just release it.
1052 if (res_all.res_dir.hdr.name) {
1053 free(res_all.res_dir.hdr.name);
1054 res_all.res_dir.hdr.name = NULL;
1056 if (res_all.res_dir.hdr.desc) {
1057 free(res_all.res_dir.hdr.desc);
1058 res_all.res_dir.hdr.desc = NULL;
1064 * The following code is only executed during pass 1
1068 size = sizeof(DIRRES);
1071 size = sizeof(CONRES);
1074 size =sizeof(CLIENT);
1077 size = sizeof(STORE);
1087 size = sizeof(FILESET);
1090 size = sizeof(SCHED);
1093 size = sizeof(POOL);
1096 size = sizeof(MSGS);
1099 size = sizeof(COUNTER);
1102 printf("Unknown resource type %d in save_resrouce.\n", type);
1109 res = (URES *)malloc(size);
1110 memcpy(res, &res_all, size);
1111 if (!res_head[rindex]) {
1112 res_head[rindex] = (RES *)res; /* store first entry */
1113 Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
1114 res->res_dir.hdr.name, rindex);
1117 /* Add new res to end of chain */
1118 for (next=res_head[rindex]; next->next; next=next->next) {
1119 if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
1120 Emsg2(M_ERROR_TERM, 0,
1121 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
1122 resources[rindex].name, res->res_dir.hdr.name);
1125 next->next = (RES *)res;
1126 Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
1127 res->res_dir.hdr.name, rindex, pass);
1133 * Store JobType (backup, verify, restore)
1136 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass)
1140 token = lex_get_token(lc, T_NAME);
1141 /* Store the type both pass 1 and pass 2 */
1142 for (i=0; jobtypes[i].type_name; i++) {
1143 if (strcasecmp(lc->str, jobtypes[i].type_name) == 0) {
1144 *(int *)(item->value) = jobtypes[i].job_type;
1150 scan_err1(lc, "Expected a Job Type keyword, got: %s", lc->str);
1153 set_bit(index, res_all.hdr.item_present);
1157 * Store Job Level (Full, Incremental, ...)
1160 void store_level(LEX *lc, RES_ITEM *item, int index, int pass)
1164 token = lex_get_token(lc, T_NAME);
1165 /* Store the level pass 2 so that type is defined */
1166 for (i=0; joblevels[i].level_name; i++) {
1167 if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1168 *(int *)(item->value) = joblevels[i].level;
1174 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1177 set_bit(index, res_all.hdr.item_present);
1180 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass)
1183 token = lex_get_token(lc, T_NAME);
1184 /* Scan Replacement options */
1185 for (i=0; ReplaceOptions[i].name; i++) {
1186 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1187 *(int *)(item->value) = ReplaceOptions[i].token;
1193 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1196 set_bit(index, res_all.hdr.item_present);
1200 * Store ACL (access control list)
1203 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
1208 token = lex_get_token(lc, T_NAME);
1210 if (((alist **)item->value)[item->code] == NULL) {
1211 ((alist **)item->value)[item->code] = New(alist(10, owned_by_alist));
1212 // Dmsg1(900, "Defined new ACL alist at %d\n", item->code);
1214 ((alist **)item->value)[item->code]->append(bstrdup(lc->str));
1215 // Dmsg2(900, "Appended to %d %s\n", item->code, lc->str);
1217 token = lex_get_token(lc, T_ALL);
1218 if (token == T_COMMA) {
1219 continue; /* get another ACL */
1223 set_bit(index, res_all.hdr.item_present);
1227 #ifdef old_deprecated_code
1229 * Store backup/verify info for Job record
1231 * Note, this code is used for both BACKUP and VERIFY jobs
1233 * Backup = Client=<client-name> FileSet=<FileSet-name> Level=<level>
1235 static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
1239 int options = lc->options;
1241 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1244 ((JOB *)(item->value))->JobType = item->code;
1245 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1248 Dmsg1(900, "store_backup got token=%s\n", lex_tok_to_str(token));
1250 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1251 scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
1253 Dmsg1(900, "Got keyword: %s\n", lc->str);
1254 for (i=0; BakVerFields[i].name; i++) {
1255 if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
1257 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1258 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1260 token = lex_get_token(lc, T_NAME);
1261 Dmsg1(900, "Got value: %s\n", lc->str);
1262 switch (BakVerFields[i].token) {
1264 /* Find Client Resource */
1266 res = GetResWithName(R_CLIENT, lc->str);
1268 scan_err1(lc, "Could not find specified Client Resource: %s",
1271 res_all.res_job.client = (CLIENT *)res;
1275 /* Find FileSet Resource */
1277 res = GetResWithName(R_FILESET, lc->str);
1279 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1282 res_all.res_job.fileset = (FILESET *)res;
1287 for (i=0; joblevels[i].level_name; i++) {
1288 if (joblevels[i].job_type == item->code &&
1289 strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1290 ((JOB *)(item->value))->level = joblevels[i].level;
1296 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1301 } /* end if strcmp() */
1304 scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
1307 lc->options = options; /* reset original options */
1308 set_bit(index, res_all.hdr.item_present);
1312 * Store restore info for Job record
1314 * Restore = JobId=<job-id> Where=<root-directory> Replace=<options> Bootstrap=<file>
1317 static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
1321 int options = lc->options;
1323 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1325 Dmsg0(900, "Enter store_restore()\n");
1327 ((JOB *)(item->value))->JobType = item->code;
1328 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1331 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1332 scan_err1(lc, "expected a name, got: %s", lc->str);
1334 for (i=0; RestoreFields[i].name; i++) {
1335 Dmsg1(900, "Restore kw=%s\n", lc->str);
1336 if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
1338 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1339 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1341 token = lex_get_token(lc, T_ALL);
1342 Dmsg1(900, "Restore value=%s\n", lc->str);
1343 switch (RestoreFields[i].token) {
1346 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1347 scan_err1(lc, "Expected a Restore bootstrap file, got: %s", lc->str);
1350 res_all.res_job.RestoreBootstrap = bstrdup(lc->str);
1354 /* Find Client Resource */
1356 res = GetResWithName(R_CLIENT, lc->str);
1358 scan_err1(lc, "Could not find specified Client Resource: %s",
1361 res_all.res_job.client = (CLIENT *)res;
1365 /* Find FileSet Resource */
1367 res = GetResWithName(R_FILESET, lc->str);
1369 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1372 res_all.res_job.fileset = (FILESET *)res;
1377 if (token != T_NUMBER) {
1378 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1381 res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
1382 Dmsg1(900, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
1384 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1389 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1390 scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
1393 res_all.res_job.RestoreWhere = bstrdup(lc->str);
1397 /* Replacement options */
1398 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1399 scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
1401 /* Fix to scan Replacement options */
1402 for (i=0; ReplaceOptions[i].name; i++) {
1403 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1404 ((JOB *)(item->value))->replace = ReplaceOptions[i].token;
1410 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1415 } /* end if strcmp() */
1418 scan_err1(lc, "%s not a valid Restore keyword", lc->str);
1421 lc->options = options; /* reset original options */
1422 set_bit(index, res_all.hdr.item_present);