X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Fua_cmds.c;h=6952b3b9bdf41f5a5555ee93d58906a20014a68c;hb=6e637fce30a1fdbc2da43552f513f529db4d4e87;hp=98481052e4ea72ef3acd2caef6fc03e78085d37d;hpb=dca40049701012f57ee10d2aab330a2240e7c471;p=bacula%2Fbacula diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 98481052e4..6952b3b9bd 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -40,9 +40,6 @@ /* Imported subroutines */ /* Imported variables */ -extern int r_first; -extern int r_last; -extern struct s_res resources[]; extern jobq_t job_queue; /* job queue */ @@ -149,19 +146,18 @@ static struct cmdstruct commands[] = { /* * Execute a command from the UA */ -int do_a_command(UAContext *ua, const char *cmd) +bool do_a_command(UAContext *ua) { unsigned int i; - int len, stat; + int len; bool ok = false; bool found = false; BSOCK *user = ua->UA_sock; - stat = 1; Dmsg1(900, "Command: %s\n", ua->UA_sock->msg); if (ua->argc == 0) { - return 1; + return false; } while (ua->jcr->wstorage->size()) { @@ -177,13 +173,14 @@ int do_a_command(UAContext *ua, const char *cmd) break; } if (ua->api) user->signal(BNET_CMD_BEGIN); - ok = (*commands[i].func)(ua, cmd); /* go execute command */ + ok = (*commands[i].func)(ua, ua->cmd); /* go execute command */ found = true; break; } } if (!found) { - user->fsend(_("%s: is an invalid command.\n"), ua->argk[0]); + ua->error_msg(_("%s: is an invalid command.\n"), ua->argk[0]); + ok = false; } if (ua->api) user->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED); return ok; @@ -1082,13 +1079,21 @@ static int estimate_cmd(UAContext *ua, const char *cmd) strcasecmp(ua->argk[i], NT_("fd")) == 0) { if (ua->argv[i]) { client = GetClientResWithName(ua->argv[i]); + if (!client) { + ua->error_msg(_("Client \"%s\" not found.\n"), ua->argv[i]); + return 1; + } continue; } } if (strcasecmp(ua->argk[i], NT_("job")) == 0) { if (ua->argv[i]) { job = GetJobResWithName(ua->argv[i]); - if (job && !acl_access_ok(ua, Job_ACL, job->name())) { + if (!job) { + ua->error_msg(_("Job \"%s\" not found.\n"), ua->argv[i]); + return 1; + } + if (!acl_access_ok(ua, Job_ACL, job->name())) { ua->error_msg(_("No authorization for Job \"%s\"\n"), job->name()); return 1; } @@ -1098,7 +1103,11 @@ static int estimate_cmd(UAContext *ua, const char *cmd) if (strcasecmp(ua->argk[i], NT_("fileset")) == 0) { if (ua->argv[i]) { fileset = GetFileSetResWithName(ua->argv[i]); - if (fileset && !acl_access_ok(ua, FileSet_ACL, fileset->name())) { + if (!fileset) { + ua->error_msg(_("Fileset \"%s\" not found.\n"), ua->argv[i]); + return 1; + } + if (!acl_access_ok(ua, FileSet_ACL, fileset->name())) { ua->error_msg(_("No authorization for FileSet \"%s\"\n"), fileset->name()); return 1; } @@ -1141,7 +1150,11 @@ static int estimate_cmd(UAContext *ua, const char *cmd) jcr->client = client; jcr->fileset = fileset; close_db(ua); - ua->catalog = client->catalog; + if (job->pool->catalog) { + ua->catalog = job->pool->catalog; + } else { + ua->catalog = client->catalog; + } if (!open_db(ua)) { return 1; @@ -1161,7 +1174,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd) get_level_since_time(ua->jcr, since, sizeof(since)); ua->send_msg(_("Connecting to Client %s at %s:%d\n"), - job->client->name(), job->client->address, job->client->FDport); + jcr->client->name(), jcr->client->address, jcr->client->FDport); if (!connect_to_file_daemon(jcr, 1, 15, 0)) { ua->error_msg(_("Failed to connect to Client.\n")); return 1; @@ -1554,7 +1567,8 @@ int wait_cmd(UAContext *ua, const char *cmd) { JCR *jcr; - /* no args + /* + * no args * Wait until no job is running */ if (ua->argc == 1) { @@ -1622,7 +1636,7 @@ int wait_cmd(UAContext *ua, const char *cmd) } /* - * We wait the end of job + * We wait the end of a specific job */ bmicrosleep(0, 200000); /* let job actually start */ @@ -1837,7 +1851,8 @@ bool open_db(UAContext *ua) ua->jcr->catalog = ua->catalog; Dmsg0(100, "UA Open database\n"); - ua->db = db_init_database(ua->jcr, ua->catalog->db_name, ua->catalog->db_user, + ua->db = db_init(ua->jcr, ua->catalog->db_driver, ua->catalog->db_name, + ua->catalog->db_user, ua->catalog->db_password, ua->catalog->db_address, ua->catalog->db_port, ua->catalog->db_socket, ua->catalog->mult_db_connections);