From: Eric Bollengier Date: Fri, 17 Mar 2023 15:00:21 +0000 (+0100) Subject: Adapt delete command to work with restricted consoles X-Git-Tag: Release-13.0.3~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=550a5b1db08a774d53f13a33efbda7f2343b199c;p=thirdparty%2Fbacula.git Adapt delete command to work with restricted consoles --- diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 7c105ed7f..6feffd20e 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -2146,6 +2146,7 @@ static void delete_job(UAContext *ua) int JobId; /* not JobId_t because it's unsigned and not compatible with sellist */ char buf[256]; sellist sl; + POOL_MEM lst; int i = find_arg_with_value(ua, NT_("jobid")); if (i >= 0) { @@ -2162,6 +2163,9 @@ static void delete_job(UAContext *ua) } } + db_get_jobids(ua->jcr, ua->db, sl.get_expanded_list(), lst.handle(), false); + sl.set_string(lst.c_str(), true); + foreach_sellist(JobId, &sl) { do_job_delete(ua, JobId); } @@ -2170,8 +2174,9 @@ static void delete_job(UAContext *ua) return; } else { - JobId = ua->int64_val; - do_job_delete(ua, JobId); + db_get_jobids(ua->jcr, ua->db, edit_uint64(ua->int64_val, buf), lst.handle(), false); + JobId = str_to_uint64(lst.c_str()); + do_job_delete(ua, JobId); /* JobId is safe */ } } @@ -2184,6 +2189,11 @@ static void do_job_delete(UAContext *ua, JobId_t JobId) edit_int64(JobId, ed1); bool skip_job = false; + if (!JobId) { + ua->send_msg(_("Invalid JobId, Job may not exist or be accessible\n")); + return; + } + JCR *jcr; foreach_jcr(jcr) { if (jcr->JobId == JobId) { @@ -2196,7 +2206,7 @@ static void do_job_delete(UAContext *ua, JobId_t JobId) if (skip_job) { ua->send_msg(_("Skipping JobId=%s, job is still running!\n"), ed1); } else { - purge_jobs_from_catalog(ua, ed1); + purge_jobs_from_catalog(ua, ed1); /* JobId is safe */ ua->send_msg(_("JobId=%s and associated records deleted from the catalog.\n"), ed1); } }