]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add dictionary directory to fr_dict_autoload()
authorAlan T. DeKok <aland@freeradius.org>
Mon, 7 May 2018 15:34:00 +0000 (11:34 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 7 May 2018 15:34:00 +0000 (11:34 -0400)
src/include/dict.h
src/lib/util/dict.c
src/main/mainconfig.c
src/main/module.c
src/modules/rlm_eap/lib/base/eap_base.c

index 101f050f7668beea4a4937da89dae1e3a4baf2c8..1afe0d0f565257e62f41e744b97655223b92b041 100644 (file)
@@ -351,7 +351,7 @@ int                 fr_dict_read(fr_dict_t *dict, char const *dir, char const *filename);
  */
 int                    fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load);
 
-int                    fr_dict_autoload(fr_dict_autoload_t const *to_load);
+int                    fr_dict_autoload(char const *dir, fr_dict_autoload_t const *to_load);
 
 void                   fr_dict_autofree(fr_dict_autoload_t const *to_free);
 /** @} */
index 0fb8ab4e1c62c03ac8244a44fb82080192ce4e44..30703094b78306725aad51da5001b786f0c010f1 100644 (file)
@@ -5281,33 +5281,34 @@ int fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load)
 
 /** Process a dict_autoload element to load a protocol
  *
+ * @param[in] dir      directory where the dictionaries are stored.
  * @param[in] to_load  dictionary definition.
  * @return
  *     - 0 on success.
  *     - -1 on failure.
  */
-int fr_dict_autoload(fr_dict_autoload_t const *to_load)
+int fr_dict_autoload(char const *dir, fr_dict_autoload_t const *to_load)
 {
        fr_dict_t                       *dict = NULL;
        fr_dict_autoload_t const        *p;
+       char const                      *my_dir;
 
        for (p = to_load; p->out; p++) {
+               my_dir = dir;
+
                if (unlikely(!p->out)) {
                        fr_strerror_printf("autoload missing parameter out");
                        return -1;
                }
 
-               if (unlikely(!p->base_dir)) {
-                       fr_strerror_printf("autoload missing parameter base_dir");
-                       return 0;       /* Change to -1 later */
-               }
+               if (p->base_dir) my_dir = p->base_dir;
 
                if (unlikely(!p->proto)) {
                        fr_strerror_printf("autoload missing parameter proto");
                        return -1;
                }
 
-               if (fr_dict_protocol_afrom_file(NULL, &dict, p->base_dir, p->proto) < 0) return -1;
+               if (fr_dict_protocol_afrom_file(NULL, &dict, my_dir, p->proto) < 0) return -1;
 
                if (p->out) *(p->out) = dict;
        }
index ecda8d760c5ffeb34c9242894f9bdb473bc793c3..38c0c82a9e8eab26b9317db804b7298ed979da66 100644 (file)
@@ -274,7 +274,7 @@ static int _module_dict_autoload(dl_t const *module, void *symbol, UNUSED void *
 {
        DEBUG("Loading dictionary %s", module->name);
 
-       if (fr_dict_autoload((fr_dict_autoload_t const *)symbol) < 0) {
+       if (fr_dict_autoload(main_config.dictionary_dir, (fr_dict_autoload_t const *)symbol) < 0) {
                ERROR("Failed loading dictionary: %s", fr_strerror());
                return -1;
        }
index c4826287f55d7b3c23d55c5f080686f640e46a38..31252cb40874c19488bb634252ef82f987eafac1 100644 (file)
@@ -954,7 +954,7 @@ static int virtual_module_bootstrap(CONF_SECTION *modules, CONF_SECTION *vm_cs)
 #if 0
 static int _module_dict_autoload(dl_t const *module, void *symbol, UNUSED void *user_ctx)
 {
-       if (fr_dict_autoload((fr_dict_autoload_t *)symbol) < 0) {
+       if (fr_dict_autoload(main_config.dictionary_dir, (fr_dict_autoload_t *)symbol) < 0) {
                ERROR("Failed loading dictionary: %s", fr_strerror());
                return -1;
        }
index 76d42f0a7dd63113b0de8736738ca12194fbb20d..3a1d3e334c49e01a68560da9bd13a2cac8b8b886 100644 (file)
@@ -423,7 +423,7 @@ rlm_rcode_t eap_virtual_server(REQUEST *request, REQUEST *fake,
  */
 int eap_base_init(void)
 {
-       if (fr_dict_autoload(eap_base_dict) < 0) return -1;
+       if (fr_dict_autoload(main_config.dictionary_dir, eap_base_dict) < 0) return -1;
        if (fr_dict_attr_autoload(eap_base_dict_attr) < 0) return -1;
 
        return 0;