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;
54 /* Imported subroutines */
55 extern void store_run(LEX *lc, RES_ITEM *item, int index, int pass);
56 extern void store_finc(LEX *lc, RES_ITEM *item, int index, int pass);
57 extern void store_inc(LEX *lc, RES_ITEM *item, int index, int pass);
60 /* Forward referenced subroutines */
62 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass);
63 void store_level(LEX *lc, RES_ITEM *item, int index, int pass);
64 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass);
65 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass);
68 /* We build the current resource here as we are
69 * scanning the resource configuration definition,
70 * then move it to allocated memory when the resource
74 int res_all_size = sizeof(res_all);
77 /* Definition of records permitted within each
78 * resource with the routine to process the record
79 * information. NOTE! quoted names must be in lower case.
84 * name handler value code flags default_value
86 static RES_ITEM dir_items[] = {
87 {"name", store_name, ITEM(res_dir.hdr.name), 0, ITEM_REQUIRED, 0},
88 {"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0},
89 {"messages", store_res, ITEM(res_dir.messages), R_MSGS, 0, 0},
90 {"dirport", store_pint, ITEM(res_dir.DIRport), 0, ITEM_DEFAULT, 9101},
91 {"diraddress", store_str, ITEM(res_dir.DIRaddr), 0, 0, 0},
92 {"queryfile", store_dir, ITEM(res_dir.query_file), 0, ITEM_REQUIRED, 0},
93 {"workingdirectory", store_dir, ITEM(res_dir.working_directory), 0, ITEM_REQUIRED, 0},
94 {"piddirectory",store_dir, ITEM(res_dir.pid_directory), 0, ITEM_REQUIRED, 0},
95 {"subsysdirectory", store_dir, ITEM(res_dir.subsys_directory), 0, 0, 0},
96 {"requiressl", store_yesno, ITEM(res_dir.require_ssl), 1, ITEM_DEFAULT, 0},
97 {"enablessl", store_yesno, ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0},
98 {"maximumconcurrentjobs", store_pint, ITEM(res_dir.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
99 {"password", store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0},
100 {"fdconnecttimeout", store_time,ITEM(res_dir.FDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
101 {"sdconnecttimeout", store_time,ITEM(res_dir.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
102 {NULL, NULL, NULL, 0, 0, 0}
108 * name handler value code flags default_value
110 static RES_ITEM con_items[] = {
111 {"name", store_name, ITEM(res_con.hdr.name), 0, ITEM_REQUIRED, 0},
112 {"description", store_str, ITEM(res_con.hdr.desc), 0, 0, 0},
113 {"enablessl", store_yesno, ITEM(res_con.enable_ssl), 1, ITEM_DEFAULT, 0},
114 {"password", store_password, ITEM(res_con.password), 0, ITEM_REQUIRED, 0},
115 {"jobacl", store_acl, ITEM(res_con.ACL_lists), Job_ACL, 0, 0},
116 {"clientacl", store_acl, ITEM(res_con.ACL_lists), Client_ACL, 0, 0},
117 {"storageacl", store_acl, ITEM(res_con.ACL_lists), Storage_ACL, 0, 0},
118 {"scheduleacl", store_acl, ITEM(res_con.ACL_lists), Schedule_ACL, 0, 0},
119 {"runacl", store_acl, ITEM(res_con.ACL_lists), Run_ACL, 0, 0},
120 {"poolacl", store_acl, ITEM(res_con.ACL_lists), Pool_ACL, 0, 0},
121 {"commandacl", store_acl, ITEM(res_con.ACL_lists), Command_ACL, 0, 0},
122 {"filesetacl", store_acl, ITEM(res_con.ACL_lists), FileSet_ACL, 0, 0},
123 {"catalogacl", store_acl, ITEM(res_con.ACL_lists), Catalog_ACL, 0, 0},
124 {NULL, NULL, NULL, 0, 0, 0}
129 * Client or File daemon resource
131 * name handler value code flags default_value
134 static RES_ITEM cli_items[] = {
135 {"name", store_name, ITEM(res_client.hdr.name), 0, ITEM_REQUIRED, 0},
136 {"description", store_str, ITEM(res_client.hdr.desc), 0, 0, 0},
137 {"address", store_str, ITEM(res_client.address), 0, ITEM_REQUIRED, 0},
138 {"fdaddress", store_str, ITEM(res_client.address), 0, 0, 0},
139 {"fdport", store_pint, ITEM(res_client.FDport), 0, ITEM_DEFAULT, 9102},
140 {"password", store_password, ITEM(res_client.password), 0, ITEM_REQUIRED, 0},
141 {"fdpassword", store_password, ITEM(res_client.password), 0, 0, 0},
142 {"catalog", store_res, ITEM(res_client.catalog), R_CATALOG, 0, 0},
143 {"fileretention", store_time, ITEM(res_client.FileRetention), 0, ITEM_DEFAULT, 60*60*24*60},
144 {"jobretention", store_time, ITEM(res_client.JobRetention), 0, ITEM_DEFAULT, 60*60*24*180},
145 {"autoprune", store_yesno, ITEM(res_client.AutoPrune), 1, ITEM_DEFAULT, 1},
146 {"enablessl", store_yesno, ITEM(res_client.enable_ssl), 1, ITEM_DEFAULT, 0},
147 {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
148 {NULL, NULL, NULL, 0, 0, 0}
151 /* Storage daemon resource
153 * name handler value code flags default_value
155 static RES_ITEM store_items[] = {
156 {"name", store_name, ITEM(res_store.hdr.name), 0, ITEM_REQUIRED, 0},
157 {"description", store_str, ITEM(res_store.hdr.desc), 0, 0, 0},
158 {"sdport", store_pint, ITEM(res_store.SDport), 0, ITEM_DEFAULT, 9103},
159 {"address", store_str, ITEM(res_store.address), 0, ITEM_REQUIRED, 0},
160 {"sdaddress", store_str, ITEM(res_store.address), 0, 0, 0},
161 {"password", store_password, ITEM(res_store.password), 0, ITEM_REQUIRED, 0},
162 {"sdpassword", store_password, ITEM(res_store.password), 0, 0, 0},
163 {"device", store_strname, ITEM(res_store.dev_name), 0, ITEM_REQUIRED, 0},
164 {"sddevicename", store_strname, ITEM(res_store.dev_name), 0, 0, 0},
165 {"mediatype", store_strname, ITEM(res_store.media_type), 0, ITEM_REQUIRED, 0},
166 {"autochanger", store_yesno, ITEM(res_store.autochanger), 1, ITEM_DEFAULT, 0},
167 {"enablessl", store_yesno, ITEM(res_store.enable_ssl), 1, ITEM_DEFAULT, 0},
168 {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
169 {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */
170 {NULL, NULL, NULL, 0, 0, 0}
174 * Catalog Resource Directives
176 * name handler value code flags default_value
178 static RES_ITEM cat_items[] = {
179 {"name", store_name, ITEM(res_cat.hdr.name), 0, ITEM_REQUIRED, 0},
180 {"description", store_str, ITEM(res_cat.hdr.desc), 0, 0, 0},
181 {"address", store_str, ITEM(res_cat.db_address), 0, 0, 0},
182 {"dbaddress", store_str, ITEM(res_cat.db_address), 0, 0, 0},
183 {"dbport", store_pint, ITEM(res_cat.db_port), 0, 0, 0},
184 /* keep this password as store_str for the moment */
185 {"password", store_str, ITEM(res_cat.db_password), 0, 0, 0},
186 {"dbpassword", store_str, ITEM(res_cat.db_password), 0, 0, 0},
187 {"user", store_str, ITEM(res_cat.db_user), 0, 0, 0},
188 {"dbname", store_str, ITEM(res_cat.db_name), 0, ITEM_REQUIRED, 0},
189 {"dbsocket", store_str, ITEM(res_cat.db_socket), 0, 0, 0},
190 {NULL, NULL, NULL, 0, 0, 0}
194 * Job Resource Directives
196 * name handler value code flags default_value
198 RES_ITEM job_items[] = {
199 {"name", store_name, ITEM(res_job.hdr.name), 0, ITEM_REQUIRED, 0},
200 {"description", store_str, ITEM(res_job.hdr.desc), 0, 0, 0},
201 {"type", store_jobtype, ITEM(res_job.JobType), 0, ITEM_REQUIRED, 0},
202 {"level", store_level, ITEM(res_job.level), 0, 0, 0},
203 {"messages", store_res, ITEM(res_job.messages), R_MSGS, ITEM_REQUIRED, 0},
204 {"storage", store_res, ITEM(res_job.storage), R_STORAGE, ITEM_REQUIRED, 0},
205 {"pool", store_res, ITEM(res_job.pool), R_POOL, ITEM_REQUIRED, 0},
206 {"fullbackuppool", store_res, ITEM(res_job.full_pool), R_POOL, 0, 0},
207 {"incrementalbackuppool", store_res, ITEM(res_job.inc_pool), R_POOL, 0, 0},
208 {"differentialbackuppool", store_res, ITEM(res_job.dif_pool), R_POOL, 0, 0},
209 {"client", store_res, ITEM(res_job.client), R_CLIENT, ITEM_REQUIRED, 0},
210 {"fileset", store_res, ITEM(res_job.fileset), R_FILESET, ITEM_REQUIRED, 0},
211 {"schedule", store_res, ITEM(res_job.schedule), R_SCHEDULE, 0, 0},
212 {"verifyjob", store_res, ITEM(res_job.verify_job), R_JOB, 0, 0},
213 {"jobdefs", store_res, ITEM(res_job.jobdefs), R_JOBDEFS, 0, 0},
214 {"where", store_dir, ITEM(res_job.RestoreWhere), 0, 0, 0},
215 {"bootstrap",store_dir, ITEM(res_job.RestoreBootstrap), 0, 0, 0},
216 {"writebootstrap",store_dir, ITEM(res_job.WriteBootstrap), 0, 0, 0},
217 {"replace", store_replace, ITEM(res_job.replace), 0, ITEM_DEFAULT, REPLACE_ALWAYS},
218 {"maxruntime", store_time, ITEM(res_job.MaxRunTime), 0, 0, 0},
219 {"maxwaittime", store_time, ITEM(res_job.MaxWaitTime), 0, 0, 0},
220 {"maxstartdelay",store_time, ITEM(res_job.MaxStartDelay), 0, 0, 0},
221 {"jobretention", store_time, ITEM(res_job.JobRetention), 0, 0, 0},
222 {"prefixlinks", store_yesno, ITEM(res_job.PrefixLinks), 1, ITEM_DEFAULT, 0},
223 {"prunejobs", store_yesno, ITEM(res_job.PruneJobs), 1, ITEM_DEFAULT, 0},
224 {"prunefiles", store_yesno, ITEM(res_job.PruneFiles), 1, ITEM_DEFAULT, 0},
225 {"prunevolumes",store_yesno, ITEM(res_job.PruneVolumes), 1, ITEM_DEFAULT, 0},
226 {"spoolattributes",store_yesno, ITEM(res_job.SpoolAttributes), 1, ITEM_DEFAULT, 0},
227 {"runbeforejob", store_str, ITEM(res_job.RunBeforeJob), 0, 0, 0},
228 {"runafterjob", store_str, ITEM(res_job.RunAfterJob), 0, 0, 0},
229 {"runafterfailedjob", store_str, ITEM(res_job.RunAfterFailedJob), 0, 0, 0},
230 {"clientrunbeforejob", store_str, ITEM(res_job.ClientRunBeforeJob), 0, 0, 0},
231 {"clientrunafterjob", store_str, ITEM(res_job.ClientRunAfterJob), 0, 0, 0},
232 {"maximumconcurrentjobs", store_pint, ITEM(res_job.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
233 {"rescheduleonerror", store_yesno, ITEM(res_job.RescheduleOnError), 1, ITEM_DEFAULT, 0},
234 {"rescheduleinterval", store_time, ITEM(res_job.RescheduleInterval), 0, ITEM_DEFAULT, 60 * 30},
235 {"rescheduletimes", store_pint, ITEM(res_job.RescheduleTimes), 0, 0, 0},
236 {"priority", store_pint, ITEM(res_job.Priority), 0, ITEM_DEFAULT, 10},
237 {NULL, NULL, NULL, 0, 0, 0}
242 * name handler value code flags default_value
244 static RES_ITEM fs_items[] = {
245 {"name", store_name, ITEM(res_fs.hdr.name), 0, ITEM_REQUIRED, 0},
246 {"description", store_str, ITEM(res_fs.hdr.desc), 0, 0, 0},
247 {"include", store_inc, NULL, 0, ITEM_NO_EQUALS, 0},
248 {"exclude", store_inc, NULL, 1, ITEM_NO_EQUALS, 0},
249 {NULL, NULL, NULL, 0, 0, 0}
252 /* Schedule -- see run_conf.c */
255 * name handler value code flags default_value
257 static RES_ITEM sch_items[] = {
258 {"name", store_name, ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0},
259 {"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0},
260 {"run", store_run, ITEM(res_sch.run), 0, 0, 0},
261 {NULL, NULL, NULL, 0, 0, 0}
266 * name handler value code flags default_value
268 static RES_ITEM pool_items[] = {
269 {"name", store_name, ITEM(res_pool.hdr.name), 0, ITEM_REQUIRED, 0},
270 {"description", store_str, ITEM(res_pool.hdr.desc), 0, 0, 0},
271 {"pooltype", store_strname, ITEM(res_pool.pool_type), 0, ITEM_REQUIRED, 0},
272 {"labelformat", store_strname, ITEM(res_pool.label_format), 0, 0, 0},
273 {"cleaningprefix", store_strname, ITEM(res_pool.cleaning_prefix), 0, 0, 0},
274 {"usecatalog", store_yesno, ITEM(res_pool.use_catalog), 1, ITEM_DEFAULT, 1},
275 {"usevolumeonce", store_yesno, ITEM(res_pool.use_volume_once), 1, 0, 0},
276 {"purgeoldestvolume", store_yesno, ITEM(res_pool.purge_oldest_volume), 1, 0, 0},
277 {"recycleoldestvolume", store_yesno, ITEM(res_pool.recycle_oldest_volume), 1, 0, 0},
278 {"recyclecurrentvolume", store_yesno, ITEM(res_pool.recycle_current_volume), 1, 0, 0},
279 {"maximumvolumes", store_pint, ITEM(res_pool.max_volumes), 0, 0, 0},
280 {"maximumvolumejobs", store_pint, ITEM(res_pool.MaxVolJobs), 0, 0, 0},
281 {"maximumvolumefiles", store_pint, ITEM(res_pool.MaxVolFiles), 0, 0, 0},
282 {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes), 0, 0, 0},
283 {"acceptanyvolume", store_yesno, ITEM(res_pool.accept_any_volume), 1, ITEM_DEFAULT, 1},
284 {"catalogfiles", store_yesno, ITEM(res_pool.catalog_files), 1, ITEM_DEFAULT, 1},
285 {"volumeretention", store_time, ITEM(res_pool.VolRetention), 0, ITEM_DEFAULT, 60*60*24*365},
286 {"volumeuseduration", store_time, ITEM(res_pool.VolUseDuration),0, 0, 0},
287 {"autoprune", store_yesno, ITEM(res_pool.AutoPrune), 1, ITEM_DEFAULT, 1},
288 {"recycle", store_yesno, ITEM(res_pool.Recycle), 1, ITEM_DEFAULT, 1},
289 {NULL, NULL, NULL, 0, 0, 0}
294 * name handler value code flags default_value
296 static RES_ITEM counter_items[] = {
297 {"name", store_name, ITEM(res_counter.hdr.name), 0, ITEM_REQUIRED, 0},
298 {"description", store_str, ITEM(res_counter.hdr.desc), 0, 0, 0},
299 {"minimum", store_int, ITEM(res_counter.MinValue), 0, ITEM_DEFAULT, 0},
300 {"maximum", store_pint, ITEM(res_counter.MaxValue), 0, ITEM_DEFAULT, INT32_MAX},
301 {"wrapcounter", store_res, ITEM(res_counter.WrapCounter), R_COUNTER, 0, 0},
302 {"catalog", store_res, ITEM(res_counter.Catalog), R_CATALOG, 0, 0},
303 {NULL, NULL, NULL, 0, 0, 0}
307 /* Message resource */
308 extern RES_ITEM msgs_items[];
311 * This is the master resource definition.
312 * It must have one item for each of the resources.
314 * NOTE!!! keep it in the same order as the R_codes
315 * or eliminate all resources[rindex].name
317 * name items rcode res_head
319 RES_TABLE resources[] = {
320 {"director", dir_items, R_DIRECTOR, NULL},
321 {"client", cli_items, R_CLIENT, NULL},
322 {"job", job_items, R_JOB, NULL},
323 {"storage", store_items, R_STORAGE, NULL},
324 {"catalog", cat_items, R_CATALOG, NULL},
325 {"schedule", sch_items, R_SCHEDULE, NULL},
326 {"fileset", fs_items, R_FILESET, NULL},
327 {"pool", pool_items, R_POOL, NULL},
328 {"messages", msgs_items, R_MSGS, NULL},
329 {"counter", counter_items, R_COUNTER, NULL},
330 {"console", con_items, R_CONSOLE, NULL},
331 {"jobdefs", job_items, R_JOBDEFS, NULL},
332 {NULL, NULL, 0, NULL}
336 /* Keywords (RHS) permitted in Job Level records
338 * level_name level job_type
340 struct s_jl joblevels[] = {
341 {"Full", L_FULL, JT_BACKUP},
342 {"Base", L_BASE, JT_BACKUP},
343 {"Incremental", L_INCREMENTAL, JT_BACKUP},
344 {"Differential", L_DIFFERENTIAL, JT_BACKUP},
345 {"Since", L_SINCE, JT_BACKUP},
346 {"Catalog", L_VERIFY_CATALOG, JT_VERIFY},
347 {"InitCatalog", L_VERIFY_INIT, JT_VERIFY},
348 {"VolumeToCatalog", L_VERIFY_VOLUME_TO_CATALOG, JT_VERIFY},
349 {"DiskToCatalog", L_VERIFY_DISK_TO_CATALOG, JT_VERIFY},
350 {"Data", L_VERIFY_DATA, JT_VERIFY},
351 {" ", L_NONE, JT_ADMIN},
352 {" ", L_NONE, JT_RESTORE},
356 /* Keywords (RHS) permitted in Job type records
360 struct s_jt jobtypes[] = {
361 {"backup", JT_BACKUP},
363 {"verify", JT_VERIFY},
364 {"restore", JT_RESTORE},
368 #ifdef old_deprecated_code
370 /* Keywords (RHS) permitted in Backup and Verify records */
371 static struct s_kw BakVerFields[] = {
378 /* Keywords (RHS) permitted in Restore records */
379 static struct s_kw RestoreFields[] = {
382 {"jobid", 'J'}, /* JobId to restore */
383 {"where", 'W'}, /* root of restore */
384 {"replace", 'R'}, /* replacement options */
385 {"bootstrap", 'B'}, /* bootstrap file */
390 /* Options permitted in Restore replace= */
391 struct s_kw ReplaceOptions[] = {
392 {"always", REPLACE_ALWAYS},
393 {"ifnewer", REPLACE_IFNEWER},
394 {"ifolder", REPLACE_IFOLDER},
395 {"never", REPLACE_NEVER},
399 char *level_to_str(int level)
402 static char level_no[30];
403 char *str = level_no;
405 bsnprintf(level_no, sizeof(level_no), "%d", level); /* default if not found */
406 for (i=0; joblevels[i].level_name; i++) {
407 if (level == joblevels[i].level) {
408 str = joblevels[i].level_name;
415 /* Dump contents of resource */
416 void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
418 URES *res = (URES *)reshdr;
420 char ed1[100], ed2[100];
423 sendit(sock, "No %s resource defined\n", res_to_str(type));
426 if (type < 0) { /* no recursion */
432 sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n",
433 reshdr->name, res->res_dir.MaxConcurrentJobs,
434 edit_uint64(res->res_dir.FDConnectTimeout, ed1),
435 edit_uint64(res->res_dir.SDConnectTimeout, ed2));
436 if (res->res_dir.query_file) {
437 sendit(sock, " query_file=%s\n", res->res_dir.query_file);
439 if (res->res_dir.messages) {
440 sendit(sock, " --> ");
441 dump_resource(-R_MSGS, (RES *)res->res_dir.messages, sendit, sock);
445 sendit(sock, "Console: name=%s SSL=%d\n",
446 res->res_con.hdr.name, res->res_con.enable_ssl);
449 if (res->res_counter.WrapCounter) {
450 sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n",
451 res->res_counter.hdr.name, res->res_counter.MinValue,
452 res->res_counter.MaxValue, res->res_counter.CurrentValue,
453 res->res_counter.WrapCounter->hdr.name);
455 sendit(sock, "Counter: name=%s min=%d max=%d\n",
456 res->res_counter.hdr.name, res->res_counter.MinValue,
457 res->res_counter.MaxValue);
459 if (res->res_counter.Catalog) {
460 sendit(sock, " --> ");
461 dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock);
466 sendit(sock, "Client: name=%s address=%s FDport=%d MaxJobs=%u\n",
467 res->res_client.hdr.name, res->res_client.address, res->res_client.FDport,
468 res->res_client.MaxConcurrentJobs);
469 sendit(sock, " JobRetention=%s FileRetention=%s AutoPrune=%d\n",
470 edit_utime(res->res_client.JobRetention, ed1),
471 edit_utime(res->res_client.FileRetention, ed2),
472 res->res_client.AutoPrune);
473 if (res->res_client.catalog) {
474 sendit(sock, " --> ");
475 dump_resource(-R_CATALOG, (RES *)res->res_client.catalog, sendit, sock);
479 sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n\
480 DeviceName=%s MediaType=%s\n",
481 res->res_store.hdr.name, res->res_store.address, res->res_store.SDport,
482 res->res_store.MaxConcurrentJobs,
483 res->res_store.dev_name, res->res_store.media_type);
486 sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n\
488 res->res_cat.hdr.name, NPRT(res->res_cat.db_address),
489 res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user));
493 sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n",
494 type == R_JOB ? "Job" : "JobDefs",
495 res->res_job.hdr.name, res->res_job.JobType,
496 level_to_str(res->res_job.level), res->res_job.Priority,
497 res->res_job.MaxConcurrentJobs);
498 sendit(sock, " Resched=%d Times=%d Interval=%s\n",
499 res->res_job.RescheduleOnError, res->res_job.RescheduleTimes,
500 edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1));
501 if (res->res_job.client) {
502 sendit(sock, " --> ");
503 dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
505 if (res->res_job.fileset) {
506 sendit(sock, " --> ");
507 dump_resource(-R_FILESET, (RES *)res->res_job.fileset, sendit, sock);
509 if (res->res_job.schedule) {
510 sendit(sock, " --> ");
511 dump_resource(-R_SCHEDULE, (RES *)res->res_job.schedule, sendit, sock);
513 if (res->res_job.RestoreWhere) {
514 sendit(sock, " --> Where=%s\n", NPRT(res->res_job.RestoreWhere));
516 if (res->res_job.RestoreBootstrap) {
517 sendit(sock, " --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap));
519 if (res->res_job.RunBeforeJob) {
520 sendit(sock, " --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob));
522 if (res->res_job.RunAfterJob) {
523 sendit(sock, " --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob));
525 if (res->res_job.RunAfterFailedJob) {
526 sendit(sock, " --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob));
528 if (res->res_job.WriteBootstrap) {
529 sendit(sock, " --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap));
531 if (res->res_job.storage) {
532 sendit(sock, " --> ");
533 dump_resource(-R_STORAGE, (RES *)res->res_job.storage, sendit, sock);
535 if (res->res_job.pool) {
536 sendit(sock, " --> ");
537 dump_resource(-R_POOL, (RES *)res->res_job.pool, sendit, sock);
539 if (res->res_job.full_pool) {
540 sendit(sock, " --> ");
541 dump_resource(-R_POOL, (RES *)res->res_job.full_pool, sendit, sock);
543 if (res->res_job.inc_pool) {
544 sendit(sock, " --> ");
545 dump_resource(-R_POOL, (RES *)res->res_job.inc_pool, sendit, sock);
547 if (res->res_job.dif_pool) {
548 sendit(sock, " --> ");
549 dump_resource(-R_POOL, (RES *)res->res_job.dif_pool, sendit, sock);
551 if (res->res_job.verify_job) {
552 sendit(sock, " --> ");
553 dump_resource(-type, (RES *)res->res_job.verify_job, sendit, sock);
556 if (res->res_job.messages) {
557 sendit(sock, " --> ");
558 dump_resource(-R_MSGS, (RES *)res->res_job.messages, sendit, sock);
562 sendit(sock, "FileSet: name=%s\n", res->res_fs.hdr.name);
563 for (int i=0; i<res->res_fs.num_includes; i++) {
564 INCEXE *incexe = res->res_fs.include_items[i];
565 for (int j=0; j<incexe->name_list.size(); j++) {
566 sendit(sock, " Inc: %s\n", incexe->name_list.get(j));
569 for (int i=0; i<res->res_fs.num_excludes; i++) {
570 INCEXE *incexe = res->res_fs.exclude_items[i];
571 for (int j=0; j<incexe->name_list.size(); j++) {
572 sendit(sock, " Exc: %s\n", incexe->name_list.get(j));
577 if (res->res_sch.run) {
579 RUN *run = res->res_sch.run;
580 char buf[1000], num[30];
581 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
586 sendit(sock, " --> Run Level=%s\n", level_to_str(run->level));
587 bstrncpy(buf, " hour=", sizeof(buf));
588 for (i=0; i<24; i++) {
589 if (bit_is_set(i, run->hour)) {
590 bsnprintf(num, sizeof(num), "%d ", i);
591 bstrncat(buf, num, sizeof(buf));
594 bstrncat(buf, "\n", sizeof(buf));
596 bstrncpy(buf, " mday=", sizeof(buf));
597 for (i=0; i<31; i++) {
598 if (bit_is_set(i, run->mday)) {
599 bsnprintf(num, sizeof(num), "%d ", i);
600 bstrncat(buf, num, sizeof(buf));
603 bstrncat(buf, "\n", sizeof(buf));
605 bstrncpy(buf, " month=", sizeof(buf));
606 for (i=0; i<12; i++) {
607 if (bit_is_set(i, run->month)) {
608 bsnprintf(num, sizeof(num), "%d ", i);
609 bstrncat(buf, num, sizeof(buf));
612 bstrncat(buf, "\n", sizeof(buf));
614 bstrncpy(buf, " wday=", sizeof(buf));
615 for (i=0; i<7; i++) {
616 if (bit_is_set(i, run->wday)) {
617 bsnprintf(num, sizeof(num), "%d ", i);
618 bstrncat(buf, num, sizeof(buf));
621 bstrncat(buf, "\n", sizeof(buf));
623 bstrncpy(buf, " wom=", sizeof(buf));
624 for (i=0; i<5; i++) {
625 if (bit_is_set(i, run->wom)) {
626 bsnprintf(num, sizeof(num), "%d ", i);
627 bstrncat(buf, num, sizeof(buf));
630 bstrncat(buf, "\n", sizeof(buf));
632 bstrncpy(buf, " woy=", sizeof(buf));
633 for (i=0; i<54; i++) {
634 if (bit_is_set(i, run->woy)) {
635 bsnprintf(num, sizeof(num), "%d ", i);
636 bstrncat(buf, num, sizeof(buf));
639 bstrncat(buf, "\n", sizeof(buf));
641 sendit(sock, " mins=%d\n", run->minute);
643 sendit(sock, " --> ");
644 dump_resource(-R_POOL, (RES *)run->pool, sendit, sock);
647 sendit(sock, " --> ");
648 dump_resource(-R_STORAGE, (RES *)run->storage, sendit, sock);
651 sendit(sock, " --> ");
652 dump_resource(-R_MSGS, (RES *)run->msgs, sendit, sock);
654 /* If another Run record is chained in, go print it */
660 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
664 sendit(sock, "Pool: name=%s PoolType=%s\n", res->res_pool.hdr.name,
665 res->res_pool.pool_type);
666 sendit(sock, " use_cat=%d use_once=%d acpt_any=%d cat_files=%d\n",
667 res->res_pool.use_catalog, res->res_pool.use_volume_once,
668 res->res_pool.accept_any_volume, res->res_pool.catalog_files);
669 sendit(sock, " max_vols=%d auto_prune=%d VolRetention=%s\n",
670 res->res_pool.max_volumes, res->res_pool.AutoPrune,
671 edit_utime(res->res_pool.VolRetention, ed1));
672 sendit(sock, " VolUse=%s recycle=%d LabelFormat=%s\n",
673 edit_utime(res->res_pool.VolUseDuration, ed1),
674 res->res_pool.Recycle,
675 NPRT(res->res_pool.label_format));
676 sendit(sock, " CleaningPrefix=%s\n",
677 NPRT(res->res_pool.cleaning_prefix));
678 sendit(sock, " recyleOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n",
679 res->res_pool.purge_oldest_volume,
680 res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
683 sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
684 if (res->res_msgs.mail_cmd)
685 sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd);
686 if (res->res_msgs.operator_cmd)
687 sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd);
690 sendit(sock, "Unknown resource type %d in dump_resource.\n", type);
693 if (recurse && res->res_dir.hdr.next) {
694 dump_resource(type, res->res_dir.hdr.next, sendit, sock);
699 * Free all the members of an INCEXE structure
701 static void free_incexe(INCEXE *incexe)
703 incexe->name_list.destroy();
704 for (int i=0; i<incexe->num_opts; i++) {
705 FOPTS *fopt = incexe->opts_list[i];
706 fopt->match.destroy();
707 fopt->base_list.destroy();
710 if (incexe->opts_list) {
711 free(incexe->opts_list);
717 * Free memory of resource -- called when daemon terminates.
718 * NB, we don't need to worry about freeing any references
719 * to other resources as they will be freed when that
720 * resource chain is traversed. Mainly we worry about freeing
721 * allocated strings (names).
723 void free_resource(RES *sres, int type)
726 RES *nres; /* next resource if linked */
727 URES *res = (URES *)sres;
732 /* common stuff -- free the resource name and description */
733 nres = (RES *)res->res_dir.hdr.next;
734 if (res->res_dir.hdr.name) {
735 free(res->res_dir.hdr.name);
737 if (res->res_dir.hdr.desc) {
738 free(res->res_dir.hdr.desc);
743 if (res->res_dir.working_directory) {
744 free(res->res_dir.working_directory);
746 if (res->res_dir.pid_directory) {
747 free(res->res_dir.pid_directory);
749 if (res->res_dir.subsys_directory) {
750 free(res->res_dir.subsys_directory);
752 if (res->res_dir.password) {
753 free(res->res_dir.password);
755 if (res->res_dir.query_file) {
756 free(res->res_dir.query_file);
758 if (res->res_dir.DIRaddr) {
759 free(res->res_dir.DIRaddr);
765 if (res->res_con.password) {
766 free(res->res_con.password);
768 for (int i=0; i<Num_ACL; i++) {
769 if (res->res_con.ACL_lists[i]) {
770 delete res->res_con.ACL_lists[i];
771 res->res_con.ACL_lists[i] = NULL;
776 if (res->res_client.address) {
777 free(res->res_client.address);
779 if (res->res_client.password) {
780 free(res->res_client.password);
784 if (res->res_store.address) {
785 free(res->res_store.address);
787 if (res->res_store.password) {
788 free(res->res_store.password);
790 if (res->res_store.media_type) {
791 free(res->res_store.media_type);
793 if (res->res_store.dev_name) {
794 free(res->res_store.dev_name);
798 if (res->res_cat.db_address) {
799 free(res->res_cat.db_address);
801 if (res->res_cat.db_socket) {
802 free(res->res_cat.db_socket);
804 if (res->res_cat.db_user) {
805 free(res->res_cat.db_user);
807 if (res->res_cat.db_name) {
808 free(res->res_cat.db_name);
810 if (res->res_cat.db_password) {
811 free(res->res_cat.db_password);
815 if ((num=res->res_fs.num_includes)) {
817 free_incexe(res->res_fs.include_items[num]);
819 free(res->res_fs.include_items);
821 res->res_fs.num_includes = 0;
822 if ((num=res->res_fs.num_excludes)) {
824 free_incexe(res->res_fs.exclude_items[num]);
826 free(res->res_fs.exclude_items);
828 res->res_fs.num_excludes = 0;
831 if (res->res_pool.pool_type) {
832 free(res->res_pool.pool_type);
834 if (res->res_pool.label_format) {
835 free(res->res_pool.label_format);
837 if (res->res_pool.cleaning_prefix) {
838 free(res->res_pool.cleaning_prefix);
842 if (res->res_sch.run) {
844 nrun = res->res_sch.run;
854 if (res->res_job.RestoreWhere) {
855 free(res->res_job.RestoreWhere);
857 if (res->res_job.RestoreBootstrap) {
858 free(res->res_job.RestoreBootstrap);
860 if (res->res_job.WriteBootstrap) {
861 free(res->res_job.WriteBootstrap);
863 if (res->res_job.RunBeforeJob) {
864 free(res->res_job.RunBeforeJob);
866 if (res->res_job.RunAfterJob) {
867 free(res->res_job.RunAfterJob);
869 if (res->res_job.RunAfterFailedJob) {
870 free(res->res_job.RunAfterFailedJob);
872 if (res->res_job.ClientRunBeforeJob) {
873 free(res->res_job.ClientRunBeforeJob);
875 if (res->res_job.ClientRunAfterJob) {
876 free(res->res_job.ClientRunAfterJob);
880 if (res->res_msgs.mail_cmd) {
881 free(res->res_msgs.mail_cmd);
883 if (res->res_msgs.operator_cmd) {
884 free(res->res_msgs.operator_cmd);
886 free_msgs_res((MSGS *)res); /* free message resource */
890 printf("Unknown resource type %d in free_resource.\n", type);
892 /* Common stuff again -- free the resource, recurse to next one */
897 free_resource(nres, type);
902 * Save the new resource by chaining it into the head list for
903 * the resource. If this is pass 2, we update any resource
904 * pointers because they may not have been defined until
907 void save_resource(int type, RES_ITEM *items, int pass)
910 int rindex = type - r_first;
914 /* Check Job requirements after applying JobDefs */
915 if (type != R_JOB && type != R_JOBDEFS) {
917 * Ensure that all required items are present
919 for (i=0; items[i].name; i++) {
920 if (items[i].flags & ITEM_REQUIRED) {
921 if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
922 Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n",
923 items[i].name, resources[rindex]);
926 /* If this triggers, take a look at lib/parse_conf.h */
927 if (i >= MAX_RES_ITEMS) {
928 Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]);
934 * During pass 2 in each "store" routine, we looked up pointers
935 * to all the resources referrenced in the current resource, now we
936 * must copy their addresses from the static record to the allocated
941 /* Resources not containing a resource */
950 /* Resources containing another resource */
952 if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) {
953 Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name);
955 res->res_dir.messages = res_all.res_dir.messages;
959 if ((res = (URES *)GetResWithName(type, res_all.res_dir.hdr.name)) == NULL) {
960 Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n",
961 res_all.res_dir.hdr.name);
963 res->res_job.messages = res_all.res_job.messages;
964 res->res_job.schedule = res_all.res_job.schedule;
965 res->res_job.client = res_all.res_job.client;
966 res->res_job.fileset = res_all.res_job.fileset;
967 res->res_job.storage = res_all.res_job.storage;
968 res->res_job.pool = res_all.res_job.pool;
969 res->res_job.full_pool = res_all.res_job.full_pool;
970 res->res_job.inc_pool = res_all.res_job.inc_pool;
971 res->res_job.dif_pool = res_all.res_job.dif_pool;
972 res->res_job.verify_job = res_all.res_job.verify_job;
973 res->res_job.jobdefs = res_all.res_job.jobdefs;
976 if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) {
977 Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name);
979 res->res_counter.Catalog = res_all.res_counter.Catalog;
980 res->res_counter.WrapCounter = res_all.res_counter.WrapCounter;
984 if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_client.hdr.name)) == NULL) {
985 Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name);
987 res->res_client.catalog = res_all.res_client.catalog;
991 * Schedule is a bit different in that it contains a RUN record
992 * chain which isn't a "named" resource. This chain was linked
993 * in by run_conf.c during pass 2, so here we jam the pointer
994 * into the Schedule resource.
996 if ((res = (URES *)GetResWithName(R_SCHEDULE, res_all.res_client.hdr.name)) == NULL) {
997 Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name);
999 res->res_sch.run = res_all.res_sch.run;
1002 Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type);
1006 /* Note, the resource name was already saved during pass 1,
1007 * so here, we can just release it.
1009 if (res_all.res_dir.hdr.name) {
1010 free(res_all.res_dir.hdr.name);
1011 res_all.res_dir.hdr.name = NULL;
1013 if (res_all.res_dir.hdr.desc) {
1014 free(res_all.res_dir.hdr.desc);
1015 res_all.res_dir.hdr.desc = NULL;
1021 * The following code is only executed during pass 1
1025 size = sizeof(DIRRES);
1028 size = sizeof(CONRES);
1031 size =sizeof(CLIENT);
1034 size = sizeof(STORE);
1044 size = sizeof(FILESET);
1047 size = sizeof(SCHED);
1050 size = sizeof(POOL);
1053 size = sizeof(MSGS);
1056 size = sizeof(COUNTER);
1059 printf("Unknown resource type %d in save_resrouce.\n", type);
1066 if (type == R_JOBDEFS) {
1067 Dmsg0(200, "Storing JobDefs definition.\n");
1069 res = (URES *)malloc(size);
1070 memcpy(res, &res_all, size);
1071 if (!resources[rindex].res_head) {
1072 resources[rindex].res_head = (RES *)res; /* store first entry */
1073 Dmsg3(200, "Inserting first %s res: %s index=%d\n", res_to_str(type),
1074 res->res_dir.hdr.name, rindex);
1077 /* Add new res to end of chain */
1078 for (next=resources[rindex].res_head; next->next; next=next->next) {
1079 if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
1080 Emsg2(M_ERROR_TERM, 0,
1081 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
1082 resources[rindex].name, res->res_dir.hdr.name);
1085 next->next = (RES *)res;
1086 Dmsg4(200, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
1087 res->res_dir.hdr.name, rindex, pass);
1093 * Store JobType (backup, verify, restore)
1096 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass)
1100 token = lex_get_token(lc, T_NAME);
1101 /* Store the type both pass 1 and pass 2 */
1102 for (i=0; jobtypes[i].type_name; i++) {
1103 if (strcasecmp(lc->str, jobtypes[i].type_name) == 0) {
1104 *(int *)(item->value) = jobtypes[i].job_type;
1110 scan_err1(lc, "Expected a Job Type keyword, got: %s", lc->str);
1113 set_bit(index, res_all.hdr.item_present);
1117 * Store Job Level (Full, Incremental, ...)
1120 void store_level(LEX *lc, RES_ITEM *item, int index, int pass)
1124 token = lex_get_token(lc, T_NAME);
1125 /* Store the level pass 2 so that type is defined */
1126 for (i=0; joblevels[i].level_name; i++) {
1127 if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1128 *(int *)(item->value) = joblevels[i].level;
1134 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1137 set_bit(index, res_all.hdr.item_present);
1140 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass)
1143 token = lex_get_token(lc, T_NAME);
1144 /* Scan Replacement options */
1145 for (i=0; ReplaceOptions[i].name; i++) {
1146 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1147 *(int *)(item->value) = ReplaceOptions[i].token;
1153 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1156 set_bit(index, res_all.hdr.item_present);
1160 * Store ACL (access control list)
1163 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
1168 token = lex_get_token(lc, T_NAME);
1170 if (((alist **)item->value)[item->code] == NULL) {
1171 ((alist **)item->value)[item->code] = new alist(10, owned_by_alist);
1172 // Dmsg1(400, "Defined new ACL alist at %d\n", item->code);
1174 ((alist **)item->value)[item->code]->append(bstrdup(lc->str));
1175 // Dmsg2(400, "Appended to %d %s\n", item->code, lc->str);
1177 token = lex_get_token(lc, T_ALL);
1178 if (token == T_COMMA) {
1179 continue; /* get another ACL */
1183 set_bit(index, res_all.hdr.item_present);
1187 #ifdef old_deprecated_code
1189 * Store backup/verify info for Job record
1191 * Note, this code is used for both BACKUP and VERIFY jobs
1193 * Backup = Client=<client-name> FileSet=<FileSet-name> Level=<level>
1195 static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
1199 int options = lc->options;
1201 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1204 ((JOB *)(item->value))->JobType = item->code;
1205 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1208 Dmsg1(150, "store_backup got token=%s\n", lex_tok_to_str(token));
1210 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1211 scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
1213 Dmsg1(190, "Got keyword: %s\n", lc->str);
1214 for (i=0; BakVerFields[i].name; i++) {
1215 if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
1217 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1218 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1220 token = lex_get_token(lc, T_NAME);
1221 Dmsg1(190, "Got value: %s\n", lc->str);
1222 switch (BakVerFields[i].token) {
1224 /* Find Client Resource */
1226 res = GetResWithName(R_CLIENT, lc->str);
1228 scan_err1(lc, "Could not find specified Client Resource: %s",
1231 res_all.res_job.client = (CLIENT *)res;
1235 /* Find FileSet Resource */
1237 res = GetResWithName(R_FILESET, lc->str);
1239 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1242 res_all.res_job.fileset = (FILESET *)res;
1247 for (i=0; joblevels[i].level_name; i++) {
1248 if (joblevels[i].job_type == item->code &&
1249 strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1250 ((JOB *)(item->value))->level = joblevels[i].level;
1256 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1261 } /* end if strcmp() */
1264 scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
1267 lc->options = options; /* reset original options */
1268 set_bit(index, res_all.hdr.item_present);
1272 * Store restore info for Job record
1274 * Restore = JobId=<job-id> Where=<root-directory> Replace=<options> Bootstrap=<file>
1277 static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
1281 int options = lc->options;
1283 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1285 Dmsg0(190, "Enter store_restore()\n");
1287 ((JOB *)(item->value))->JobType = item->code;
1288 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1291 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1292 scan_err1(lc, "expected a name, got: %s", lc->str);
1294 for (i=0; RestoreFields[i].name; i++) {
1295 Dmsg1(190, "Restore kw=%s\n", lc->str);
1296 if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
1298 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1299 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1301 token = lex_get_token(lc, T_ALL);
1302 Dmsg1(190, "Restore value=%s\n", lc->str);
1303 switch (RestoreFields[i].token) {
1306 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1307 scan_err1(lc, "Expected a Restore bootstrap file, got: %s", lc->str);
1310 res_all.res_job.RestoreBootstrap = bstrdup(lc->str);
1314 /* Find Client Resource */
1316 res = GetResWithName(R_CLIENT, lc->str);
1318 scan_err1(lc, "Could not find specified Client Resource: %s",
1321 res_all.res_job.client = (CLIENT *)res;
1325 /* Find FileSet Resource */
1327 res = GetResWithName(R_FILESET, lc->str);
1329 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1332 res_all.res_job.fileset = (FILESET *)res;
1337 if (token != T_NUMBER) {
1338 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1341 res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
1342 Dmsg1(190, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
1344 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1349 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1350 scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
1353 res_all.res_job.RestoreWhere = bstrdup(lc->str);
1357 /* Replacement options */
1358 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1359 scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
1361 /* Fix to scan Replacement options */
1362 for (i=0; ReplaceOptions[i].name; i++) {
1363 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1364 ((JOB *)(item->value))->replace = ReplaceOptions[i].token;
1370 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1375 } /* end if strcmp() */
1378 scan_err1(lc, "%s not a valid Restore keyword", lc->str);
1381 lc->options = options; /* reset original options */
1382 set_bit(index, res_all.hdr.item_present);