]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move dlopen() to load by protocol
authorAlan T. DeKok <aland@freeradius.org>
Mon, 4 Nov 2019 22:11:31 +0000 (17:11 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 4 Nov 2019 22:11:31 +0000 (17:11 -0500)
src/lib/util/dict_priv.h
src/lib/util/dict_tokenize.c
src/lib/util/dict_util.c

index 3c12777f53ba6ad50cc79e84234e85567d0b4dea..90757f01118c0c49c1335e0a363d9a44427dee3c 100644 (file)
@@ -100,7 +100,9 @@ extern TALLOC_CTX *dict_ctx;
 extern fr_table_num_ordered_t const date_precision_table[];
 extern size_t date_precision_table_len;
 
-fr_dict_t              *dict_alloc(TALLOC_CTX *ctx, char const *name);
+fr_dict_t              *dict_alloc(TALLOC_CTX *ctx);
+
+int                    dict_dlopen(fr_dict_t *dict, char const *name);
 
 /** Initialise fields in a dictionary attribute structure
  *
index 7c7f2bbc6ba8217f5f858553a9401ad2af2d84ce..3aabb7ffc8e85ba403641b729e2e97d346dd25b0 100644 (file)
@@ -1236,7 +1236,17 @@ static int dict_read_process_protocol(char **argv, int argc)
                return 0;
        }
 
-       dict = dict_alloc(NULL, argv[0]);
+       dict = dict_alloc(NULL);
+
+       /*
+        *      Try to load protocol-specific validation routines.
+        *      Some protocols don't need them, so it's OK if the
+        *      validation routines don't exist.
+        */
+       if (dict_dlopen(dict, argv[0]) < 0) {
+               talloc_free(dict);
+               return -1;
+       }
 
        /*
         *      Set the root attribute with the protocol name
@@ -2240,7 +2250,7 @@ int fr_dict_internal_afrom_file(fr_dict_t **out, char const *dict_subdir)
        memcpy(&tmp, &dict_dir_default, sizeof(tmp));
        dict_path = dict_subdir ? talloc_asprintf(NULL, "%s%c%s", dict_dir_default, FR_DIR_SEP, dict_subdir) : tmp;
 
-       dict = dict_alloc(dict_ctx, NULL);
+       dict = dict_alloc(dict_ctx);
        if (!dict) {
        error:
                if (!fr_dict_internal) talloc_free(dict);
index 4359496f9e9b38d6e4928ee74a3e9cbb753278ea..8e74371bb4fa0321942ce8ba1070cd24ff2b30a1 100644 (file)
@@ -2153,7 +2153,7 @@ fr_dict_enum_t *fr_dict_enum_by_alias(fr_dict_attr_t const *da, char const *alia
        return fr_hash_table_finddata(dict->values_by_alias, &find);
 }
 
-static int dict_dlopen(fr_dict_t *dict, char const *name)
+int dict_dlopen(fr_dict_t *dict, char const *name)
 {
        char *module_name;
        char *p, *q;
@@ -2208,11 +2208,10 @@ static int _dict_free(fr_dict_t *dict)
 /** Allocate a new dictionary
  *
  * @param[in] ctx to allocate dictionary in.
- * @param[in] name the name of the protocol
  * @return
  *     - NULL on memory allocation error.
  */
-fr_dict_t *dict_alloc(TALLOC_CTX *ctx, char const *name)
+fr_dict_t *dict_alloc(TALLOC_CTX *ctx)
 {
        fr_dict_t *dict;
 
@@ -2273,11 +2272,11 @@ fr_dict_t *dict_alloc(TALLOC_CTX *ctx, char const *name)
        dict->values_by_da = fr_hash_table_create(dict, dict_enum_value_hash, dict_enum_value_cmp, hash_pool_free);
        if (!dict->values_by_da) goto error;
 
-       if (dict_dlopen(dict, name) < 0) goto error;
-
        /*
-        *      Try to load libfreeradius-NAME
+        *      Set default type size and length.
         */
+       dict->default_type_size = 1;
+       dict->default_type_length = 1;
 
        return dict;
 }