- if (acl_access_ok(ua, Client_ACL, cr.Name)) {
- client = (CLIENT *)GetResWithName(R_CLIENT, cr.Name);
- if (client) {
- jcr->client = client;
- } else {
- Jmsg1(jcr, M_FATAL, 0, _("Client resource \"%s\" does not exist.\n"), cr.Name);
- goto bail_out;
- }
+ if (!open_client_db(ua)) {
+ goto bail_out;
+ }
+
+ if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
+ ua->error_msg(_("Job %ld/%s not found in database.\n"), jr.JobId, jr.Job);
+ goto bail_out;
+ }
+
+ if (!acl_access_ok(ua, Job_ACL, jr.Name)) {
+ ua->error_msg(_("Job %s is not accessible from this console\n"), jr.Name);
+ goto bail_out;
+ }
+
+ cr.ClientId = jr.ClientId;
+ if (!cr.ClientId || !db_get_client_record(ua->jcr, ua->db, &cr)) {
+ ua->error_msg(_("Client %ld not found in database.\n"), jr.ClientId);
+ goto bail_out;
+ }
+
+ if (acl_access_client_ok(ua, cr.Name, jr.JobType)) {
+ client = (CLIENT *)GetResWithName(R_CLIENT, cr.Name);
+ if (client) {
+ jcr->client = client;