Skip to content

Commit

Permalink
configure add: deny adding a director resource
Browse files Browse the repository at this point in the history
Only a single director resource is allowed per director.
  • Loading branch information
joergsteffens committed Aug 25, 2016
1 parent cb52b40 commit ca944e3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/dird/dird_conf.c
Expand Up @@ -1023,7 +1023,11 @@ const char *get_configure_usage_string()
* subcommand: add
*/
for (int r = 0; resources[r].name; r++) {
if (resources[r].items) {
/*
* Only one Director is allowed.
* If the resource have not items, there is no need to add it.
*/
if ((resources[r].rcode != R_DIRECTOR) && (resources[r].items)) {
configure_usage_string->strcat("add ");
resourcename.strcpy(resources[r].name);
resourcename.toLower();
Expand Down
16 changes: 11 additions & 5 deletions src/dird/ua_configure.c
Expand Up @@ -349,14 +349,20 @@ static inline bool configure_add(UAContext *ua, int resource_type_parameter)
RES_TABLE *res_table = NULL;

res_table = my_config->get_resource_table(ua->argk[resource_type_parameter]);
if (res_table) {
ua->send->object_start("configure");
result = configure_add_resource(ua, resource_type_parameter+1, res_table);
ua->send->object_end("configure");
} else {
if (!res_table) {
ua->error_msg(_("invalid resource type %s.\n"), ua->argk[resource_type_parameter]);
return false;
}

if (res_table->rcode == R_DIRECTOR) {
ua->error_msg(_("Only one Director resource allowed.\n"));
return false;
}

ua->send->object_start("configure");
result = configure_add_resource(ua, resource_type_parameter+1, res_table);
ua->send->object_end("configure");

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/parse_conf.c
Expand Up @@ -169,7 +169,7 @@ bool CONFIG::parse_config_file(const char *cf, void *caller_ctx, LEX_ERROR_HANDL
* Make two passes. The first builds the name symbol table,
* and the second picks up the items.
*/
Dmsg0(900, "Enter parse_config()\n");
Dmsg1(900, "Enter parse_config_file(%s)\n", cf);
for (pass = 1; pass <= 2; pass++) {
Dmsg1(900, "parse_config pass %d\n", pass);
if ((lc = lex_open_file(lc, cf, scan_error, scan_warning)) == NULL) {
Expand Down

0 comments on commit ca944e3

Please sign in to comment.