+ rc.catalog_name = NULL;
+ rc.job_name = NULL;
+ rc.pool_name = NULL;
+ rc.store_name = NULL;
+ rc.client_name = NULL;
+ rc.restore_client_name = NULL;
+ rc.fileset_name = NULL;
+ rc.verify_job_name = NULL;
+ rc.previous_job_name = NULL;
+ rc.spool_data_set = 0;
+
+
+ for (i=1; i<ua->argc; i++) {
+ Dmsg2(800, "Doing arg %d = %s\n", i, ua->argk[i]);
+ kw_ok = false;
+ /* Keep looking until we find a good keyword */
+ for (j=0; !kw_ok && kw[j]; j++) {
+ if (strcasecmp(ua->argk[i], kw[j]) == 0) {
+ /* Note, yes and run have no value, so do not fail */
+ if (!ua->argv[i] && j != YES_POS /*yes*/) {
+ ua->send_msg(_("Value missing for keyword %s\n"), ua->argk[i]);
+ return false;
+ }
+ Dmsg1(800, "Got keyword=%s\n", NPRT(kw[j]));
+ switch (j) {
+ case 0: /* job */
+ if (rc.job_name) {
+ ua->send_msg(_("Job name specified twice.\n"));
+ return false;
+ }
+ rc.job_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 1: /* JobId */
+ if (rc.jid && !rc.mod) {
+ ua->send_msg(_("JobId specified twice.\n"));
+ return false;
+ }
+ rc.jid = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 2: /* client */
+ case 3: /* fd */
+ if (rc.client_name) {
+ ua->send_msg(_("Client specified twice.\n"));
+ return false;
+ }
+ rc.client_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 4: /* fileset */
+ if (rc.fileset_name) {
+ ua->send_msg(_("FileSet specified twice.\n"));
+ return false;
+ }
+ rc.fileset_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 5: /* level */
+ if (rc.level_name) {
+ ua->send_msg(_("Level specified twice.\n"));
+ return false;
+ }
+ rc.level_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 6: /* storage */
+ case 7: /* sd */
+ if (rc.store_name) {
+ ua->send_msg(_("Storage specified twice.\n"));
+ return false;
+ }
+ rc.store_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 8: /* regexwhere */
+ if ((rc.regexwhere || rc.where) && !rc.mod) {
+ ua->send_msg(_("RegexWhere or Where specified twice.\n"));
+ return false;
+ }
+ rc.regexwhere = ua->argv[i];
+ if (!acl_access_ok(ua, Where_ACL, rc.regexwhere)) {
+ ua->send_msg(_("No authorization for \"regexwhere\" specification.\n"));
+ return false;
+ }
+ kw_ok = true;
+ break;
+ case 9: /* where */
+ if ((rc.where || rc.regexwhere) && !rc.mod) {
+ ua->send_msg(_("Where or RegexWhere specified twice.\n"));
+ return false;
+ }
+ rc.where = ua->argv[i];
+ if (!acl_access_ok(ua, Where_ACL, rc.where)) {
+ ua->send_msg(_("No authoriztion for \"where\" specification.\n"));
+ return false;
+ }
+ kw_ok = true;
+ break;
+ case 10: /* bootstrap */
+ if (rc.bootstrap && !rc.mod) {
+ ua->send_msg(_("Bootstrap specified twice.\n"));
+ return false;
+ }
+ rc.bootstrap = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 11: /* replace */
+ if (rc.replace && !rc.mod) {
+ ua->send_msg(_("Replace specified twice.\n"));
+ return false;
+ }
+ rc.replace = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 12: /* When */
+ if (rc.when && !rc.mod) {
+ ua->send_msg(_("When specified twice.\n"));
+ return false;
+ }
+ rc.when = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 13: /* Priority */
+ if (rc.Priority && !rc.mod) {
+ ua->send_msg(_("Priority specified twice.\n"));
+ return false;
+ }
+ rc.Priority = atoi(ua->argv[i]);
+ if (rc.Priority <= 0) {
+ ua->send_msg(_("Priority must be positive nonzero setting it to 10.\n"));
+ rc.Priority = 10;
+ }
+ kw_ok = true;
+ break;
+ case 14: /* yes */
+ kw_ok = true;
+ break;
+ case 15: /* Verify Job */
+ if (rc.verify_job_name) {
+ ua->send_msg(_("Verify Job specified twice.\n"));
+ return false;
+ }
+ rc.verify_job_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 16: /* files */
+ rc.files = atoi(ua->argv[i]);
+ kw_ok = true;
+ break;
+
+ case 17: /* catalog */
+ rc.catalog_name = ua->argv[i];
+ kw_ok = true;
+ break;
+
+ case 18: /* since */
+ rc.since = ua->argv[i];
+ kw_ok = true;
+ break;
+
+ case 19: /* cloned */
+ rc. cloned = true;
+ kw_ok = true;
+ break;
+
+ case 20: /* write verify list output */
+ rc.verify_list = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 21: /* Migration Job */
+ if (rc.previous_job_name) {
+ ua->send_msg(_("Migration Job specified twice.\n"));
+ return false;
+ }
+ rc.previous_job_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 22: /* pool */
+ if (rc.pool_name) {
+ ua->send_msg(_("Pool specified twice.\n"));
+ return false;
+ }
+ rc.pool_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 23: /* backupclient */
+ if (rc.client_name) {
+ ua->send_msg(_("Client specified twice.\n"));
+ return 0;
+ }
+ rc.client_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 24: /* restoreclient */
+ if (rc.restore_client_name && !rc.mod) {
+ ua->send_msg(_("Restore Client specified twice.\n"));
+ return false;
+ }
+ rc.restore_client_name = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 25: /* pluginoptions */
+ ua->send_msg(_("Plugin Options not yet implemented.\n"));
+ return false;
+ if (rc.plugin_options) {
+ ua->send_msg(_("Plugin Options specified twice.\n"));
+ return false;
+ }
+ rc.plugin_options = ua->argv[i];
+ if (!acl_access_ok(ua, PluginOptions_ACL, rc.plugin_options)) {
+ ua->send_msg(_("No authoriztion for \"PluginOptions\" specification.\n"));
+ return false;
+ }
+ kw_ok = true;
+ break;
+ case 26: /* spooldata */
+ if (rc.spool_data_set) {
+ ua->send_msg(_("Spool flag specified twice.\n"));
+ return false;
+ }
+ if (is_yesno(ua->argv[i], &rc.spool_data)) {
+ rc.spool_data_set = 1;
+ kw_ok = true;
+ } else {
+ ua->send_msg(_("Invalid spooldata flag.\n"));
+ }
+ break;
+ default:
+ break;
+ }
+ } /* end strcase compare */
+ } /* end keyword loop */
+ /*
+ * End of keyword for loop -- if not found, we got a bogus keyword
+ */
+ if (!kw_ok) {
+ Dmsg1(800, "%s not found\n", ua->argk[i]);
+ /*
+ * Special case for Job Name, it can be the first
+ * keyword that has no value.
+ */
+ if (!rc.job_name && !ua->argv[i]) {
+ rc.job_name = ua->argk[i]; /* use keyword as job name */
+ Dmsg1(800, "Set jobname=%s\n", rc.job_name);
+ } else {
+ ua->send_msg(_("Invalid keyword: %s\n"), ua->argk[i]);
+ return false;
+ }
+ }
+ } /* end argc loop */
+
+ Dmsg0(800, "Done scan.\n");
+
+ if (rc.catalog_name) {
+ rc.catalog = GetCatalogResWithName(rc.catalog_name);
+ if (rc.catalog == NULL) {
+ ua->error_msg(_("Catalog \"%s\" not found\n"), rc.catalog_name);
+ return false;
+ }
+ if (!acl_access_ok(ua, Catalog_ACL, rc.catalog->name())) {
+ ua->error_msg(_("No authorization. Catalog \"%s\".\n"), rc.catalog->name());
+ return false;
+ }
+ }
+ Dmsg1(800, "Using catalog=%s\n", NPRT(rc.catalog_name));
+
+ if (rc.job_name) {
+ /* Find Job */
+ rc.job = GetJobResWithName(rc.job_name);
+ if (!rc.job) {
+ if (*rc.job_name != 0) {
+ ua->send_msg(_("Job \"%s\" not found\n"), rc.job_name);
+ }
+ rc.job = select_job_resource(ua);
+ } else {
+ Dmsg1(800, "Found job=%s\n", rc.job_name);
+ }
+ } else if (!rc.job) {
+ ua->send_msg(_("A job name must be specified.\n"));
+ rc.job = select_job_resource(ua);
+ }
+ if (!rc.job) {
+ return false;
+ } else if (!acl_access_ok(ua, Job_ACL, rc.job->name())) {
+ ua->error_msg( _("No authorization. Job \"%s\".\n"), rc.job->name());
+ return false;
+ }
+
+ if (rc.pool_name) {
+ rc.pool = GetPoolResWithName(rc.pool_name);
+ if (!rc.pool) {
+ if (*rc.pool_name != 0) {
+ ua->warning_msg(_("Pool \"%s\" not found.\n"), rc.pool_name);
+ }
+ rc.pool = select_pool_resource(ua);
+ }
+ } else if (!rc.pool) {
+ rc.pool = rc.job->pool; /* use default */
+ }
+ if (!rc.pool) {
+ return false;
+ } else if (!acl_access_ok(ua, Pool_ACL, rc.pool->name())) {
+ ua->error_msg(_("No authorization. Pool \"%s\".\n"), rc.pool->name());
+ return false;
+ }
+ Dmsg1(100, "Using pool %s\n", rc.pool->name());
+
+ if (rc.spool_data_set) {
+ rc.job->spool_data = rc.spool_data;
+ }
+ Dmsg1(900, "Spooling data: %s\n", (rc.job->spool_data ? "Yes" : "No"));
+
+ if (rc.store_name) {
+ rc.store->store = GetStoreResWithName(rc.store_name);
+ pm_strcpy(rc.store->store_source, _("command line"));
+ if (!rc.store->store) {
+ if (*rc.store_name != 0) {
+ ua->warning_msg(_("Storage \"%s\" not found.\n"), rc.store_name);
+ }
+ rc.store->store = select_storage_resource(ua);
+ pm_strcpy(rc.store->store_source, _("user selection"));
+ }
+ } else if (!rc.store->store) {
+ get_job_storage(rc.store, rc.job, NULL); /* use default */
+ }
+ if (!rc.store->store) {
+ ua->error_msg(_("No storage specified.\n"));
+ return false;
+ } else if (!acl_access_ok(ua, Storage_ACL, rc.store->store->name())) {
+ ua->error_msg(_("No authorization. Storage \"%s\".\n"),
+ rc.store->store->name());
+ return false;
+ }
+ Dmsg1(800, "Using storage=%s\n", rc.store->store->name());
+
+ if (rc.client_name) {
+ rc.client = GetClientResWithName(rc.client_name);
+ if (!rc.client) {
+ if (*rc.client_name != 0) {
+ ua->warning_msg(_("Client \"%s\" not found.\n"), rc.client_name);
+ }
+ rc.client = select_client_resource(ua);
+ }
+ } else if (!rc.client) {
+ rc.client = rc.job->client; /* use default */
+ }
+ if (!rc.client) {
+ return false;
+ } else if (!acl_access_ok(ua, Client_ACL, rc.client->name())) {
+ ua->error_msg(_("No authorization. Client \"%s\".\n"),
+ rc.client->name());
+ return false;
+ }
+ Dmsg1(800, "Using client=%s\n", rc.client->name());
+
+ if (rc.restore_client_name) {
+ rc.client = GetClientResWithName(rc.restore_client_name);
+ if (!rc.client) {
+ if (*rc.restore_client_name != 0) {
+ ua->warning_msg(_("Restore Client \"%s\" not found.\n"), rc.restore_client_name);
+ }
+ rc.client = select_client_resource(ua);
+ }
+ } else if (!rc.client) {
+ rc.client = rc.job->client; /* use default */
+ }
+ if (!rc.client) {
+ return false;
+ } else if (!acl_access_ok(ua, Client_ACL, rc.client->name())) {
+ ua->error_msg(_("No authorization. Client \"%s\".\n"),
+ rc.client->name());
+ return false;
+ }
+ Dmsg1(800, "Using restore client=%s\n", rc.client->name());
+
+
+ if (rc.fileset_name) {
+ rc.fileset = GetFileSetResWithName(rc.fileset_name);
+ if (!rc.fileset) {
+ ua->send_msg(_("FileSet \"%s\" not found.\n"), rc.fileset_name);
+ rc.fileset = select_fileset_resource(ua);
+ }
+ } else if (!rc.fileset) {
+ rc.fileset = rc.job->fileset; /* use default */
+ }
+ if (!rc.fileset) {
+ return false;
+ } else if (!acl_access_ok(ua, FileSet_ACL, rc.fileset->name())) {
+ ua->send_msg(_("No authorization. FileSet \"%s\".\n"),
+ rc.fileset->name());
+ return false;
+ }
+
+ if (rc.verify_job_name) {
+ rc.verify_job = GetJobResWithName(rc.verify_job_name);
+ if (!rc.verify_job) {
+ ua->send_msg(_("Verify Job \"%s\" not found.\n"), rc.verify_job_name);
+ rc.verify_job = select_job_resource(ua);
+ }
+ } else if (!rc.verify_job) {
+ rc.verify_job = rc.job->verify_job;
+ }
+
+ if (rc.previous_job_name) {
+ rc.previous_job = GetJobResWithName(rc.previous_job_name);
+ if (!rc.previous_job) {
+ ua->send_msg(_("Migration Job \"%s\" not found.\n"), rc.previous_job_name);
+ rc.previous_job = select_job_resource(ua);
+ }
+ } else {
+ rc.previous_job = rc.job->verify_job;
+ }
+ return true;