From: <gi...@ba...> - 2014-05-23 11:42:00
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Bacula Community source". The branch, Branch-7.0 has been updated via fdba62e5732c55a45e8648b36b0b6fa37093d604 (commit) via 68b3b64ba03ec741db05f5ad200e7c0faf91ff3d (commit) via 828e9e4debe7e335578a0406640dbeb3e899d908 (commit) via b8909c975353de1965988e39fa212886a60d66d6 (commit) via 887d35f081ea5ebadc7a645f8f20fa85b7f44b88 (commit) via 56cc796dc504ad5d14fad6a55908c9a5ad5f3bad (commit) from ee829cd48fa11cdbe0f9426d12b85d9d39e9b0a6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fdba62e5732c55a45e8648b36b0b6fa37093d604 Author: Kern Sibbald <ke...@si...> Date: Thu May 22 17:21:00 2014 +0200 Update version+date commit 68b3b64ba03ec741db05f5ad200e7c0faf91ff3d Author: Eric Bollengier <er...@ba...> Date: Thu May 22 17:17:52 2014 +0200 Fix copy/migration to second SD commit 828e9e4debe7e335578a0406640dbeb3e899d908 Author: Kern Sibbald <ke...@si...> Date: Mon May 19 19:39:27 2014 +0200 Fix calls to sl.set_string() commit b8909c975353de1965988e39fa212886a60d66d6 Author: Kern Sibbald <ke...@si...> Date: Mon May 19 19:37:49 2014 +0200 Improve sellist code commit 887d35f081ea5ebadc7a645f8f20fa85b7f44b88 Author: Kern Sibbald <ke...@si...> Date: Sun May 11 12:34:12 2014 +0200 Tweak update ChangeLog+ReleaseNotes commit 56cc796dc504ad5d14fad6a55908c9a5ad5f3bad Author: Kern Sibbald <ke...@si...> Date: Sun May 11 12:32:44 2014 +0200 Fix error handling in do_alist_prompt ----------------------------------------------------------------------- Summary of changes: diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 8ee753f..1aacbe1 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -1,7 +1,8 @@ Changelog on version 7.0.3 Release version 7.0.3 -11May14 +12May14 + - Fix error handling in do_alist_prompt - Tighten error condition handling in sellist - Add new cancel test diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index 43e61c8..ea6bf19 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -6,6 +6,7 @@ This is a bug fix release to version 7.0.2. We recommend that everyone using version 7.0.2 upgrade to this version. 12May14 + - Fix error handling in do_alist_prompt - Tighten error condition handling in sellist - Add new cancel test - Update LICENSE and LICENSE-FAQ diff --git a/bacula/src/dird/mac.c b/bacula/src/dird/mac.c index da25e0a..49de6df 100644 --- a/bacula/src/dird/mac.c +++ b/bacula/src/dird/mac.c @@ -472,10 +472,6 @@ bool do_mac(JCR *jcr) wjcr->jr.Name, (int)wjcr->jr.JobId, wjcr->jr.JobType, wjcr->jr.JobLevel); - store = wjcr->wstore; - if (store->SDDport == 0) { - store->SDDport = store->SDport; - } if (jcr->sd_calls_client) { /* @@ -486,6 +482,11 @@ bool do_mac(JCR *jcr) goto bail_out; } + /* Setup the storage address and port */ + store = wjcr->wstore; + if (store->SDDport == 0) { + store->SDDport = store->SDport; + } store_address = store->address; /* note: store points to wstore */ Dmsg2(200, "Start write message thread jid=%d Job=%s\n", wjcr->JobId, wjcr->Job); @@ -518,6 +519,10 @@ bool do_mac(JCR *jcr) * * Send Storage daemon address to the writing SD */ + store = jcr->rstore; + if (store->SDDport == 0) { + store->SDDport = store->SDport; + } store_address = get_storage_address(jcr->client, store); store_port = store->SDDport; diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index f77fef7..f13f090 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1454,7 +1454,7 @@ static void delete_job(UAContext *ua) i = find_arg_with_value(ua, NT_("jobid")); if (i >= 0) { - if (sl.set_string(ua->argv[i], true) < 0 && sl.get_errmsg()) { + if (!sl.set_string(ua->argv[i], true)) { ua->warning_msg("%s", sl.get_errmsg()); return; } diff --git a/bacula/src/dird/ua_input.c b/bacula/src/dird/ua_input.c index d8dd4af..421a9e6 100644 --- a/bacula/src/dird/ua_input.c +++ b/bacula/src/dird/ua_input.c @@ -86,7 +86,7 @@ bool get_selection_list(UAContext *ua, sellist &sl, if (!get_cmd(ua, prompt, subprompt)) { return false; } - if (sl.set_string(ua->cmd, true) < 0 && sl.get_errmsg()) { + if (!sl.set_string(ua->cmd, true)) { ua->send_msg("%s", sl.get_errmsg()); continue; } diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 45a9258..4a31ac6 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -419,7 +419,7 @@ static bool get_jobid_list(UAContext *ua, sellist &sl, run_ctx &rc) ua->send_msg(_("No JobId specified.\n")); return false; } - if (sl.set_string(ua->argv[i], true) < 0 && sl.get_errmsg()) { + if (!sl.set_string(ua->argv[i], true)) { ua->send_msg("%s", sl.get_errmsg()); return false; } diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 5f8bc33..68904ab 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -951,6 +951,7 @@ int do_alist_prompt(UAContext *ua, const char *automsg, const char *msg, sprintf(pmsg, "%s (1-%d): ", msg, ua->num_prompts-1); for ( ;; ) { + bool ok = true; /* Either a . or an @ will get you out of the loop */ if (ua->api) user->signal(BNET_SELECT_INPUT); @@ -967,13 +968,16 @@ int do_alist_prompt(UAContext *ua, const char *automsg, const char *msg, while ( (item = sl.next()) > 0) { if (item < 1 || item >= ua->num_prompts) { ua->warning_msg(_("Please enter a number between 1 and %d\n"), ua->num_prompts-1); - continue; + ok = false; + break; } selected->append(bstrdup(ua->prompt[item])); } } - item = selected->size(); - break; + if (ok) { + item = selected->size(); + break; + } } done: @@ -1237,7 +1241,7 @@ int select_running_jobs(UAContext *ua, alist *jcrs, const char *reason) sellist sl; int32_t JobId; - if (sl.set_string(ua->argv[i], true) < 0 && sl.get_errmsg()) { + if (!sl.set_string(ua->argv[i], true)) { ua->send_msg("%s", sl.get_errmsg()); break; } diff --git a/bacula/src/lib/sellist.c b/bacula/src/lib/sellist.c index fc627f2..e3e2589 100644 --- a/bacula/src/lib/sellist.c +++ b/bacula/src/lib/sellist.c @@ -32,6 +32,7 @@ int64_t sellist::next() { errmsg = NULL; if (beg <= end) { /* scan done? */ + //printf("Return %lld\n", beg); return beg++; } if (e == NULL) { @@ -45,7 +46,7 @@ int64_t sellist::next() for (p=e; p && *p; p=e) { esave = hsave = 0; /* Check for list */ - e = strchr(p, ','); + e = strpbrk(p, ", "); if (e) { /* have list */ esave = *e; *e++ = 0; @@ -70,7 +71,8 @@ int64_t sellist::next() } beg = str_to_int64(p); end = str_to_int64(h); - if (end < beg) { + //printf("beg=%lld end=%lld\n", beg, end); + if (end <= beg) { errmsg = _("Range end not bigger than start.\n"); goto bail_out; } @@ -85,6 +87,7 @@ int64_t sellist::next() if (strncasecmp(p, "all", 3) == 0) { all = true; errmsg = NULL; + //printf("Return 0 i.e. all\n"); return 0; } if (!is_an_integer(p)) { @@ -104,15 +107,22 @@ int64_t sellist::next() goto bail_out; } if (beg <= end) { + //printf("Return %lld\n", beg); return beg++; } } + //printf("Rtn=-1. End of items\n"); /* End of items */ begin(); e = NULL; return -1; /* No error */ bail_out: + if (errmsg) { + //printf("Bail out rtn=-1. p=%c err=%s\n", *p, errmsg); + } else { + //printf("Rtn=-1. End of items\n"); + } e = NULL; return -1; /* Error, errmsg set */ } @@ -123,9 +133,9 @@ bail_out: * returns false on error in string * returns true if OK */ -bool sellist::set_string(char *string, bool scan=true) +bool sellist::set_string(const char *string, bool scan=true) { - bool OK = true; + bool ok = true; /* * Copy string, because we write into it, * then scan through it once to find any @@ -138,24 +148,27 @@ bool sellist::set_string(char *string, bool scan=true) if (str) { free(str); } - e = str = bstrdup(string); - end = 0; - beg = 1; + str = bstrdup(string); + begin(); num_items = 0; - errmsg = NULL; if (scan) { while (next() >= 0) { num_items++; } - OK = !get_errmsg(); - e = str; - end = 0; - beg = 1; + ok = get_errmsg() == NULL; } - return OK; + if (ok) { + begin(); + } else { + e = NULL; + } + return ok; } -/* Get the expanded list of all ids, very useful for SQL queries */ +/* + * Get the expanded list of values separated by commas, + * useful for SQL queries + */ char *sellist::get_expanded_list() { int32_t expandedsize = 512; @@ -197,50 +210,60 @@ char *sellist::get_expanded_list() } #ifdef TEST_PROGRAM + +const char *sin[] = { + "1,70", + "1", + "256", + "1-5", + "1-5,7", + "1 10 20 30", + "1-5,7,20 21", + "all", + "12a", /* error */ + "12-11", /* error */ + "12-13a", /* error */ + "a123", /* error */ + NULL +}; + +const char *sout[] = { + "1,70", + "1", + "256", + "1,2,3,4,5", + "1,2,3,4,5,7", + "1,10,20,30", + "1,2,3,4,5,7,20,21", + "0", + "ERROR", + "ERROR", + "ERROR", + "ERROR", + NULL +}; + int main(int argc, char **argv, char **env) { const char *msg; sellist sl; - int i; - - if (!argv[1]) { - msg = _("No input string given.\n"); - goto bail_out; - } - Dmsg1(000, "argv[1]=%s\n", argv[1]); + int x; - strip_trailing_junk(argv[1]); - sl.set_string(argv[1]); - - //Dmsg1(000, "get_list=%s\n", sl.get_list()); - - /* If the list is very long, Dmsg will truncate it */ - Dmsg1(000, "get_expanded_list=%s\n", NPRT(sl.get_expanded_list())); - - if ((msg = sl.get_errmsg())) { - goto bail_out; - } - while ((i=sl.next()) > 0) { - Dmsg1(000, "rtn=%d\n", i); - } - if ((msg = sl.get_errmsg())) { - goto bail_out; - } - printf("\nPass 2 argv[1]=%s\n", argv[1]); - sl.set_string(argv[1]); - while ((i=sl.next()) > 0) { - Dmsg1(000, "rtn=%d\n", i); - } - msg = sl.get_errmsg(); - Dmsg2(000, "rtn=%d msg=%s\n", i, NPRT(msg)); - if (msg) { - goto bail_out; + for (x=0; sin[x] != NULL; x++) { + if (!sl.set_string(sin[x], true)) { + printf("ERR: input: %s ERR=%s", sin[x], sl.get_errmsg()); + continue; + } + msg = sl.get_expanded_list(); + if (sl.get_errmsg() == NULL && strcmp(msg, sout[x]) == 0) { + printf("OK: input: %s output: %s\n", sin[x], msg); + } else { + printf("ERR: input: %s gave output: %s ERR=%s\n", sin[x], msg, + sl.get_errmsg()); + } } + printf("\n"); return 0; -bail_out: - Dmsg1(000, "Error: %s\n", NPRT(msg)); - return 1; - } #endif /* TEST_PROGRAM */ diff --git a/bacula/src/lib/sellist.h b/bacula/src/lib/sellist.h index c9716a0..18389e9 100644 --- a/bacula/src/lib/sellist.h +++ b/bacula/src/lib/sellist.h @@ -43,7 +43,7 @@ class sellist : public SMARTALLOC { public: sellist(); ~sellist(); - bool set_string(char *string, bool scan); + bool set_string(const char *string, bool scan); bool is_all() { return all; }; int64_t first(); int64_t next(); diff --git a/bacula/src/version.h b/bacula/src/version.h index f400658..f0cb73e 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ #undef VERSION -#define VERSION "7.0.3" -#define BDATE "12 May 2014" -#define LSMDATE "12May14" +#define VERSION "7.0.4" +#define BDATE "22 May 2014" +#define LSMDATE "22May14" #define PROG_COPYRIGHT "Copyright (C) %d-2014 Free Software Foundation Europe e.V.\n" #define BYEAR "2014" /* year for copyright messages in progs */ hooks/post-receive -- Bacula Community source |