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, 0, 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 {NULL, NULL, NULL, 0, 0, 0}
256 /* Schedule -- see run_conf.c */
259 * name handler value code flags default_value
261 static RES_ITEM sch_items[] = {
262 {"name", store_name, ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0},
263 {"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0},
264 {"run", store_run, ITEM(res_sch.run), 0, 0, 0},
265 {NULL, NULL, NULL, 0, 0, 0}
270 * name handler value code flags default_value
272 static RES_ITEM pool_items[] = {
273 {"name", store_name, ITEM(res_pool.hdr.name), 0, ITEM_REQUIRED, 0},
274 {"description", store_str, ITEM(res_pool.hdr.desc), 0, 0, 0},
275 {"pooltype", store_strname, ITEM(res_pool.pool_type), 0, ITEM_REQUIRED, 0},
276 {"labelformat", store_strname, ITEM(res_pool.label_format), 0, 0, 0},
277 {"cleaningprefix", store_strname, ITEM(res_pool.cleaning_prefix), 0, 0, 0},
278 {"usecatalog", store_yesno, ITEM(res_pool.use_catalog), 1, ITEM_DEFAULT, 1},
279 {"usevolumeonce", store_yesno, ITEM(res_pool.use_volume_once), 1, 0, 0},
280 {"purgeoldestvolume", store_yesno, ITEM(res_pool.purge_oldest_volume), 1, 0, 0},
281 {"recycleoldestvolume", store_yesno, ITEM(res_pool.recycle_oldest_volume), 1, 0, 0},
282 {"recyclecurrentvolume", store_yesno, ITEM(res_pool.recycle_current_volume), 1, 0, 0},
283 {"maximumvolumes", store_pint, ITEM(res_pool.max_volumes), 0, 0, 0},
284 {"maximumvolumejobs", store_pint, ITEM(res_pool.MaxVolJobs), 0, 0, 0},
285 {"maximumvolumefiles", store_pint, ITEM(res_pool.MaxVolFiles), 0, 0, 0},
286 {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes), 0, 0, 0},
287 {"acceptanyvolume", store_yesno, ITEM(res_pool.accept_any_volume), 1, ITEM_DEFAULT, 1},
288 {"catalogfiles", store_yesno, ITEM(res_pool.catalog_files), 1, ITEM_DEFAULT, 1},
289 {"volumeretention", store_time, ITEM(res_pool.VolRetention), 0, ITEM_DEFAULT, 60*60*24*365},
290 {"volumeuseduration", store_time, ITEM(res_pool.VolUseDuration),0, 0, 0},
291 {"autoprune", store_yesno, ITEM(res_pool.AutoPrune), 1, ITEM_DEFAULT, 1},
292 {"recycle", store_yesno, ITEM(res_pool.Recycle), 1, ITEM_DEFAULT, 1},
293 {NULL, NULL, NULL, 0, 0, 0}
298 * name handler value code flags default_value
300 static RES_ITEM counter_items[] = {
301 {"name", store_name, ITEM(res_counter.hdr.name), 0, ITEM_REQUIRED, 0},
302 {"description", store_str, ITEM(res_counter.hdr.desc), 0, 0, 0},
303 {"minimum", store_int, ITEM(res_counter.MinValue), 0, ITEM_DEFAULT, 0},
304 {"maximum", store_pint, ITEM(res_counter.MaxValue), 0, ITEM_DEFAULT, INT32_MAX},
305 {"wrapcounter", store_res, ITEM(res_counter.WrapCounter), R_COUNTER, 0, 0},
306 {"catalog", store_res, ITEM(res_counter.Catalog), R_CATALOG, 0, 0},
307 {NULL, NULL, NULL, 0, 0, 0}
311 /* Message resource */
312 extern RES_ITEM msgs_items[];
315 * This is the master resource definition.
316 * It must have one item for each of the resources.
318 * NOTE!!! keep it in the same order as the R_codes
319 * or eliminate all resources[rindex].name
321 * name items rcode res_head
323 RES_TABLE resources[] = {
324 {"director", dir_items, R_DIRECTOR},
325 {"client", cli_items, R_CLIENT},
326 {"job", job_items, R_JOB},
327 {"storage", store_items, R_STORAGE},
328 {"catalog", cat_items, R_CATALOG},
329 {"schedule", sch_items, R_SCHEDULE},
330 {"fileset", fs_items, R_FILESET},
331 {"pool", pool_items, R_POOL},
332 {"messages", msgs_items, R_MSGS},
333 {"counter", counter_items, R_COUNTER},
334 {"console", con_items, R_CONSOLE},
335 {"jobdefs", job_items, R_JOBDEFS},
340 /* Keywords (RHS) permitted in Job Level records
342 * level_name level job_type
344 struct s_jl joblevels[] = {
345 {"Full", L_FULL, JT_BACKUP},
346 {"Base", L_BASE, JT_BACKUP},
347 {"Incremental", L_INCREMENTAL, JT_BACKUP},
348 {"Differential", L_DIFFERENTIAL, JT_BACKUP},
349 {"Since", L_SINCE, JT_BACKUP},
350 {"Catalog", L_VERIFY_CATALOG, JT_VERIFY},
351 {"InitCatalog", L_VERIFY_INIT, JT_VERIFY},
352 {"VolumeToCatalog", L_VERIFY_VOLUME_TO_CATALOG, JT_VERIFY},
353 {"DiskToCatalog", L_VERIFY_DISK_TO_CATALOG, JT_VERIFY},
354 {"Data", L_VERIFY_DATA, JT_VERIFY},
355 {" ", L_NONE, JT_ADMIN},
356 {" ", L_NONE, JT_RESTORE},
360 /* Keywords (RHS) permitted in Job type records
364 struct s_jt jobtypes[] = {
365 {"backup", JT_BACKUP},
367 {"verify", JT_VERIFY},
368 {"restore", JT_RESTORE},
372 #ifdef old_deprecated_code
374 /* Keywords (RHS) permitted in Backup and Verify records */
375 static struct s_kw BakVerFields[] = {
382 /* Keywords (RHS) permitted in Restore records */
383 static struct s_kw RestoreFields[] = {
386 {"jobid", 'J'}, /* JobId to restore */
387 {"where", 'W'}, /* root of restore */
388 {"replace", 'R'}, /* replacement options */
389 {"bootstrap", 'B'}, /* bootstrap file */
394 /* Options permitted in Restore replace= */
395 struct s_kw ReplaceOptions[] = {
396 {"always", REPLACE_ALWAYS},
397 {"ifnewer", REPLACE_IFNEWER},
398 {"ifolder", REPLACE_IFOLDER},
399 {"never", REPLACE_NEVER},
403 const char *level_to_str(int level)
406 static char level_no[30];
407 const char *str = level_no;
409 bsnprintf(level_no, sizeof(level_no), "%d", level); /* default if not found */
410 for (i=0; joblevels[i].level_name; i++) {
411 if (level == joblevels[i].level) {
412 str = joblevels[i].level_name;
419 /* Dump contents of resource */
420 void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
422 URES *res = (URES *)reshdr;
424 char ed1[100], ed2[100];
427 sendit(sock, "No %s resource defined\n", res_to_str(type));
430 if (type < 0) { /* no recursion */
436 sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n",
437 reshdr->name, res->res_dir.MaxConcurrentJobs,
438 edit_uint64(res->res_dir.FDConnectTimeout, ed1),
439 edit_uint64(res->res_dir.SDConnectTimeout, ed2));
440 if (res->res_dir.query_file) {
441 sendit(sock, " query_file=%s\n", res->res_dir.query_file);
443 if (res->res_dir.messages) {
444 sendit(sock, " --> ");
445 dump_resource(-R_MSGS, (RES *)res->res_dir.messages, sendit, sock);
449 sendit(sock, "Console: name=%s SSL=%d\n",
450 res->res_con.hdr.name, res->res_con.enable_ssl);
453 if (res->res_counter.WrapCounter) {
454 sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n",
455 res->res_counter.hdr.name, res->res_counter.MinValue,
456 res->res_counter.MaxValue, res->res_counter.CurrentValue,
457 res->res_counter.WrapCounter->hdr.name);
459 sendit(sock, "Counter: name=%s min=%d max=%d\n",
460 res->res_counter.hdr.name, res->res_counter.MinValue,
461 res->res_counter.MaxValue);
463 if (res->res_counter.Catalog) {
464 sendit(sock, " --> ");
465 dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock);
470 sendit(sock, "Client: name=%s address=%s FDport=%d MaxJobs=%u\n",
471 res->res_client.hdr.name, res->res_client.address, res->res_client.FDport,
472 res->res_client.MaxConcurrentJobs);
473 sendit(sock, " JobRetention=%s FileRetention=%s AutoPrune=%d\n",
474 edit_utime(res->res_client.JobRetention, ed1, sizeof(ed1)),
475 edit_utime(res->res_client.FileRetention, ed2, sizeof(ed2)),
476 res->res_client.AutoPrune);
477 if (res->res_client.catalog) {
478 sendit(sock, " --> ");
479 dump_resource(-R_CATALOG, (RES *)res->res_client.catalog, sendit, sock);
483 sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n\
484 DeviceName=%s MediaType=%s\n",
485 res->res_store.hdr.name, res->res_store.address, res->res_store.SDport,
486 res->res_store.MaxConcurrentJobs,
487 res->res_store.dev_name, res->res_store.media_type);
490 sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n\
492 res->res_cat.hdr.name, NPRT(res->res_cat.db_address),
493 res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user));
497 sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n",
498 type == R_JOB ? "Job" : "JobDefs",
499 res->res_job.hdr.name, res->res_job.JobType,
500 level_to_str(res->res_job.level), res->res_job.Priority,
501 res->res_job.MaxConcurrentJobs);
502 sendit(sock, " Resched=%d Times=%d Interval=%s Spool=%d\n",
503 res->res_job.RescheduleOnError, res->res_job.RescheduleTimes,
504 edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1),
505 res->res_job.spool_data);
506 if (res->res_job.client) {
507 sendit(sock, " --> ");
508 dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
510 if (res->res_job.fileset) {
511 sendit(sock, " --> ");
512 dump_resource(-R_FILESET, (RES *)res->res_job.fileset, sendit, sock);
514 if (res->res_job.schedule) {
515 sendit(sock, " --> ");
516 dump_resource(-R_SCHEDULE, (RES *)res->res_job.schedule, sendit, sock);
518 if (res->res_job.RestoreWhere) {
519 sendit(sock, " --> Where=%s\n", NPRT(res->res_job.RestoreWhere));
521 if (res->res_job.RestoreBootstrap) {
522 sendit(sock, " --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap));
524 if (res->res_job.RunBeforeJob) {
525 sendit(sock, " --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob));
527 if (res->res_job.RunAfterJob) {
528 sendit(sock, " --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob));
530 if (res->res_job.RunAfterFailedJob) {
531 sendit(sock, " --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob));
533 if (res->res_job.WriteBootstrap) {
534 sendit(sock, " --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap));
536 if (res->res_job.storage) {
537 sendit(sock, " --> ");
538 dump_resource(-R_STORAGE, (RES *)res->res_job.storage, sendit, sock);
540 if (res->res_job.pool) {
541 sendit(sock, " --> ");
542 dump_resource(-R_POOL, (RES *)res->res_job.pool, sendit, sock);
544 if (res->res_job.full_pool) {
545 sendit(sock, " --> ");
546 dump_resource(-R_POOL, (RES *)res->res_job.full_pool, sendit, sock);
548 if (res->res_job.inc_pool) {
549 sendit(sock, " --> ");
550 dump_resource(-R_POOL, (RES *)res->res_job.inc_pool, sendit, sock);
552 if (res->res_job.dif_pool) {
553 sendit(sock, " --> ");
554 dump_resource(-R_POOL, (RES *)res->res_job.dif_pool, sendit, sock);
556 if (res->res_job.verify_job) {
557 sendit(sock, " --> ");
558 dump_resource(-type, (RES *)res->res_job.verify_job, sendit, sock);
561 if (res->res_job.messages) {
562 sendit(sock, " --> ");
563 dump_resource(-R_MSGS, (RES *)res->res_job.messages, sendit, sock);
569 sendit(sock, "FileSet: name=%s\n", res->res_fs.hdr.name);
570 for (i=0; i<res->res_fs.num_includes; i++) {
571 INCEXE *incexe = res->res_fs.include_items[i];
572 for (j=0; j<incexe->num_opts; j++) {
573 FOPTS *fo = incexe->opts_list[j];
574 sendit(sock, " O %s\n", fo->opts);
575 for (k=0; k<fo->regex.size(); k++) {
576 sendit(sock, " R %s\n", fo->regex.get(k));
578 for (k=0; k<fo->wild.size(); k++) {
579 sendit(sock, " W %s\n", fo->wild.get(k));
581 for (k=0; k<fo->base.size(); k++) {
582 sendit(sock, " B %s\n", fo->base.get(k));
585 sendit(sock, " D %s\n", fo->reader);
588 sendit(sock, " T %s\n", fo->writer);
590 sendit(sock, " N\n");
592 for (j=0; j<incexe->name_list.size(); j++) {
593 sendit(sock, " I %s\n", incexe->name_list.get(j));
595 if (incexe->name_list.size()) {
596 sendit(sock, " N\n");
600 for (i=0; i<res->res_fs.num_excludes; i++) {
601 INCEXE *incexe = res->res_fs.exclude_items[i];
602 for (j=0; j<incexe->name_list.size(); j++) {
603 sendit(sock, " E %s\n", incexe->name_list.get(j));
605 if (incexe->name_list.size()) {
606 sendit(sock, " N\n");
612 if (res->res_sch.run) {
614 RUN *run = res->res_sch.run;
615 char buf[1000], num[30];
616 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
621 sendit(sock, " --> Run Level=%s\n", level_to_str(run->level));
622 bstrncpy(buf, " hour=", sizeof(buf));
623 for (i=0; i<24; i++) {
624 if (bit_is_set(i, run->hour)) {
625 bsnprintf(num, sizeof(num), "%d ", i);
626 bstrncat(buf, num, sizeof(buf));
629 bstrncat(buf, "\n", sizeof(buf));
631 bstrncpy(buf, " mday=", sizeof(buf));
632 for (i=0; i<31; i++) {
633 if (bit_is_set(i, run->mday)) {
634 bsnprintf(num, sizeof(num), "%d ", i);
635 bstrncat(buf, num, sizeof(buf));
638 bstrncat(buf, "\n", sizeof(buf));
640 bstrncpy(buf, " month=", sizeof(buf));
641 for (i=0; i<12; i++) {
642 if (bit_is_set(i, run->month)) {
643 bsnprintf(num, sizeof(num), "%d ", i);
644 bstrncat(buf, num, sizeof(buf));
647 bstrncat(buf, "\n", sizeof(buf));
649 bstrncpy(buf, " wday=", sizeof(buf));
650 for (i=0; i<7; i++) {
651 if (bit_is_set(i, run->wday)) {
652 bsnprintf(num, sizeof(num), "%d ", i);
653 bstrncat(buf, num, sizeof(buf));
656 bstrncat(buf, "\n", sizeof(buf));
658 bstrncpy(buf, " wom=", sizeof(buf));
659 for (i=0; i<5; i++) {
660 if (bit_is_set(i, run->wom)) {
661 bsnprintf(num, sizeof(num), "%d ", i);
662 bstrncat(buf, num, sizeof(buf));
665 bstrncat(buf, "\n", sizeof(buf));
667 bstrncpy(buf, " woy=", sizeof(buf));
668 for (i=0; i<54; i++) {
669 if (bit_is_set(i, run->woy)) {
670 bsnprintf(num, sizeof(num), "%d ", i);
671 bstrncat(buf, num, sizeof(buf));
674 bstrncat(buf, "\n", sizeof(buf));
676 sendit(sock, " mins=%d\n", run->minute);
678 sendit(sock, " --> ");
679 dump_resource(-R_POOL, (RES *)run->pool, sendit, sock);
682 sendit(sock, " --> ");
683 dump_resource(-R_STORAGE, (RES *)run->storage, sendit, sock);
686 sendit(sock, " --> ");
687 dump_resource(-R_MSGS, (RES *)run->msgs, sendit, sock);
689 /* If another Run record is chained in, go print it */
695 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
699 sendit(sock, "Pool: name=%s PoolType=%s\n", res->res_pool.hdr.name,
700 res->res_pool.pool_type);
701 sendit(sock, " use_cat=%d use_once=%d acpt_any=%d cat_files=%d\n",
702 res->res_pool.use_catalog, res->res_pool.use_volume_once,
703 res->res_pool.accept_any_volume, res->res_pool.catalog_files);
704 sendit(sock, " max_vols=%d auto_prune=%d VolRetention=%s\n",
705 res->res_pool.max_volumes, res->res_pool.AutoPrune,
706 edit_utime(res->res_pool.VolRetention, ed1, sizeof(ed1)));
707 sendit(sock, " VolUse=%s recycle=%d LabelFormat=%s\n",
708 edit_utime(res->res_pool.VolUseDuration, ed1, sizeof(ed1)),
709 res->res_pool.Recycle,
710 NPRT(res->res_pool.label_format));
711 sendit(sock, " CleaningPrefix=%s\n",
712 NPRT(res->res_pool.cleaning_prefix));
713 sendit(sock, " recyleOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n",
714 res->res_pool.purge_oldest_volume,
715 res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
718 sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
719 if (res->res_msgs.mail_cmd)
720 sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd);
721 if (res->res_msgs.operator_cmd)
722 sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd);
725 sendit(sock, "Unknown resource type %d in dump_resource.\n", type);
728 if (recurse && res->res_dir.hdr.next) {
729 dump_resource(type, res->res_dir.hdr.next, sendit, sock);
734 * Free all the members of an INCEXE structure
736 static void free_incexe(INCEXE *incexe)
738 incexe->name_list.destroy();
739 for (int i=0; i<incexe->num_opts; i++) {
740 FOPTS *fopt = incexe->opts_list[i];
741 fopt->regex.destroy();
742 fopt->wild.destroy();
743 fopt->base.destroy();
752 if (incexe->opts_list) {
753 free(incexe->opts_list);
759 * Free memory of resource -- called when daemon terminates.
760 * NB, we don't need to worry about freeing any references
761 * to other resources as they will be freed when that
762 * resource chain is traversed. Mainly we worry about freeing
763 * allocated strings (names).
765 void free_resource(RES *sres, int type)
768 RES *nres; /* next resource if linked */
769 URES *res = (URES *)sres;
774 /* common stuff -- free the resource name and description */
775 nres = (RES *)res->res_dir.hdr.next;
776 if (res->res_dir.hdr.name) {
777 free(res->res_dir.hdr.name);
779 if (res->res_dir.hdr.desc) {
780 free(res->res_dir.hdr.desc);
785 if (res->res_dir.working_directory) {
786 free(res->res_dir.working_directory);
788 if (res->res_dir.pid_directory) {
789 free(res->res_dir.pid_directory);
791 if (res->res_dir.subsys_directory) {
792 free(res->res_dir.subsys_directory);
794 if (res->res_dir.password) {
795 free(res->res_dir.password);
797 if (res->res_dir.query_file) {
798 free(res->res_dir.query_file);
800 if (res->res_dir.DIRaddrs) {
801 free_addresses(res->res_dir.DIRaddrs);
807 if (res->res_con.password) {
808 free(res->res_con.password);
810 for (int i=0; i<Num_ACL; i++) {
811 if (res->res_con.ACL_lists[i]) {
812 delete res->res_con.ACL_lists[i];
813 res->res_con.ACL_lists[i] = NULL;
818 if (res->res_client.address) {
819 free(res->res_client.address);
821 if (res->res_client.password) {
822 free(res->res_client.password);
826 if (res->res_store.address) {
827 free(res->res_store.address);
829 if (res->res_store.password) {
830 free(res->res_store.password);
832 if (res->res_store.media_type) {
833 free(res->res_store.media_type);
835 if (res->res_store.dev_name) {
836 free(res->res_store.dev_name);
840 if (res->res_cat.db_address) {
841 free(res->res_cat.db_address);
843 if (res->res_cat.db_socket) {
844 free(res->res_cat.db_socket);
846 if (res->res_cat.db_user) {
847 free(res->res_cat.db_user);
849 if (res->res_cat.db_name) {
850 free(res->res_cat.db_name);
852 if (res->res_cat.db_password) {
853 free(res->res_cat.db_password);
857 if ((num=res->res_fs.num_includes)) {
859 free_incexe(res->res_fs.include_items[num]);
861 free(res->res_fs.include_items);
863 res->res_fs.num_includes = 0;
864 if ((num=res->res_fs.num_excludes)) {
866 free_incexe(res->res_fs.exclude_items[num]);
868 free(res->res_fs.exclude_items);
870 res->res_fs.num_excludes = 0;
873 if (res->res_pool.pool_type) {
874 free(res->res_pool.pool_type);
876 if (res->res_pool.label_format) {
877 free(res->res_pool.label_format);
879 if (res->res_pool.cleaning_prefix) {
880 free(res->res_pool.cleaning_prefix);
884 if (res->res_sch.run) {
886 nrun = res->res_sch.run;
896 if (res->res_job.RestoreWhere) {
897 free(res->res_job.RestoreWhere);
899 if (res->res_job.RestoreBootstrap) {
900 free(res->res_job.RestoreBootstrap);
902 if (res->res_job.WriteBootstrap) {
903 free(res->res_job.WriteBootstrap);
905 if (res->res_job.RunBeforeJob) {
906 free(res->res_job.RunBeforeJob);
908 if (res->res_job.RunAfterJob) {
909 free(res->res_job.RunAfterJob);
911 if (res->res_job.RunAfterFailedJob) {
912 free(res->res_job.RunAfterFailedJob);
914 if (res->res_job.ClientRunBeforeJob) {
915 free(res->res_job.ClientRunBeforeJob);
917 if (res->res_job.ClientRunAfterJob) {
918 free(res->res_job.ClientRunAfterJob);
922 if (res->res_msgs.mail_cmd) {
923 free(res->res_msgs.mail_cmd);
925 if (res->res_msgs.operator_cmd) {
926 free(res->res_msgs.operator_cmd);
928 free_msgs_res((MSGS *)res); /* free message resource */
932 printf("Unknown resource type %d in free_resource.\n", type);
934 /* Common stuff again -- free the resource, recurse to next one */
939 free_resource(nres, type);
944 * Save the new resource by chaining it into the head list for
945 * the resource. If this is pass 2, we update any resource
946 * pointers because they may not have been defined until
949 void save_resource(int type, RES_ITEM *items, int pass)
952 int rindex = type - r_first;
956 /* Check Job requirements after applying JobDefs */
957 if (type != R_JOB && type != R_JOBDEFS) {
959 * Ensure that all required items are present
961 for (i=0; items[i].name; i++) {
962 if (items[i].flags & ITEM_REQUIRED) {
963 if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
964 Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n",
965 items[i].name, resources[rindex]);
968 /* If this triggers, take a look at lib/parse_conf.h */
969 if (i >= MAX_RES_ITEMS) {
970 Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]);
976 * During pass 2 in each "store" routine, we looked up pointers
977 * to all the resources referrenced in the current resource, now we
978 * must copy their addresses from the static record to the allocated
983 /* Resources not containing a resource */
992 /* Resources containing another resource */
994 if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) {
995 Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name);
997 res->res_dir.messages = res_all.res_dir.messages;
1001 if ((res = (URES *)GetResWithName(type, res_all.res_dir.hdr.name)) == NULL) {
1002 Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n",
1003 res_all.res_dir.hdr.name);
1005 res->res_job.messages = res_all.res_job.messages;
1006 res->res_job.schedule = res_all.res_job.schedule;
1007 res->res_job.client = res_all.res_job.client;
1008 res->res_job.fileset = res_all.res_job.fileset;
1009 res->res_job.storage = res_all.res_job.storage;
1010 res->res_job.pool = res_all.res_job.pool;
1011 res->res_job.full_pool = res_all.res_job.full_pool;
1012 res->res_job.inc_pool = res_all.res_job.inc_pool;
1013 res->res_job.dif_pool = res_all.res_job.dif_pool;
1014 res->res_job.verify_job = res_all.res_job.verify_job;
1015 res->res_job.jobdefs = res_all.res_job.jobdefs;
1018 if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) {
1019 Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name);
1021 res->res_counter.Catalog = res_all.res_counter.Catalog;
1022 res->res_counter.WrapCounter = res_all.res_counter.WrapCounter;
1026 if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_client.hdr.name)) == NULL) {
1027 Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name);
1029 res->res_client.catalog = res_all.res_client.catalog;
1033 * Schedule is a bit different in that it contains a RUN record
1034 * chain which isn't a "named" resource. This chain was linked
1035 * in by run_conf.c during pass 2, so here we jam the pointer
1036 * into the Schedule resource.
1038 if ((res = (URES *)GetResWithName(R_SCHEDULE, res_all.res_client.hdr.name)) == NULL) {
1039 Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name);
1041 res->res_sch.run = res_all.res_sch.run;
1044 Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type);
1048 /* Note, the resource name was already saved during pass 1,
1049 * so here, we can just release it.
1051 if (res_all.res_dir.hdr.name) {
1052 free(res_all.res_dir.hdr.name);
1053 res_all.res_dir.hdr.name = NULL;
1055 if (res_all.res_dir.hdr.desc) {
1056 free(res_all.res_dir.hdr.desc);
1057 res_all.res_dir.hdr.desc = NULL;
1063 * The following code is only executed during pass 1
1067 size = sizeof(DIRRES);
1070 size = sizeof(CONRES);
1073 size =sizeof(CLIENT);
1076 size = sizeof(STORE);
1086 size = sizeof(FILESET);
1089 size = sizeof(SCHED);
1092 size = sizeof(POOL);
1095 size = sizeof(MSGS);
1098 size = sizeof(COUNTER);
1101 printf("Unknown resource type %d in save_resrouce.\n", type);
1108 res = (URES *)malloc(size);
1109 memcpy(res, &res_all, size);
1110 if (!res_head[rindex]) {
1111 res_head[rindex] = (RES *)res; /* store first entry */
1112 Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
1113 res->res_dir.hdr.name, rindex);
1116 /* Add new res to end of chain */
1117 for (next=res_head[rindex]; next->next; next=next->next) {
1118 if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
1119 Emsg2(M_ERROR_TERM, 0,
1120 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
1121 resources[rindex].name, res->res_dir.hdr.name);
1124 next->next = (RES *)res;
1125 Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
1126 res->res_dir.hdr.name, rindex, pass);
1132 * Store JobType (backup, verify, restore)
1135 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass)
1139 token = lex_get_token(lc, T_NAME);
1140 /* Store the type both pass 1 and pass 2 */
1141 for (i=0; jobtypes[i].type_name; i++) {
1142 if (strcasecmp(lc->str, jobtypes[i].type_name) == 0) {
1143 *(int *)(item->value) = jobtypes[i].job_type;
1149 scan_err1(lc, "Expected a Job Type keyword, got: %s", lc->str);
1152 set_bit(index, res_all.hdr.item_present);
1156 * Store Job Level (Full, Incremental, ...)
1159 void store_level(LEX *lc, RES_ITEM *item, int index, int pass)
1163 token = lex_get_token(lc, T_NAME);
1164 /* Store the level pass 2 so that type is defined */
1165 for (i=0; joblevels[i].level_name; i++) {
1166 if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1167 *(int *)(item->value) = joblevels[i].level;
1173 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1176 set_bit(index, res_all.hdr.item_present);
1179 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass)
1182 token = lex_get_token(lc, T_NAME);
1183 /* Scan Replacement options */
1184 for (i=0; ReplaceOptions[i].name; i++) {
1185 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1186 *(int *)(item->value) = ReplaceOptions[i].token;
1192 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1195 set_bit(index, res_all.hdr.item_present);
1199 * Store ACL (access control list)
1202 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
1207 token = lex_get_token(lc, T_NAME);
1209 if (((alist **)item->value)[item->code] == NULL) {
1210 ((alist **)item->value)[item->code] = new alist(10, owned_by_alist);
1211 // Dmsg1(900, "Defined new ACL alist at %d\n", item->code);
1213 ((alist **)item->value)[item->code]->append(bstrdup(lc->str));
1214 // Dmsg2(900, "Appended to %d %s\n", item->code, lc->str);
1216 token = lex_get_token(lc, T_ALL);
1217 if (token == T_COMMA) {
1218 continue; /* get another ACL */
1222 set_bit(index, res_all.hdr.item_present);
1226 #ifdef old_deprecated_code
1228 * Store backup/verify info for Job record
1230 * Note, this code is used for both BACKUP and VERIFY jobs
1232 * Backup = Client=<client-name> FileSet=<FileSet-name> Level=<level>
1234 static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
1238 int options = lc->options;
1240 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1243 ((JOB *)(item->value))->JobType = item->code;
1244 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1247 Dmsg1(900, "store_backup got token=%s\n", lex_tok_to_str(token));
1249 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1250 scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
1252 Dmsg1(900, "Got keyword: %s\n", lc->str);
1253 for (i=0; BakVerFields[i].name; i++) {
1254 if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
1256 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1257 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1259 token = lex_get_token(lc, T_NAME);
1260 Dmsg1(900, "Got value: %s\n", lc->str);
1261 switch (BakVerFields[i].token) {
1263 /* Find Client Resource */
1265 res = GetResWithName(R_CLIENT, lc->str);
1267 scan_err1(lc, "Could not find specified Client Resource: %s",
1270 res_all.res_job.client = (CLIENT *)res;
1274 /* Find FileSet Resource */
1276 res = GetResWithName(R_FILESET, lc->str);
1278 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1281 res_all.res_job.fileset = (FILESET *)res;
1286 for (i=0; joblevels[i].level_name; i++) {
1287 if (joblevels[i].job_type == item->code &&
1288 strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1289 ((JOB *)(item->value))->level = joblevels[i].level;
1295 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1300 } /* end if strcmp() */
1303 scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
1306 lc->options = options; /* reset original options */
1307 set_bit(index, res_all.hdr.item_present);
1311 * Store restore info for Job record
1313 * Restore = JobId=<job-id> Where=<root-directory> Replace=<options> Bootstrap=<file>
1316 static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
1320 int options = lc->options;
1322 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1324 Dmsg0(900, "Enter store_restore()\n");
1326 ((JOB *)(item->value))->JobType = item->code;
1327 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1330 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1331 scan_err1(lc, "expected a name, got: %s", lc->str);
1333 for (i=0; RestoreFields[i].name; i++) {
1334 Dmsg1(900, "Restore kw=%s\n", lc->str);
1335 if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
1337 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1338 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1340 token = lex_get_token(lc, T_ALL);
1341 Dmsg1(900, "Restore value=%s\n", lc->str);
1342 switch (RestoreFields[i].token) {
1345 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1346 scan_err1(lc, "Expected a Restore bootstrap file, got: %s", lc->str);
1349 res_all.res_job.RestoreBootstrap = bstrdup(lc->str);
1353 /* Find Client Resource */
1355 res = GetResWithName(R_CLIENT, lc->str);
1357 scan_err1(lc, "Could not find specified Client Resource: %s",
1360 res_all.res_job.client = (CLIENT *)res;
1364 /* Find FileSet Resource */
1366 res = GetResWithName(R_FILESET, lc->str);
1368 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1371 res_all.res_job.fileset = (FILESET *)res;
1376 if (token != T_NUMBER) {
1377 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1380 res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
1381 Dmsg1(900, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
1383 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1388 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1389 scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
1392 res_all.res_job.RestoreWhere = bstrdup(lc->str);
1396 /* Replacement options */
1397 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1398 scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
1400 /* Fix to scan Replacement options */
1401 for (i=0; ReplaceOptions[i].name; i++) {
1402 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1403 ((JOB *)(item->value))->replace = ReplaceOptions[i].token;
1409 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1414 } /* end if strcmp() */
1417 scan_err1(lc, "%s not a valid Restore keyword", lc->str);
1420 lc->options = options; /* reset original options */
1421 set_bit(index, res_all.hdr.item_present);