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_pint, ITEM(res_dir.DIRport), 0, ITEM_DEFAULT, 9101},
93 {"diraddress", store_str, ITEM(res_dir.DIRaddr), 0, 0, 0},
94 {"queryfile", store_dir, ITEM(res_dir.query_file), 0, ITEM_REQUIRED, 0},
95 {"workingdirectory", store_dir, ITEM(res_dir.working_directory), 0, ITEM_REQUIRED, 0},
96 {"piddirectory",store_dir, ITEM(res_dir.pid_directory), 0, ITEM_REQUIRED, 0},
97 {"subsysdirectory", store_dir, ITEM(res_dir.subsys_directory), 0, 0, 0},
98 {"requiressl", store_yesno, ITEM(res_dir.require_ssl), 1, ITEM_DEFAULT, 0},
99 {"enablessl", store_yesno, ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0},
100 {"maximumconcurrentjobs", store_pint, ITEM(res_dir.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
101 {"password", store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0},
102 {"fdconnecttimeout", store_time,ITEM(res_dir.FDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
103 {"sdconnecttimeout", store_time,ITEM(res_dir.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
104 {NULL, NULL, NULL, 0, 0, 0}
110 * name handler value code flags default_value
112 static RES_ITEM con_items[] = {
113 {"name", store_name, ITEM(res_con.hdr.name), 0, ITEM_REQUIRED, 0},
114 {"description", store_str, ITEM(res_con.hdr.desc), 0, 0, 0},
115 {"enablessl", store_yesno, ITEM(res_con.enable_ssl), 1, ITEM_DEFAULT, 0},
116 {"password", store_password, ITEM(res_con.password), 0, ITEM_REQUIRED, 0},
117 {"jobacl", store_acl, ITEM(res_con.ACL_lists), Job_ACL, 0, 0},
118 {"clientacl", store_acl, ITEM(res_con.ACL_lists), Client_ACL, 0, 0},
119 {"storageacl", store_acl, ITEM(res_con.ACL_lists), Storage_ACL, 0, 0},
120 {"scheduleacl", store_acl, ITEM(res_con.ACL_lists), Schedule_ACL, 0, 0},
121 {"runacl", store_acl, ITEM(res_con.ACL_lists), Run_ACL, 0, 0},
122 {"poolacl", store_acl, ITEM(res_con.ACL_lists), Pool_ACL, 0, 0},
123 {"commandacl", store_acl, ITEM(res_con.ACL_lists), Command_ACL, 0, 0},
124 {"filesetacl", store_acl, ITEM(res_con.ACL_lists), FileSet_ACL, 0, 0},
125 {"catalogacl", store_acl, ITEM(res_con.ACL_lists), Catalog_ACL, 0, 0},
126 {NULL, NULL, NULL, 0, 0, 0}
131 * Client or File daemon resource
133 * name handler value code flags default_value
136 static RES_ITEM cli_items[] = {
137 {"name", store_name, ITEM(res_client.hdr.name), 0, ITEM_REQUIRED, 0},
138 {"description", store_str, ITEM(res_client.hdr.desc), 0, 0, 0},
139 {"address", store_str, ITEM(res_client.address), 0, ITEM_REQUIRED, 0},
140 {"fdaddress", store_str, ITEM(res_client.address), 0, 0, 0},
141 {"fdport", store_pint, ITEM(res_client.FDport), 0, ITEM_DEFAULT, 9102},
142 {"password", store_password, ITEM(res_client.password), 0, ITEM_REQUIRED, 0},
143 {"fdpassword", store_password, ITEM(res_client.password), 0, 0, 0},
144 {"catalog", store_res, ITEM(res_client.catalog), R_CATALOG, 0, 0},
145 {"fileretention", store_time, ITEM(res_client.FileRetention), 0, ITEM_DEFAULT, 60*60*24*60},
146 {"jobretention", store_time, ITEM(res_client.JobRetention), 0, ITEM_DEFAULT, 60*60*24*180},
147 {"autoprune", store_yesno, ITEM(res_client.AutoPrune), 1, ITEM_DEFAULT, 1},
148 {"enablessl", store_yesno, ITEM(res_client.enable_ssl), 1, ITEM_DEFAULT, 0},
149 {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
150 {NULL, NULL, NULL, 0, 0, 0}
153 /* Storage daemon resource
155 * name handler value code flags default_value
157 static RES_ITEM store_items[] = {
158 {"name", store_name, ITEM(res_store.hdr.name), 0, ITEM_REQUIRED, 0},
159 {"description", store_str, ITEM(res_store.hdr.desc), 0, 0, 0},
160 {"sdport", store_pint, ITEM(res_store.SDport), 0, ITEM_DEFAULT, 9103},
161 {"address", store_str, ITEM(res_store.address), 0, ITEM_REQUIRED, 0},
162 {"sdaddress", store_str, ITEM(res_store.address), 0, 0, 0},
163 {"password", store_password, ITEM(res_store.password), 0, ITEM_REQUIRED, 0},
164 {"sdpassword", store_password, ITEM(res_store.password), 0, 0, 0},
165 {"device", store_strname, ITEM(res_store.dev_name), 0, ITEM_REQUIRED, 0},
166 {"sddevicename", store_strname, ITEM(res_store.dev_name), 0, 0, 0},
167 {"mediatype", store_strname, ITEM(res_store.media_type), 0, ITEM_REQUIRED, 0},
168 {"autochanger", store_yesno, ITEM(res_store.autochanger), 1, ITEM_DEFAULT, 0},
169 {"enablessl", store_yesno, ITEM(res_store.enable_ssl), 1, ITEM_DEFAULT, 0},
170 {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
171 {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */
172 {NULL, NULL, NULL, 0, 0, 0}
176 * Catalog Resource Directives
178 * name handler value code flags default_value
180 static RES_ITEM cat_items[] = {
181 {"name", store_name, ITEM(res_cat.hdr.name), 0, ITEM_REQUIRED, 0},
182 {"description", store_str, ITEM(res_cat.hdr.desc), 0, 0, 0},
183 {"address", store_str, ITEM(res_cat.db_address), 0, 0, 0},
184 {"dbaddress", store_str, ITEM(res_cat.db_address), 0, 0, 0},
185 {"dbport", store_pint, ITEM(res_cat.db_port), 0, 0, 0},
186 /* keep this password as store_str for the moment */
187 {"password", store_str, ITEM(res_cat.db_password), 0, 0, 0},
188 {"dbpassword", store_str, ITEM(res_cat.db_password), 0, 0, 0},
189 {"user", store_str, ITEM(res_cat.db_user), 0, 0, 0},
190 {"dbname", store_str, ITEM(res_cat.db_name), 0, ITEM_REQUIRED, 0},
191 {"dbsocket", store_str, ITEM(res_cat.db_socket), 0, 0, 0},
192 {NULL, NULL, NULL, 0, 0, 0}
196 * Job Resource Directives
198 * name handler value code flags default_value
200 RES_ITEM job_items[] = {
201 {"name", store_name, ITEM(res_job.hdr.name), 0, ITEM_REQUIRED, 0},
202 {"description", store_str, ITEM(res_job.hdr.desc), 0, 0, 0},
203 {"type", store_jobtype, ITEM(res_job.JobType), 0, ITEM_REQUIRED, 0},
204 {"level", store_level, ITEM(res_job.level), 0, 0, 0},
205 {"messages", store_res, ITEM(res_job.messages), R_MSGS, ITEM_REQUIRED, 0},
206 {"storage", store_res, ITEM(res_job.storage), R_STORAGE, ITEM_REQUIRED, 0},
207 {"pool", store_res, ITEM(res_job.pool), R_POOL, ITEM_REQUIRED, 0},
208 {"fullbackuppool", store_res, ITEM(res_job.full_pool), R_POOL, 0, 0},
209 {"incrementalbackuppool", store_res, ITEM(res_job.inc_pool), R_POOL, 0, 0},
210 {"differentialbackuppool", store_res, ITEM(res_job.dif_pool), R_POOL, 0, 0},
211 {"client", store_res, ITEM(res_job.client), R_CLIENT, ITEM_REQUIRED, 0},
212 {"fileset", store_res, ITEM(res_job.fileset), R_FILESET, ITEM_REQUIRED, 0},
213 {"schedule", store_res, ITEM(res_job.schedule), R_SCHEDULE, 0, 0},
214 {"verifyjob", store_res, ITEM(res_job.verify_job), R_JOB, 0, 0},
215 {"jobdefs", store_res, ITEM(res_job.jobdefs), R_JOBDEFS, 0, 0},
216 {"where", store_dir, ITEM(res_job.RestoreWhere), 0, 0, 0},
217 {"bootstrap",store_dir, ITEM(res_job.RestoreBootstrap), 0, 0, 0},
218 {"writebootstrap",store_dir, ITEM(res_job.WriteBootstrap), 0, 0, 0},
219 {"replace", store_replace, ITEM(res_job.replace), 0, ITEM_DEFAULT, REPLACE_ALWAYS},
220 {"maxruntime", store_time, ITEM(res_job.MaxRunTime), 0, 0, 0},
221 {"maxwaittime", store_time, ITEM(res_job.MaxWaitTime), 0, 0, 0},
222 {"maxstartdelay",store_time, ITEM(res_job.MaxStartDelay), 0, 0, 0},
223 {"jobretention", store_time, ITEM(res_job.JobRetention), 0, 0, 0},
224 {"prefixlinks", store_yesno, ITEM(res_job.PrefixLinks), 1, ITEM_DEFAULT, 0},
225 {"prunejobs", store_yesno, ITEM(res_job.PruneJobs), 1, ITEM_DEFAULT, 0},
226 {"prunefiles", store_yesno, ITEM(res_job.PruneFiles), 1, ITEM_DEFAULT, 0},
227 {"prunevolumes",store_yesno, ITEM(res_job.PruneVolumes), 1, ITEM_DEFAULT, 0},
228 {"spoolattributes",store_yesno, ITEM(res_job.SpoolAttributes), 1, ITEM_DEFAULT, 0},
229 {"spooldata", store_yesno, ITEM(res_job.spool_data), 1, ITEM_DEFAULT, 0},
230 {"runbeforejob", store_str, ITEM(res_job.RunBeforeJob), 0, 0, 0},
231 {"runafterjob", store_str, ITEM(res_job.RunAfterJob), 0, 0, 0},
232 {"runafterfailedjob", store_str, ITEM(res_job.RunAfterFailedJob), 0, 0, 0},
233 {"clientrunbeforejob", store_str, ITEM(res_job.ClientRunBeforeJob), 0, 0, 0},
234 {"clientrunafterjob", store_str, ITEM(res_job.ClientRunAfterJob), 0, 0, 0},
235 {"maximumconcurrentjobs", store_pint, ITEM(res_job.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
236 {"rescheduleonerror", store_yesno, ITEM(res_job.RescheduleOnError), 1, ITEM_DEFAULT, 0},
237 {"rescheduleinterval", store_time, ITEM(res_job.RescheduleInterval), 0, ITEM_DEFAULT, 60 * 30},
238 {"rescheduletimes", store_pint, ITEM(res_job.RescheduleTimes), 0, 0, 0},
239 {"priority", store_pint, ITEM(res_job.Priority), 0, ITEM_DEFAULT, 10},
240 {NULL, NULL, NULL, 0, 0, 0}
245 * name handler value code flags default_value
247 static RES_ITEM fs_items[] = {
248 {"name", store_name, ITEM(res_fs.hdr.name), 0, ITEM_REQUIRED, 0},
249 {"description", store_str, ITEM(res_fs.hdr.desc), 0, 0, 0},
250 {"include", store_inc, NULL, 0, ITEM_NO_EQUALS, 0},
251 {"exclude", store_inc, NULL, 1, ITEM_NO_EQUALS, 0},
252 {NULL, NULL, NULL, 0, 0, 0}
255 /* Schedule -- see run_conf.c */
258 * name handler value code flags default_value
260 static RES_ITEM sch_items[] = {
261 {"name", store_name, ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0},
262 {"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0},
263 {"run", store_run, ITEM(res_sch.run), 0, 0, 0},
264 {NULL, NULL, NULL, 0, 0, 0}
269 * name handler value code flags default_value
271 static RES_ITEM pool_items[] = {
272 {"name", store_name, ITEM(res_pool.hdr.name), 0, ITEM_REQUIRED, 0},
273 {"description", store_str, ITEM(res_pool.hdr.desc), 0, 0, 0},
274 {"pooltype", store_strname, ITEM(res_pool.pool_type), 0, ITEM_REQUIRED, 0},
275 {"labelformat", store_strname, ITEM(res_pool.label_format), 0, 0, 0},
276 {"cleaningprefix", store_strname, ITEM(res_pool.cleaning_prefix), 0, 0, 0},
277 {"usecatalog", store_yesno, ITEM(res_pool.use_catalog), 1, ITEM_DEFAULT, 1},
278 {"usevolumeonce", store_yesno, ITEM(res_pool.use_volume_once), 1, 0, 0},
279 {"purgeoldestvolume", store_yesno, ITEM(res_pool.purge_oldest_volume), 1, 0, 0},
280 {"recycleoldestvolume", store_yesno, ITEM(res_pool.recycle_oldest_volume), 1, 0, 0},
281 {"recyclecurrentvolume", store_yesno, ITEM(res_pool.recycle_current_volume), 1, 0, 0},
282 {"maximumvolumes", store_pint, ITEM(res_pool.max_volumes), 0, 0, 0},
283 {"maximumvolumejobs", store_pint, ITEM(res_pool.MaxVolJobs), 0, 0, 0},
284 {"maximumvolumefiles", store_pint, ITEM(res_pool.MaxVolFiles), 0, 0, 0},
285 {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes), 0, 0, 0},
286 {"acceptanyvolume", store_yesno, ITEM(res_pool.accept_any_volume), 1, ITEM_DEFAULT, 1},
287 {"catalogfiles", store_yesno, ITEM(res_pool.catalog_files), 1, ITEM_DEFAULT, 1},
288 {"volumeretention", store_time, ITEM(res_pool.VolRetention), 0, ITEM_DEFAULT, 60*60*24*365},
289 {"volumeuseduration", store_time, ITEM(res_pool.VolUseDuration),0, 0, 0},
290 {"autoprune", store_yesno, ITEM(res_pool.AutoPrune), 1, ITEM_DEFAULT, 1},
291 {"recycle", store_yesno, ITEM(res_pool.Recycle), 1, ITEM_DEFAULT, 1},
292 {NULL, NULL, NULL, 0, 0, 0}
297 * name handler value code flags default_value
299 static RES_ITEM counter_items[] = {
300 {"name", store_name, ITEM(res_counter.hdr.name), 0, ITEM_REQUIRED, 0},
301 {"description", store_str, ITEM(res_counter.hdr.desc), 0, 0, 0},
302 {"minimum", store_int, ITEM(res_counter.MinValue), 0, ITEM_DEFAULT, 0},
303 {"maximum", store_pint, ITEM(res_counter.MaxValue), 0, ITEM_DEFAULT, INT32_MAX},
304 {"wrapcounter", store_res, ITEM(res_counter.WrapCounter), R_COUNTER, 0, 0},
305 {"catalog", store_res, ITEM(res_counter.Catalog), R_CATALOG, 0, 0},
306 {NULL, NULL, NULL, 0, 0, 0}
310 /* Message resource */
311 extern RES_ITEM msgs_items[];
314 * This is the master resource definition.
315 * It must have one item for each of the resources.
317 * NOTE!!! keep it in the same order as the R_codes
318 * or eliminate all resources[rindex].name
320 * name items rcode res_head
322 RES_TABLE resources[] = {
323 {"director", dir_items, R_DIRECTOR},
324 {"client", cli_items, R_CLIENT},
325 {"job", job_items, R_JOB},
326 {"storage", store_items, R_STORAGE},
327 {"catalog", cat_items, R_CATALOG},
328 {"schedule", sch_items, R_SCHEDULE},
329 {"fileset", fs_items, R_FILESET},
330 {"pool", pool_items, R_POOL},
331 {"messages", msgs_items, R_MSGS},
332 {"counter", counter_items, R_COUNTER},
333 {"console", con_items, R_CONSOLE},
334 {"jobdefs", job_items, R_JOBDEFS},
339 /* Keywords (RHS) permitted in Job Level records
341 * level_name level job_type
343 struct s_jl joblevels[] = {
344 {"Full", L_FULL, JT_BACKUP},
345 {"Base", L_BASE, JT_BACKUP},
346 {"Incremental", L_INCREMENTAL, JT_BACKUP},
347 {"Differential", L_DIFFERENTIAL, JT_BACKUP},
348 {"Since", L_SINCE, JT_BACKUP},
349 {"Catalog", L_VERIFY_CATALOG, JT_VERIFY},
350 {"InitCatalog", L_VERIFY_INIT, JT_VERIFY},
351 {"VolumeToCatalog", L_VERIFY_VOLUME_TO_CATALOG, JT_VERIFY},
352 {"DiskToCatalog", L_VERIFY_DISK_TO_CATALOG, JT_VERIFY},
353 {"Data", L_VERIFY_DATA, JT_VERIFY},
354 {" ", L_NONE, JT_ADMIN},
355 {" ", L_NONE, JT_RESTORE},
359 /* Keywords (RHS) permitted in Job type records
363 struct s_jt jobtypes[] = {
364 {"backup", JT_BACKUP},
366 {"verify", JT_VERIFY},
367 {"restore", JT_RESTORE},
371 #ifdef old_deprecated_code
373 /* Keywords (RHS) permitted in Backup and Verify records */
374 static struct s_kw BakVerFields[] = {
381 /* Keywords (RHS) permitted in Restore records */
382 static struct s_kw RestoreFields[] = {
385 {"jobid", 'J'}, /* JobId to restore */
386 {"where", 'W'}, /* root of restore */
387 {"replace", 'R'}, /* replacement options */
388 {"bootstrap", 'B'}, /* bootstrap file */
393 /* Options permitted in Restore replace= */
394 struct s_kw ReplaceOptions[] = {
395 {"always", REPLACE_ALWAYS},
396 {"ifnewer", REPLACE_IFNEWER},
397 {"ifolder", REPLACE_IFOLDER},
398 {"never", REPLACE_NEVER},
402 const char *level_to_str(int level)
405 static char level_no[30];
406 const char *str = level_no;
408 bsnprintf(level_no, sizeof(level_no), "%d", level); /* default if not found */
409 for (i=0; joblevels[i].level_name; i++) {
410 if (level == joblevels[i].level) {
411 str = joblevels[i].level_name;
418 /* Dump contents of resource */
419 void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
421 URES *res = (URES *)reshdr;
423 char ed1[100], ed2[100];
426 sendit(sock, "No %s resource defined\n", res_to_str(type));
429 if (type < 0) { /* no recursion */
435 sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n",
436 reshdr->name, res->res_dir.MaxConcurrentJobs,
437 edit_uint64(res->res_dir.FDConnectTimeout, ed1),
438 edit_uint64(res->res_dir.SDConnectTimeout, ed2));
439 if (res->res_dir.query_file) {
440 sendit(sock, " query_file=%s\n", res->res_dir.query_file);
442 if (res->res_dir.messages) {
443 sendit(sock, " --> ");
444 dump_resource(-R_MSGS, (RES *)res->res_dir.messages, sendit, sock);
448 sendit(sock, "Console: name=%s SSL=%d\n",
449 res->res_con.hdr.name, res->res_con.enable_ssl);
452 if (res->res_counter.WrapCounter) {
453 sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n",
454 res->res_counter.hdr.name, res->res_counter.MinValue,
455 res->res_counter.MaxValue, res->res_counter.CurrentValue,
456 res->res_counter.WrapCounter->hdr.name);
458 sendit(sock, "Counter: name=%s min=%d max=%d\n",
459 res->res_counter.hdr.name, res->res_counter.MinValue,
460 res->res_counter.MaxValue);
462 if (res->res_counter.Catalog) {
463 sendit(sock, " --> ");
464 dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock);
469 sendit(sock, "Client: name=%s address=%s FDport=%d MaxJobs=%u\n",
470 res->res_client.hdr.name, res->res_client.address, res->res_client.FDport,
471 res->res_client.MaxConcurrentJobs);
472 sendit(sock, " JobRetention=%s FileRetention=%s AutoPrune=%d\n",
473 edit_utime(res->res_client.JobRetention, ed1),
474 edit_utime(res->res_client.FileRetention, ed2),
475 res->res_client.AutoPrune);
476 if (res->res_client.catalog) {
477 sendit(sock, " --> ");
478 dump_resource(-R_CATALOG, (RES *)res->res_client.catalog, sendit, sock);
482 sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n\
483 DeviceName=%s MediaType=%s\n",
484 res->res_store.hdr.name, res->res_store.address, res->res_store.SDport,
485 res->res_store.MaxConcurrentJobs,
486 res->res_store.dev_name, res->res_store.media_type);
489 sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n\
491 res->res_cat.hdr.name, NPRT(res->res_cat.db_address),
492 res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user));
496 sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n",
497 type == R_JOB ? "Job" : "JobDefs",
498 res->res_job.hdr.name, res->res_job.JobType,
499 level_to_str(res->res_job.level), res->res_job.Priority,
500 res->res_job.MaxConcurrentJobs);
501 sendit(sock, " Resched=%d Times=%d Interval=%s Spool=%d\n",
502 res->res_job.RescheduleOnError, res->res_job.RescheduleTimes,
503 edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1),
504 res->res_job.spool_data);
505 if (res->res_job.client) {
506 sendit(sock, " --> ");
507 dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
509 if (res->res_job.fileset) {
510 sendit(sock, " --> ");
511 dump_resource(-R_FILESET, (RES *)res->res_job.fileset, sendit, sock);
513 if (res->res_job.schedule) {
514 sendit(sock, " --> ");
515 dump_resource(-R_SCHEDULE, (RES *)res->res_job.schedule, sendit, sock);
517 if (res->res_job.RestoreWhere) {
518 sendit(sock, " --> Where=%s\n", NPRT(res->res_job.RestoreWhere));
520 if (res->res_job.RestoreBootstrap) {
521 sendit(sock, " --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap));
523 if (res->res_job.RunBeforeJob) {
524 sendit(sock, " --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob));
526 if (res->res_job.RunAfterJob) {
527 sendit(sock, " --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob));
529 if (res->res_job.RunAfterFailedJob) {
530 sendit(sock, " --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob));
532 if (res->res_job.WriteBootstrap) {
533 sendit(sock, " --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap));
535 if (res->res_job.storage) {
536 sendit(sock, " --> ");
537 dump_resource(-R_STORAGE, (RES *)res->res_job.storage, sendit, sock);
539 if (res->res_job.pool) {
540 sendit(sock, " --> ");
541 dump_resource(-R_POOL, (RES *)res->res_job.pool, sendit, sock);
543 if (res->res_job.full_pool) {
544 sendit(sock, " --> ");
545 dump_resource(-R_POOL, (RES *)res->res_job.full_pool, sendit, sock);
547 if (res->res_job.inc_pool) {
548 sendit(sock, " --> ");
549 dump_resource(-R_POOL, (RES *)res->res_job.inc_pool, sendit, sock);
551 if (res->res_job.dif_pool) {
552 sendit(sock, " --> ");
553 dump_resource(-R_POOL, (RES *)res->res_job.dif_pool, sendit, sock);
555 if (res->res_job.verify_job) {
556 sendit(sock, " --> ");
557 dump_resource(-type, (RES *)res->res_job.verify_job, sendit, sock);
560 if (res->res_job.messages) {
561 sendit(sock, " --> ");
562 dump_resource(-R_MSGS, (RES *)res->res_job.messages, sendit, sock);
568 sendit(sock, "FileSet: name=%s\n", res->res_fs.hdr.name);
569 for (i=0; i<res->res_fs.num_includes; i++) {
570 INCEXE *incexe = res->res_fs.include_items[i];
571 for (j=0; j<incexe->num_opts; j++) {
572 FOPTS *fo = incexe->opts_list[j];
573 sendit(sock, " O %s\n", fo->opts);
574 for (k=0; k<fo->regex.size(); k++) {
575 sendit(sock, " R %s\n", fo->regex.get(k));
577 for (k=0; k<fo->wild.size(); k++) {
578 sendit(sock, " W %s\n", fo->wild.get(k));
580 for (k=0; k<fo->base.size(); k++) {
581 sendit(sock, " B %s\n", fo->base.get(k));
583 sendit(sock, " N\n");
585 for (j=0; j<incexe->name_list.size(); j++) {
586 sendit(sock, " I %s\n", incexe->name_list.get(j));
588 if (incexe->name_list.size()) {
589 sendit(sock, " N\n");
593 for (i=0; i<res->res_fs.num_excludes; i++) {
594 INCEXE *incexe = res->res_fs.exclude_items[i];
595 for (j=0; j<incexe->name_list.size(); j++) {
596 sendit(sock, " E %s\n", incexe->name_list.get(j));
598 if (incexe->name_list.size()) {
599 sendit(sock, " N\n");
605 if (res->res_sch.run) {
607 RUN *run = res->res_sch.run;
608 char buf[1000], num[30];
609 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
614 sendit(sock, " --> Run Level=%s\n", level_to_str(run->level));
615 bstrncpy(buf, " hour=", sizeof(buf));
616 for (i=0; i<24; i++) {
617 if (bit_is_set(i, run->hour)) {
618 bsnprintf(num, sizeof(num), "%d ", i);
619 bstrncat(buf, num, sizeof(buf));
622 bstrncat(buf, "\n", sizeof(buf));
624 bstrncpy(buf, " mday=", sizeof(buf));
625 for (i=0; i<31; i++) {
626 if (bit_is_set(i, run->mday)) {
627 bsnprintf(num, sizeof(num), "%d ", i);
628 bstrncat(buf, num, sizeof(buf));
631 bstrncat(buf, "\n", sizeof(buf));
633 bstrncpy(buf, " month=", sizeof(buf));
634 for (i=0; i<12; i++) {
635 if (bit_is_set(i, run->month)) {
636 bsnprintf(num, sizeof(num), "%d ", i);
637 bstrncat(buf, num, sizeof(buf));
640 bstrncat(buf, "\n", sizeof(buf));
642 bstrncpy(buf, " wday=", sizeof(buf));
643 for (i=0; i<7; i++) {
644 if (bit_is_set(i, run->wday)) {
645 bsnprintf(num, sizeof(num), "%d ", i);
646 bstrncat(buf, num, sizeof(buf));
649 bstrncat(buf, "\n", sizeof(buf));
651 bstrncpy(buf, " wom=", sizeof(buf));
652 for (i=0; i<5; i++) {
653 if (bit_is_set(i, run->wom)) {
654 bsnprintf(num, sizeof(num), "%d ", i);
655 bstrncat(buf, num, sizeof(buf));
658 bstrncat(buf, "\n", sizeof(buf));
660 bstrncpy(buf, " woy=", sizeof(buf));
661 for (i=0; i<54; i++) {
662 if (bit_is_set(i, run->woy)) {
663 bsnprintf(num, sizeof(num), "%d ", i);
664 bstrncat(buf, num, sizeof(buf));
667 bstrncat(buf, "\n", sizeof(buf));
669 sendit(sock, " mins=%d\n", run->minute);
671 sendit(sock, " --> ");
672 dump_resource(-R_POOL, (RES *)run->pool, sendit, sock);
675 sendit(sock, " --> ");
676 dump_resource(-R_STORAGE, (RES *)run->storage, sendit, sock);
679 sendit(sock, " --> ");
680 dump_resource(-R_MSGS, (RES *)run->msgs, sendit, sock);
682 /* If another Run record is chained in, go print it */
688 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
692 sendit(sock, "Pool: name=%s PoolType=%s\n", res->res_pool.hdr.name,
693 res->res_pool.pool_type);
694 sendit(sock, " use_cat=%d use_once=%d acpt_any=%d cat_files=%d\n",
695 res->res_pool.use_catalog, res->res_pool.use_volume_once,
696 res->res_pool.accept_any_volume, res->res_pool.catalog_files);
697 sendit(sock, " max_vols=%d auto_prune=%d VolRetention=%s\n",
698 res->res_pool.max_volumes, res->res_pool.AutoPrune,
699 edit_utime(res->res_pool.VolRetention, ed1));
700 sendit(sock, " VolUse=%s recycle=%d LabelFormat=%s\n",
701 edit_utime(res->res_pool.VolUseDuration, ed1),
702 res->res_pool.Recycle,
703 NPRT(res->res_pool.label_format));
704 sendit(sock, " CleaningPrefix=%s\n",
705 NPRT(res->res_pool.cleaning_prefix));
706 sendit(sock, " recyleOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n",
707 res->res_pool.purge_oldest_volume,
708 res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
711 sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
712 if (res->res_msgs.mail_cmd)
713 sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd);
714 if (res->res_msgs.operator_cmd)
715 sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd);
718 sendit(sock, "Unknown resource type %d in dump_resource.\n", type);
721 if (recurse && res->res_dir.hdr.next) {
722 dump_resource(type, res->res_dir.hdr.next, sendit, sock);
727 * Free all the members of an INCEXE structure
729 static void free_incexe(INCEXE *incexe)
731 incexe->name_list.destroy();
732 for (int i=0; i<incexe->num_opts; i++) {
733 FOPTS *fopt = incexe->opts_list[i];
734 fopt->regex.destroy();
735 fopt->wild.destroy();
736 fopt->base.destroy();
739 if (incexe->opts_list) {
740 free(incexe->opts_list);
746 * Free memory of resource -- called when daemon terminates.
747 * NB, we don't need to worry about freeing any references
748 * to other resources as they will be freed when that
749 * resource chain is traversed. Mainly we worry about freeing
750 * allocated strings (names).
752 void free_resource(RES *sres, int type)
755 RES *nres; /* next resource if linked */
756 URES *res = (URES *)sres;
761 /* common stuff -- free the resource name and description */
762 nres = (RES *)res->res_dir.hdr.next;
763 if (res->res_dir.hdr.name) {
764 free(res->res_dir.hdr.name);
766 if (res->res_dir.hdr.desc) {
767 free(res->res_dir.hdr.desc);
772 if (res->res_dir.working_directory) {
773 free(res->res_dir.working_directory);
775 if (res->res_dir.pid_directory) {
776 free(res->res_dir.pid_directory);
778 if (res->res_dir.subsys_directory) {
779 free(res->res_dir.subsys_directory);
781 if (res->res_dir.password) {
782 free(res->res_dir.password);
784 if (res->res_dir.query_file) {
785 free(res->res_dir.query_file);
787 if (res->res_dir.DIRaddr) {
788 free(res->res_dir.DIRaddr);
794 if (res->res_con.password) {
795 free(res->res_con.password);
797 for (int i=0; i<Num_ACL; i++) {
798 if (res->res_con.ACL_lists[i]) {
799 delete res->res_con.ACL_lists[i];
800 res->res_con.ACL_lists[i] = NULL;
805 if (res->res_client.address) {
806 free(res->res_client.address);
808 if (res->res_client.password) {
809 free(res->res_client.password);
813 if (res->res_store.address) {
814 free(res->res_store.address);
816 if (res->res_store.password) {
817 free(res->res_store.password);
819 if (res->res_store.media_type) {
820 free(res->res_store.media_type);
822 if (res->res_store.dev_name) {
823 free(res->res_store.dev_name);
827 if (res->res_cat.db_address) {
828 free(res->res_cat.db_address);
830 if (res->res_cat.db_socket) {
831 free(res->res_cat.db_socket);
833 if (res->res_cat.db_user) {
834 free(res->res_cat.db_user);
836 if (res->res_cat.db_name) {
837 free(res->res_cat.db_name);
839 if (res->res_cat.db_password) {
840 free(res->res_cat.db_password);
844 if ((num=res->res_fs.num_includes)) {
846 free_incexe(res->res_fs.include_items[num]);
848 free(res->res_fs.include_items);
850 res->res_fs.num_includes = 0;
851 if ((num=res->res_fs.num_excludes)) {
853 free_incexe(res->res_fs.exclude_items[num]);
855 free(res->res_fs.exclude_items);
857 res->res_fs.num_excludes = 0;
860 if (res->res_pool.pool_type) {
861 free(res->res_pool.pool_type);
863 if (res->res_pool.label_format) {
864 free(res->res_pool.label_format);
866 if (res->res_pool.cleaning_prefix) {
867 free(res->res_pool.cleaning_prefix);
871 if (res->res_sch.run) {
873 nrun = res->res_sch.run;
883 if (res->res_job.RestoreWhere) {
884 free(res->res_job.RestoreWhere);
886 if (res->res_job.RestoreBootstrap) {
887 free(res->res_job.RestoreBootstrap);
889 if (res->res_job.WriteBootstrap) {
890 free(res->res_job.WriteBootstrap);
892 if (res->res_job.RunBeforeJob) {
893 free(res->res_job.RunBeforeJob);
895 if (res->res_job.RunAfterJob) {
896 free(res->res_job.RunAfterJob);
898 if (res->res_job.RunAfterFailedJob) {
899 free(res->res_job.RunAfterFailedJob);
901 if (res->res_job.ClientRunBeforeJob) {
902 free(res->res_job.ClientRunBeforeJob);
904 if (res->res_job.ClientRunAfterJob) {
905 free(res->res_job.ClientRunAfterJob);
909 if (res->res_msgs.mail_cmd) {
910 free(res->res_msgs.mail_cmd);
912 if (res->res_msgs.operator_cmd) {
913 free(res->res_msgs.operator_cmd);
915 free_msgs_res((MSGS *)res); /* free message resource */
919 printf("Unknown resource type %d in free_resource.\n", type);
921 /* Common stuff again -- free the resource, recurse to next one */
926 free_resource(nres, type);
931 * Save the new resource by chaining it into the head list for
932 * the resource. If this is pass 2, we update any resource
933 * pointers because they may not have been defined until
936 void save_resource(int type, RES_ITEM *items, int pass)
939 int rindex = type - r_first;
943 /* Check Job requirements after applying JobDefs */
944 if (type != R_JOB && type != R_JOBDEFS) {
946 * Ensure that all required items are present
948 for (i=0; items[i].name; i++) {
949 if (items[i].flags & ITEM_REQUIRED) {
950 if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
951 Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n",
952 items[i].name, resources[rindex]);
955 /* If this triggers, take a look at lib/parse_conf.h */
956 if (i >= MAX_RES_ITEMS) {
957 Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]);
963 * During pass 2 in each "store" routine, we looked up pointers
964 * to all the resources referrenced in the current resource, now we
965 * must copy their addresses from the static record to the allocated
970 /* Resources not containing a resource */
979 /* Resources containing another resource */
981 if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) {
982 Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name);
984 res->res_dir.messages = res_all.res_dir.messages;
988 if ((res = (URES *)GetResWithName(type, res_all.res_dir.hdr.name)) == NULL) {
989 Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n",
990 res_all.res_dir.hdr.name);
992 res->res_job.messages = res_all.res_job.messages;
993 res->res_job.schedule = res_all.res_job.schedule;
994 res->res_job.client = res_all.res_job.client;
995 res->res_job.fileset = res_all.res_job.fileset;
996 res->res_job.storage = res_all.res_job.storage;
997 res->res_job.pool = res_all.res_job.pool;
998 res->res_job.full_pool = res_all.res_job.full_pool;
999 res->res_job.inc_pool = res_all.res_job.inc_pool;
1000 res->res_job.dif_pool = res_all.res_job.dif_pool;
1001 res->res_job.verify_job = res_all.res_job.verify_job;
1002 res->res_job.jobdefs = res_all.res_job.jobdefs;
1005 if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) {
1006 Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name);
1008 res->res_counter.Catalog = res_all.res_counter.Catalog;
1009 res->res_counter.WrapCounter = res_all.res_counter.WrapCounter;
1013 if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_client.hdr.name)) == NULL) {
1014 Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name);
1016 res->res_client.catalog = res_all.res_client.catalog;
1020 * Schedule is a bit different in that it contains a RUN record
1021 * chain which isn't a "named" resource. This chain was linked
1022 * in by run_conf.c during pass 2, so here we jam the pointer
1023 * into the Schedule resource.
1025 if ((res = (URES *)GetResWithName(R_SCHEDULE, res_all.res_client.hdr.name)) == NULL) {
1026 Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name);
1028 res->res_sch.run = res_all.res_sch.run;
1031 Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type);
1035 /* Note, the resource name was already saved during pass 1,
1036 * so here, we can just release it.
1038 if (res_all.res_dir.hdr.name) {
1039 free(res_all.res_dir.hdr.name);
1040 res_all.res_dir.hdr.name = NULL;
1042 if (res_all.res_dir.hdr.desc) {
1043 free(res_all.res_dir.hdr.desc);
1044 res_all.res_dir.hdr.desc = NULL;
1050 * The following code is only executed during pass 1
1054 size = sizeof(DIRRES);
1057 size = sizeof(CONRES);
1060 size =sizeof(CLIENT);
1063 size = sizeof(STORE);
1073 size = sizeof(FILESET);
1076 size = sizeof(SCHED);
1079 size = sizeof(POOL);
1082 size = sizeof(MSGS);
1085 size = sizeof(COUNTER);
1088 printf("Unknown resource type %d in save_resrouce.\n", type);
1095 res = (URES *)malloc(size);
1096 memcpy(res, &res_all, size);
1097 if (!res_head[rindex]) {
1098 res_head[rindex] = (RES *)res; /* store first entry */
1099 Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
1100 res->res_dir.hdr.name, rindex);
1103 /* Add new res to end of chain */
1104 for (next=res_head[rindex]; next->next; next=next->next) {
1105 if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
1106 Emsg2(M_ERROR_TERM, 0,
1107 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
1108 resources[rindex].name, res->res_dir.hdr.name);
1111 next->next = (RES *)res;
1112 Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
1113 res->res_dir.hdr.name, rindex, pass);
1119 * Store JobType (backup, verify, restore)
1122 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass)
1126 token = lex_get_token(lc, T_NAME);
1127 /* Store the type both pass 1 and pass 2 */
1128 for (i=0; jobtypes[i].type_name; i++) {
1129 if (strcasecmp(lc->str, jobtypes[i].type_name) == 0) {
1130 *(int *)(item->value) = jobtypes[i].job_type;
1136 scan_err1(lc, "Expected a Job Type keyword, got: %s", lc->str);
1139 set_bit(index, res_all.hdr.item_present);
1143 * Store Job Level (Full, Incremental, ...)
1146 void store_level(LEX *lc, RES_ITEM *item, int index, int pass)
1150 token = lex_get_token(lc, T_NAME);
1151 /* Store the level pass 2 so that type is defined */
1152 for (i=0; joblevels[i].level_name; i++) {
1153 if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1154 *(int *)(item->value) = joblevels[i].level;
1160 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1163 set_bit(index, res_all.hdr.item_present);
1166 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass)
1169 token = lex_get_token(lc, T_NAME);
1170 /* Scan Replacement options */
1171 for (i=0; ReplaceOptions[i].name; i++) {
1172 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1173 *(int *)(item->value) = ReplaceOptions[i].token;
1179 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1182 set_bit(index, res_all.hdr.item_present);
1186 * Store ACL (access control list)
1189 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
1194 token = lex_get_token(lc, T_NAME);
1196 if (((alist **)item->value)[item->code] == NULL) {
1197 ((alist **)item->value)[item->code] = new alist(10, owned_by_alist);
1198 // Dmsg1(900, "Defined new ACL alist at %d\n", item->code);
1200 ((alist **)item->value)[item->code]->append(bstrdup(lc->str));
1201 // Dmsg2(900, "Appended to %d %s\n", item->code, lc->str);
1203 token = lex_get_token(lc, T_ALL);
1204 if (token == T_COMMA) {
1205 continue; /* get another ACL */
1209 set_bit(index, res_all.hdr.item_present);
1213 #ifdef old_deprecated_code
1215 * Store backup/verify info for Job record
1217 * Note, this code is used for both BACKUP and VERIFY jobs
1219 * Backup = Client=<client-name> FileSet=<FileSet-name> Level=<level>
1221 static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
1225 int options = lc->options;
1227 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1230 ((JOB *)(item->value))->JobType = item->code;
1231 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1234 Dmsg1(900, "store_backup got token=%s\n", lex_tok_to_str(token));
1236 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1237 scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
1239 Dmsg1(900, "Got keyword: %s\n", lc->str);
1240 for (i=0; BakVerFields[i].name; i++) {
1241 if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
1243 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1244 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1246 token = lex_get_token(lc, T_NAME);
1247 Dmsg1(900, "Got value: %s\n", lc->str);
1248 switch (BakVerFields[i].token) {
1250 /* Find Client Resource */
1252 res = GetResWithName(R_CLIENT, lc->str);
1254 scan_err1(lc, "Could not find specified Client Resource: %s",
1257 res_all.res_job.client = (CLIENT *)res;
1261 /* Find FileSet Resource */
1263 res = GetResWithName(R_FILESET, lc->str);
1265 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1268 res_all.res_job.fileset = (FILESET *)res;
1273 for (i=0; joblevels[i].level_name; i++) {
1274 if (joblevels[i].job_type == item->code &&
1275 strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1276 ((JOB *)(item->value))->level = joblevels[i].level;
1282 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1287 } /* end if strcmp() */
1290 scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
1293 lc->options = options; /* reset original options */
1294 set_bit(index, res_all.hdr.item_present);
1298 * Store restore info for Job record
1300 * Restore = JobId=<job-id> Where=<root-directory> Replace=<options> Bootstrap=<file>
1303 static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
1307 int options = lc->options;
1309 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1311 Dmsg0(900, "Enter store_restore()\n");
1313 ((JOB *)(item->value))->JobType = item->code;
1314 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1317 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1318 scan_err1(lc, "expected a name, got: %s", lc->str);
1320 for (i=0; RestoreFields[i].name; i++) {
1321 Dmsg1(900, "Restore kw=%s\n", lc->str);
1322 if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
1324 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1325 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1327 token = lex_get_token(lc, T_ALL);
1328 Dmsg1(900, "Restore value=%s\n", lc->str);
1329 switch (RestoreFields[i].token) {
1332 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1333 scan_err1(lc, "Expected a Restore bootstrap file, got: %s", lc->str);
1336 res_all.res_job.RestoreBootstrap = bstrdup(lc->str);
1340 /* Find Client Resource */
1342 res = GetResWithName(R_CLIENT, lc->str);
1344 scan_err1(lc, "Could not find specified Client Resource: %s",
1347 res_all.res_job.client = (CLIENT *)res;
1351 /* Find FileSet Resource */
1353 res = GetResWithName(R_FILESET, lc->str);
1355 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1358 res_all.res_job.fileset = (FILESET *)res;
1363 if (token != T_NUMBER) {
1364 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1367 res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
1368 Dmsg1(900, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
1370 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1375 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1376 scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
1379 res_all.res_job.RestoreWhere = bstrdup(lc->str);
1383 /* Replacement options */
1384 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1385 scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
1387 /* Fix to scan Replacement options */
1388 for (i=0; ReplaceOptions[i].name; i++) {
1389 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1390 ((JOB *)(item->value))->replace = ReplaceOptions[i].token;
1396 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1401 } /* end if strcmp() */
1404 scan_err1(lc, "%s not a valid Restore keyword", lc->str);
1407 lc->options = options; /* reset original options */
1408 set_bit(index, res_all.hdr.item_present);