From: Arran Cudbard-Bell Date: Sat, 19 Oct 2024 01:49:35 +0000 (-0600) Subject: Support resetting the dictionary root X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05ca7cb6e08dc42c508cb0d316b4a8e648e13093;p=thirdparty%2Ffreeradius-server.git Support resetting the dictionary root --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 0d7cde966d9..98f9bb1b04f 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -50,6 +50,7 @@ typedef struct request_s request_t; #include #include #include +#include #include #include #include @@ -2549,10 +2550,14 @@ static size_t command_proto_dictionary_root(command_result_t *result, command_fi fr_dict_attr_t const *root_da = fr_dict_root(dict); fr_dict_attr_t const *new_root; - new_root = fr_dict_attr_by_name(NULL, fr_dict_root(dict), in); - if (!new_root) { - fr_strerror_printf("dictionary attribute \"%s\" not found in %s", in, root_da->name); - RETURN_PARSE_ERROR(0); + if (is_whitespace(in) || (*in == '\0')) { + new_root = fr_dict_root(dict); + } else { + new_root = fr_dict_attr_by_name(NULL, fr_dict_root(dict), in); + if (!new_root) { + fr_strerror_printf("dictionary attribute \"%s\" not found in %s", in, root_da->name); + RETURN_PARSE_ERROR(0); + } } cc->tmpl_rules.attr.namespace = new_root; @@ -3159,8 +3164,9 @@ static fr_table_ptr_sorted_t commands[] = { { L("proto-dictionary-root "), &(command_entry_t){ .func = command_proto_dictionary_root, - .usage = "proto-dictionary-root ", - .description = "Set the root attribute for the current protocol dictionary", + .usage = "proto-dictionary-root[ ]", + .description = "Set the root attribute for the current protocol dictionary. " + "If no attribute name is provided, the root will be reset to the root of the current dictionary", }}, { L("raw "), &(command_entry_t){ .func = command_encode_raw,