The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
- modify it under the terms of version two of the GNU General Public
+ modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*
* Kern Sibbald, October MMI
*
- * Version $Id$
*/
#include "bacula.h"
return job;
}
+/*
+ * Select a Restore Job resource from argument or prompt
+ */
+JOB *get_restore_job(UAContext *ua)
+{
+ JOB *job;
+ int i = find_arg_with_value(ua, "restore_job");
+ if (i >= 0 && acl_access_ok(ua, Job_ACL, ua->argv[i])) {
+ job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ if (job && job->JobType == JT_RESTORE) {
+ return job;
+ }
+ ua->error_msg(_("Error: Restore Job resource \"%s\" does not exist.\n"),
+ ua->argv[i]);
+ }
+ return select_restore_job_resource(ua);
+}
+
/*
* Select a Restore Job resource from prompt list
*/
int select_media_dbr(UAContext *ua, MEDIA_DBR *mr)
{
int i;
+ int ret = 0;
+ POOLMEM *err = get_pool_memory(PM_FNAME);
+ *err=0;
memset(mr, 0, sizeof(MEDIA_DBR));
i = find_arg_with_value(ua, "volume");
if (i >= 0) {
- bstrncpy(mr->VolumeName, ua->argv[i], sizeof(mr->VolumeName));
+ if (is_name_valid(ua->argv[i], &err)) {
+ bstrncpy(mr->VolumeName, ua->argv[i], sizeof(mr->VolumeName));
+ } else {
+ goto bail_out;
+ }
}
if (mr->VolumeName[0] == 0) {
POOL_DBR pr;
memset(&pr, 0, sizeof(pr));
/* Get the pool from pool=<pool-name> */
if (!get_pool_dbr(ua, &pr)) {
- return 0;
+ goto bail_out;
}
mr->PoolId = pr.PoolId;
db_list_media_records(ua->jcr, ua->db, mr, prtit, ua, HORZ_LIST);
if (!get_cmd(ua, _("Enter *MediaId or Volume name: "))) {
- return 0;
+ goto bail_out;
}
if (ua->cmd[0] == '*' && is_a_number(ua->cmd+1)) {
mr->MediaId = str_to_int64(ua->cmd+1);
- } else {
+ } else if (is_name_valid(ua->cmd, &err)) {
bstrncpy(mr->VolumeName, ua->cmd, sizeof(mr->VolumeName));
+ } else {
+ goto bail_out;
}
}
if (!db_get_media_record(ua->jcr, ua->db, mr)) {
- ua->error_msg("%s", db_strerror(ua->db));
- return 0;
+ pm_strcpy(err, db_strerror(ua->db));
+ goto bail_out;
}
- return 1;
+ ret = 1;
+
+bail_out:
+ if (!ret && *err) {
+ ua->error_msg("%s", err);
+ }
+ free_pool_memory(err);
+ return ret;
}
bool found = false;
for (int i=0; joblevels[i].level_name; i++) {
if (strcasecmp(level_name, joblevels[i].level_name) == 0) {
- jcr->set_JobLevel(joblevels[i].level);
+ jcr->setJobLevel(joblevels[i].level);
found = true;
break;
}