]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
hard-code some dictionary rules
authorAlan T. DeKok <aland@freeradius.org>
Sat, 20 Feb 2021 14:29:39 +0000 (09:29 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 20 Feb 2021 17:37:19 +0000 (12:37 -0500)
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.

src/lib/server/virtual_servers.c

index 72b14ec39e62d48559b8f8f7986e9fa0bb94c937..68b22d384dd18473e17305d7abb362bf42cdb197 100644 (file)
@@ -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;
        }