From: Alan T. DeKok Date: Sat, 20 Feb 2021 14:29:39 +0000 (-0500) Subject: hard-code some dictionary rules X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d68d6bdc367476535b546500a59e8c7ec53dbb4;p=thirdparty%2Ffreeradius-server.git hard-code some dictionary rules which makes the rest of the code much simpler, during the cleanup process. the "control" server has no dictionary. eap-aka-prime, eap-aka, and eap-sim all have the same root dictionary. --- diff --git a/src/lib/server/virtual_servers.c b/src/lib/server/virtual_servers.c index 72b14ec39e6..68b22d384dd 100644 --- a/src/lib/server/virtual_servers.c +++ b/src/lib/server/virtual_servers.c @@ -214,16 +214,38 @@ static int namespace_on_read(UNUSED TALLOC_CTX *ctx, UNUSED void *out, UNUSED vo { CONF_PAIR *cp = cf_item_to_pair(ci); CONF_SECTION *server_cs = cf_item_to_section(cf_parent(ci)); - char const *value = cf_pair_value(cp); + char const *namespace = cf_pair_value(cp); + char const *file; + char const *dir = NULL; fr_dict_t *dict; - if (!value || !*value) { + if (!namespace || !*namespace) { cf_log_err(ci, "Missing value for 'namespace'"); return -1; } - if (fr_dict_protocol_afrom_file(&dict, value, NULL) < 0) { - cf_log_warn(ci, "No such dictionary '%s'. The server will likely fail", value); + /* + * The "control" socket does not have a dictionary. + */ + if (strcmp(namespace, "control") == 0) { + return 0; + } + + file = namespace; /* the default */ + + /* + * These are all equivalent. Rewrite the names to be our + * canonical version. + */ + if ((strcmp(namespace, "eap-aka-prime") == 0) || + (strcmp(namespace, "eap-aka") == 0) || + (strcmp(namespace, "eap-sim") == 0)) { + dir = "eap/aka-sim"; + file = "eap-aka-sim"; + } + + if (fr_dict_protocol_afrom_file(&dict, file, dir) < 0) { + cf_log_warn(ci, "Failed loading namespace '%s' - %s", namespace, fr_strerror()); return 0; }