From 37765ecf4e9f9833b94e79e119cea0a7fcb4d162 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 7 Sep 2004 17:17:11 +0000 Subject: [PATCH] Modify scan code so that in most places scanning will continue across the end of a line. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1588 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/.cvsignore | 1 + bacula/kernstodo | 96 +++++++------- bacula/src/cats/sql_find.c | 3 +- bacula/src/console/console_conf.c | 68 +++++----- bacula/src/dird/dird_conf.c | 199 ------------------------------ bacula/src/dird/inc_conf.c | 54 ++++---- bacula/src/lib/address_conf.c | 127 +++++++++---------- bacula/src/lib/lex.c | 45 +++++-- bacula/src/lib/lex.h | 3 +- bacula/src/lib/parse_conf.c | 16 +-- bacula/src/stored/stored_conf.c | 1 - bacula/src/version.h | 4 +- 12 files changed, 209 insertions(+), 408 deletions(-) diff --git a/bacula/.cvsignore b/bacula/.cvsignore index 2856eb45bc..c24ed44804 100644 --- a/bacula/.cvsignore +++ b/bacula/.cvsignore @@ -1,5 +1,6 @@ 1 2 +text set-gnome2 set-gnome1.4 kerns-gprof-config diff --git a/bacula/kernstodo b/bacula/kernstodo index b3c6033169..09b22fd96c 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ - Kern's ToDo List - 06 Septermber 2004 + Kern's ToDo List + 07 Septermber 2004 Major development: Project Developer @@ -11,61 +11,15 @@ Version 1.35 Kern (see below) ======================================================== 1.35 Items to do for release: -- Fix silly restriction requiring Include { Options { xxx } } to be - on separate lines. -- Improve error message if old/new FileSet syntax mixed. - Restore c: with a prefix into /prefix/c/ to prevent c: and d: files with the same name from overwritting each other. - Add new DCR calling sequences everywhere in SD. This will permit simultaneous use of multiple devices by a single job. - - Document a get out of jail procedure if everything breaks if you lost/broke the Catalog -- do the same for "I know my file is there how do I get it back?". -- New IP address specification is used as follows: - [sdaddresses|diraddresses|fdaddresses] = { [[ip|ipv4|ipv6] = { - [[addr|port] = [^ ]+[\n;]+] }] } - - so it could look for example like this: - SDaddresses = { ip = { - addr = 1.2.3.4; port = 1205; } - ipv4 = { - addr = 1.2.3.4; port = http; } - ipv6 = { - addr = 1.2.3.4; - port = 1205; - } - ip = { - addr = 1.2.3.4 - port = 1205 - } - ip = { - addr = 1.2.3.4 - } - ip = { - addr = 201:220:222::2 - } - ip = { - addr = bluedot.thun.net - } - } - as a consequence, you can now specify multiple IP addresses and - ports to be used. In the case of a server, it will listen on - all those that you specify. In the case of connecting to the server, - Bacula will attempt connecting to one at a time until it succeeds. - And, in a few other special cases, Bacula will use only the first - address specified. - - The default port numbers are still the same and the services and hosts - are also resolved by name. So now you could use the real names for the - port numbers. - - An ip section will allow resolution to either an ipv4 or an ipv6 address. - An ipv4 section forces the resolution to be only ipv4, and an ipv6 section - forces the resolution to be only ipv6. - Maybe for 1.35: - Look at patches/bacula_db.b2z postgresql that loops during restore. @@ -74,7 +28,7 @@ Maybe for 1.35: - Add bscan to four-concurrent-jobs regression. - Add IPv6 to regression - Perhaps add read/write programs and/or plugins to FileSets. - +- How to handle backing up portables ... Documentation to do: (any release a little bit at a time) - Alternative to static linking "ldd prog" save all binaries listed, @@ -1405,4 +1359,48 @@ Block Position: 0 - Document that console commands can be abbreviated. - Doc update AllFromVol - Doc -p option in stored +- New IP address specification is used as follows: + [sdaddresses|diraddresses|fdaddresses] = { [[ip|ipv4|ipv6] = { + [[addr|port] = [^ ]+[\n;]+] }] } + + so it could look for example like this: + SDaddresses = { ip = { + addr = 1.2.3.4; port = 1205; } + ipv4 = { + addr = 1.2.3.4; port = http; } + ipv6 = { + addr = 1.2.3.4; + port = 1205; + } + ip = { + addr = 1.2.3.4 + port = 1205 + } + ip = { + addr = 1.2.3.4 + } + ip = { + addr = 201:220:222::2 + } + ip = { + addr = bluedot.thun.net + } + } + as a consequence, you can now specify multiple IP addresses and + ports to be used. In the case of a server, it will listen on + all those that you specify. In the case of connecting to the server, + Bacula will attempt connecting to one at a time until it succeeds. + And, in a few other special cases, Bacula will use only the first + address specified. + + The default port numbers are still the same and the services and hosts + are also resolved by name. So now you could use the real names for the + port numbers. + + An ip section will allow resolution to either an ipv4 or an ipv6 address. + An ipv4 section forces the resolution to be only ipv4, and an ipv6 section + forces the resolution to be only ipv6. +- Fix silly restriction requiring Include { Options { xxx } } to be + on separate lines. + diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index 74a1e4039b..dc47ba6924 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -128,7 +128,8 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) } if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("No Job record found: ERR=%s\n"), sql_strerror(mdb)); + Mmsg2(&mdb->errmsg, _("No Job record found: ERR=%s\nCMD=%s\n"), + sql_strerror(mdb), mdb->cmd); sql_free_result(mdb); db_unlock(mdb); return 0; diff --git a/bacula/src/console/console_conf.c b/bacula/src/console/console_conf.c index 4a377dfa66..83d0f22791 100644 --- a/bacula/src/console/console_conf.c +++ b/bacula/src/console/console_conf.c @@ -122,16 +122,16 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm recurse = false; } switch (type) { - case R_CONSOLE: - printf("Console: name=%s rcfile=%s histfile=%s\n", reshdr->name, - res->res_cons.rc_file, res->res_cons.hist_file); - break; - case R_DIRECTOR: - printf("Director: name=%s address=%s DIRport=%d\n", reshdr->name, - res->res_dir.address, res->res_dir.DIRport); - break; - default: - printf("Unknown resource type %d\n", type); + case R_CONSOLE: + printf("Console: name=%s rcfile=%s histfile=%s\n", reshdr->name, + res->res_cons.rc_file, res->res_cons.hist_file); + break; + case R_DIRECTOR: + printf("Director: name=%s address=%s DIRport=%d\n", reshdr->name, + res->res_dir.address, res->res_dir.DIRport); + break; + default: + printf("Unknown resource type %d\n", type); } if (recurse && res->res_dir.hdr.next) { dump_resource(type, res->res_dir.hdr.next, sendit, sock); @@ -163,19 +163,19 @@ void free_resource(RES *sres, int type) } switch (type) { - case R_CONSOLE: - if (res->res_cons.rc_file) { - free(res->res_cons.rc_file); - } - if (res->res_cons.hist_file) { - free(res->res_cons.hist_file); - } - case R_DIRECTOR: - if (res->res_dir.address) - free(res->res_dir.address); - break; - default: - printf("Unknown resource type %d\n", type); + case R_CONSOLE: + if (res->res_cons.rc_file) { + free(res->res_cons.rc_file); + } + if (res->res_cons.hist_file) { + free(res->res_cons.hist_file); + } + case R_DIRECTOR: + if (res->res_dir.address) + free(res->res_dir.address); + break; + default: + printf("Unknown resource type %d\n", type); } /* Common stuff again -- free the resource, recurse to next one */ free(res); @@ -240,17 +240,17 @@ void save_resource(int type, RES_ITEM *items, int pass) /* The following code is only executed during pass 1 */ switch (type) { - case R_CONSOLE: - size = sizeof(CONRES); - break; - case R_DIRECTOR: - size = sizeof(DIRRES); - break; - default: - printf("Unknown resource type %d\n", type); - error = 1; - size = 1; - break; + case R_CONSOLE: + size = sizeof(CONRES); + break; + case R_DIRECTOR: + size = sizeof(DIRRES); + break; + default: + printf("Unknown resource type %d\n", type); + error = 1; + size = 1; + break; } /* Common */ if (!error) { diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 148f9ff54a..09d6c0924b 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -1223,202 +1223,3 @@ void store_acl(LEX *lc, RES_ITEM *item, int index, int pass) set_bit(index, res_all.hdr.item_present); } - -#ifdef old_deprecated_code -/* - * Store backup/verify info for Job record - * - * Note, this code is used for both BACKUP and VERIFY jobs - * - * Backup = Client= FileSet= Level= - */ -static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass) -{ - int token, i; - RES *res; - int options = lc->options; - - lc->options |= LOPT_NO_IDENT; /* make spaces significant */ - - - ((JOB *)(item->value))->JobType = item->code; - while ((token = lex_get_token(lc, T_ALL)) != T_EOL) { - bool found = false; - - Dmsg1(900, "store_backup got token=%s\n", lex_tok_to_str(token)); - - if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) { - scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str); - } - Dmsg1(900, "Got keyword: %s\n", lc->str); - for (i=0; BakVerFields[i].name; i++) { - if (strcasecmp(lc->str, BakVerFields[i].name) == 0) { - found = true; - if (lex_get_token(lc, T_ALL) != T_EQUALS) { - scan_err1(lc, "Expected an equals, got: %s", lc->str); - } - token = lex_get_token(lc, T_NAME); - Dmsg1(900, "Got value: %s\n", lc->str); - switch (BakVerFields[i].token) { - case 'C': - /* Find Client Resource */ - if (pass == 2) { - res = GetResWithName(R_CLIENT, lc->str); - if (res == NULL) { - scan_err1(lc, "Could not find specified Client Resource: %s", - lc->str); - } - res_all.res_job.client = (CLIENT *)res; - } - break; - case 'F': - /* Find FileSet Resource */ - if (pass == 2) { - res = GetResWithName(R_FILESET, lc->str); - if (res == NULL) { - scan_err1(lc, "Could not find specified FileSet Resource: %s\n", - lc->str); - } - res_all.res_job.fileset = (FILESET *)res; - } - break; - case 'L': - /* Get level */ - for (i=0; joblevels[i].level_name; i++) { - if (joblevels[i].job_type == item->code && - strcasecmp(lc->str, joblevels[i].level_name) == 0) { - ((JOB *)(item->value))->level = joblevels[i].level; - i = 0; - break; - } - } - if (i != 0) { - scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str); - } - break; - } /* end switch */ - break; - } /* end if strcmp() */ - } /* end for */ - if (!found) { - scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str); - } - } /* end while */ - lc->options = options; /* reset original options */ - set_bit(index, res_all.hdr.item_present); -} - -/* - * Store restore info for Job record - * - * Restore = JobId= Where= Replace= Bootstrap= - * - */ -static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass) -{ - int token, i; - RES *res; - int options = lc->options; - - lc->options |= LOPT_NO_IDENT; /* make spaces significant */ - - Dmsg0(900, "Enter store_restore()\n"); - - ((JOB *)(item->value))->JobType = item->code; - while ((token = lex_get_token(lc, T_ALL)) != T_EOL) { - bool found = false; - - if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) { - scan_err1(lc, "expected a name, got: %s", lc->str); - } - for (i=0; RestoreFields[i].name; i++) { - Dmsg1(900, "Restore kw=%s\n", lc->str); - if (strcasecmp(lc->str, RestoreFields[i].name) == 0) { - found = true; - if (lex_get_token(lc, T_ALL) != T_EQUALS) { - scan_err1(lc, "Expected an equals, got: %s", lc->str); - } - token = lex_get_token(lc, T_ALL); - Dmsg1(900, "Restore value=%s\n", lc->str); - switch (RestoreFields[i].token) { - case 'B': - /* Bootstrap */ - if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) { - scan_err1(lc, "Expected a Restore bootstrap file, got: %s", lc->str); - } - if (pass == 1) { - res_all.res_job.RestoreBootstrap = bstrdup(lc->str); - } - break; - case 'C': - /* Find Client Resource */ - if (pass == 2) { - res = GetResWithName(R_CLIENT, lc->str); - if (res == NULL) { - scan_err1(lc, "Could not find specified Client Resource: %s", - lc->str); - } - res_all.res_job.client = (CLIENT *)res; - } - break; - case 'F': - /* Find FileSet Resource */ - if (pass == 2) { - res = GetResWithName(R_FILESET, lc->str); - if (res == NULL) { - scan_err1(lc, "Could not find specified FileSet Resource: %s\n", - lc->str); - } - res_all.res_job.fileset = (FILESET *)res; - } - break; - case 'J': - /* JobId */ - if (token != T_NUMBER) { - scan_err1(lc, "expected an integer number, got: %s", lc->str); - } - errno = 0; - res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0); - Dmsg1(900, "RestorJobId=%d\n", res_all.res_job.RestoreJobId); - if (errno != 0) { - scan_err1(lc, "expected an integer number, got: %s", lc->str); - } - break; - case 'W': - /* Where */ - if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) { - scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str); - } - if (pass == 1) { - res_all.res_job.RestoreWhere = bstrdup(lc->str); - } - break; - case 'R': - /* Replacement options */ - if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) { - scan_err1(lc, "Expected a keyword name, got: %s", lc->str); - } - /* Fix to scan Replacement options */ - for (i=0; ReplaceOptions[i].name; i++) { - if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) { - ((JOB *)(item->value))->replace = ReplaceOptions[i].token; - i = 0; - break; - } - } - if (i != 0) { - scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str); - } - break; - } /* end switch */ - break; - } /* end if strcmp() */ - } /* end for */ - if (!found) { - scan_err1(lc, "%s not a valid Restore keyword", lc->str); - } - } /* end while */ - lc->options = options; /* reset original options */ - set_bit(index, res_all.hdr.item_present); -} -#endif diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index 815b824832..c3a01f4ef3 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -243,6 +243,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) /* * * Store FileSet Include/Exclude info + * NEW style includes are handled in store_newinc() */ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) { @@ -257,11 +258,14 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) * new Include is followed immediately by open brace, whereas the * old include has options following the Include. */ - token = lex_get_token(lc, T_ALL); + token = lex_get_token(lc, T_SKIP_EOL); if (token == T_BOB) { store_newinc(lc, item, index, pass); return; } + + /* What follows is scanning for the OLD style Include/Exclude */ + if (token != T_EQUALS) { scan_err1(lc, _("Expecting an equals sign, got: %s\n"), lc->str); } @@ -270,7 +274,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) /* Get include options */ inc_opts[0] = 0; - while ((token=lex_get_token(lc, T_ALL)) != T_BOB) { + while ((token=lex_get_token(lc, T_SKIP_EOL)) != T_BOB) { keyword = INC_KW_NONE; for (i=0; FS_option_kw[i].name; i++) { @@ -283,7 +287,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) scan_err1(lc, _("Expected a FileSet keyword, got: %s"), lc->str); } /* Option keyword should be following by =