]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Rip out server/module hup
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 24 Nov 2016 17:01:58 +0000 (12:01 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 24 Nov 2016 17:01:58 +0000 (12:01 -0500)
They need to be re-added once v4 re-architecture is complete

19 files changed:
src/include/modpriv.h
src/include/modules.h
src/main/command.c
src/main/mainconfig.c
src/main/modules.c
src/modules/rlm_always/rlm_always.c
src/modules/rlm_attr_filter/rlm_attr_filter.c
src/modules/rlm_detail/rlm_detail.c
src/modules/rlm_files/rlm_files.c
src/modules/rlm_krb5/rlm_krb5.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_linelog/rlm_linelog.c
src/modules/rlm_pap/rlm_pap.c
src/modules/rlm_passwd/rlm_passwd.c
src/modules/rlm_radutmp/rlm_radutmp.c
src/modules/rlm_realm/rlm_realm.c
src/modules/rlm_securid/rlm_securid.c
src/modules/rlm_sometimes/rlm_sometimes.c
src/modules/rlm_winbind/rlm_winbind.c

index 1511b7bf1a97184d2d88d806a70cb30250d49562..2037711d79c1341660caa72a8a5c9769700a6f2d 100644 (file)
@@ -33,8 +33,6 @@ RCSIDH(modpriv_h, "$Id$")
 extern "C" {
 #endif
 
-typedef struct fr_module_hup_t fr_module_hup_t;
-
 /** Per instance data
  *
  * Per-instance data structure, to correlate the modules with the
@@ -53,8 +51,6 @@ typedef struct module_instance {
 
        CONF_SECTION                    *cs;            //!< Configuration section in modules {}.
 
-       time_t                          last_hup;       //!< Last time the module was 'hupped'.
-
        bool                            instantiated;   //!< Whether the module has been instantiated yet.
 
        bool                            force;          //!< Force the module to return a specific code.
@@ -62,16 +58,12 @@ typedef struct module_instance {
 
        rlm_rcode_t                     code;           //!< Code module will return when 'force' has
                                                        //!< has been set to true.
-       fr_module_hup_t                 *hup;           //!< Previous versions of the module's
-                                                       //!< instance data.
 } module_instance_t;
 
 module_instance_t      *module_find_with_method(rlm_components_t *method,
                                                 CONF_SECTION *modules, char const *asked_name);
 module_instance_t      *module_find(CONF_SECTION *modules, char const *asked_name);
 int                    module_sibling_section_find(CONF_SECTION **out, CONF_SECTION *module, char const *name);
-int                    module_hup(CONF_SECTION *cs, module_instance_t *node, time_t when);
-
 int                    unlang_fixup_update(vp_map_t *map, void *ctx);
 
 #ifdef __cplusplus
index e2ac9c565105f767aefb4e2ee46ae828fd58a3bd..52fded63a2feb364120e600ee2d848fab3ed3d4c 100644 (file)
@@ -78,11 +78,7 @@ extern const section_type_value_t section_type_value[];
 #define RLM_TYPE_THREAD_UNSAFE (1 << 0)        //!< Module is not threadsafe.
                                                //!< Server will protect calls
                                                //!< with mutex.
-#define RLM_TYPE_HUP_SAFE      (1 << 2)        //!< Will be restarted on HUP.
-                                               //!< Server will instantiated
-                                               //!< new instance, and then
-                                               //!< destroy old instance.
-#define RLM_TYPE_RESUMABLE             (1 << 3)        //!< does yield / resume
+#define RLM_TYPE_RESUMABLE             (1 << 2)        //!< does yield / resume
 
 /** Module section callback
  *
@@ -169,7 +165,6 @@ exfile_t *module_exfile_init(TALLOC_CTX *ctx,
 int            modules_bootstrap(CONF_SECTION *root) CC_HINT(nonnull);
 int            modules_instantiate(CONF_SECTION *root) CC_HINT(nonnull);
 int            modules_free(void);
-int            modules_hup(CONF_SECTION *modules);
 int            module_instance_read_only(TALLOC_CTX *ctx, char const *name);
 
 /*
index eb34300aa2842ef24e89808e289f142c911bde1a..36612acb04efbd46e29fbdc699de357f62ecabde 100644 (file)
@@ -854,22 +854,9 @@ static int command_hup(rad_listen_t *listener, int argc, char *argv[])
                return CMD_FAIL;
        }
 
-       if ((instance->module->type & RLM_TYPE_HUP_SAFE) == 0) {
-               cprintf_error(listener, "Module %s cannot be hup'd\n",
-                       argv[0]);
-               return CMD_FAIL;
-       }
-
-       if (!module_hup(instance->cs, instance, time(NULL))) {
-               cprintf_error(listener, "Failed to reload module\n");
-               return CMD_FAIL;
-       }
-
-       snprintf(buffer, sizeof(buffer), "modules.%s.hup",
-                cf_section_name1(instance->cs));
-       trigger_exec(NULL, instance->cs, buffer, true, NULL);
+       cprintf_error(listener, "HUP - NYI in version 4", argv[0]);
 
-       return CMD_OK;
+       return CMD_FAIL;
 }
 
 static int command_terminate(UNUSED rad_listen_t *listener,
@@ -1100,8 +1087,6 @@ static int command_show_module_flags(rad_listen_t *listener, int argc, char *arg
 
        if ((instance->module->type & RLM_TYPE_THREAD_UNSAFE) != 0) cprintf(listener, "thread-unsafe\n");
 
-       if ((instance->module->type & RLM_TYPE_HUP_SAFE) != 0) cprintf(listener, "reload-on-hup\n");
-
        return CMD_OK;
 }
 
@@ -2509,11 +2494,6 @@ static int command_set_module_config(rad_listen_t *listener, int argc, char *arg
                return 0;
        }
 
-       if ((instance->module->type & RLM_TYPE_HUP_SAFE) == 0) {
-               cprintf_error(listener, "Cannot change configuration of module as it is cannot be HUP'd.\n");
-               return 0;
-       }
-
        variables = cf_section_parse_table(instance->cs);
        if (!variables) {
                cprintf_error(listener, "Cannot find configuration for module\n");
index b33508873e83ebefe70c71f83a367e299c4aaa9e..18f256dcf49360b8dccda79e5073792f83041a62 100644 (file)
@@ -1133,52 +1133,11 @@ void hup_logfile(void)
        }
 }
 
-static int hup_callback(void *ctx, void *data)
-{
-       CONF_SECTION *modules = ctx;
-       CONF_SECTION *cs = data;
-       CONF_SECTION *parent;
-       char const *name;
-       module_instance_t *instance;
-
-       /*
-        *      Files may be defined in sub-sections of a module
-        *      config.  Walk up the tree until we find the module
-        *      definition.
-        */
-       parent = cf_item_parent(cf_section_to_item(cs));
-       while (parent != modules) {
-               cs = parent;
-               parent = cf_item_parent(cf_section_to_item(cs));
-
-               /*
-                *      Something went wrong.  Oh well...
-                */
-               if (!parent) return 0;
-       }
-
-       name = cf_section_name2(cs);
-       if (!name) name = cf_section_name1(cs);
-
-       instance = module_find(modules, name);
-       if (!instance) return 0;
-
-       if ((instance->module->type & RLM_TYPE_HUP_SAFE) == 0) return 0;
-
-       if (!module_hup(instance->cs, instance, time(NULL))) return 0;
-
-       return 1;
-}
-
 void main_config_hup(void)
 {
-       int rcode;
-       cached_config_t *cc;
-       CONF_SECTION *cs;
-       time_t when;
-       char buffer[1024];
+       time_t          when;
 
-       static time_t last_hup = 0;
+       static time_t   last_hup = 0;
 
        /*
         *      Re-open the log file.  If we can't, then keep logging
@@ -1199,6 +1158,7 @@ void main_config_hup(void)
        }
        last_hup = when;
 
+#if 0
        rcode = cf_file_changed(cs_cache->cs, hup_callback);
        if (rcode == CF_FILE_NONE) {
                INFO("HUP - No files changed.  Ignoring");
@@ -1209,64 +1169,7 @@ void main_config_hup(void)
                INFO("HUP - Cannot read configuration files.  Ignoring");
                return;
        }
+#endif
 
-       /*
-        *      No config files have changed.
-        */
-       if ((rcode & CF_FILE_CONFIG) == 0) {
-               if ((rcode & CF_FILE_MODULE) != 0) {
-                       INFO("HUP - Files loaded by a module have changed.");
-
-                       /*
-                        *      FIXME: reload the module.
-                        */
-
-               }
-               return;
-       }
-
-       cs = cf_section_alloc(NULL, "main", NULL);
-       if (!cs) return;
-
-       /* Read the configuration file */
-       snprintf(buffer, sizeof(buffer), "%.200s/%.50s.conf", radius_dir, main_config.name);
-
-       INFO("HUP - Re-reading configuration files");
-       if (cf_file_read(cs, buffer) < 0) {
-               ERROR("Failed to re-read or parse %s", buffer);
-               talloc_free(cs);
-               return;
-       }
-
-       cc = talloc_zero(cs_cache, cached_config_t);
-       if (!cc) {
-               ERROR("Out of memory");
-               return;
-       }
-
-       /*
-        *      Save the current configuration.  Note that we do NOT
-        *      free older ones.  We should probably do so at some
-        *      point.  Doing so will require us to mark which modules
-        *      are still in use, and which aren't.  Modules that
-        *      can't be HUPed always use the original configuration.
-        *      Modules that can be HUPed use one of the newer
-        *      configurations.
-        */
-       cc->created = time(NULL);
-       cc->cs = talloc_steal(cc, cs);
-       cc->next = cs_cache;
-       cs_cache = cc;
-
-       INFO("HUP - loading modules");
-
-       /*
-        *      Prefer the new module configuration.
-        */
-       modules_hup(cf_section_sub_find(cs, "modules"));
-
-       /*
-        *      Load the new servers.
-        */
-       virtual_servers_init(cs);
+       INFO("HUP - NYI in version 4"); /* Not yet implemented in v4 */
 }
index 35ac84dcc34459f724d63769c2e25d4ffa4a8aeb..e21b8428a05a026df3bb4229aed9f94c52455526 100644 (file)
@@ -34,13 +34,6 @@ RCSID("$Id$")
 
 static TALLOC_CTX *instance_ctx = NULL;
 
-struct fr_module_hup_t {
-       module_instance_t       *mi;
-       time_t                  when;
-       void                    *insthandle;
-       fr_module_hup_t         *next;
-};
-
 /*
  *     Ordered by component
  */
@@ -450,146 +443,6 @@ module_instance_t *module_find_with_method(rlm_components_t *method, CONF_SECTIO
        return inst;
 }
 
-/** Free old instances from HUPs
- *
- */
-static void module_hup_free(module_instance_t *instance, time_t when)
-{
-       fr_module_hup_t *mh, **last;
-
-       /*
-        *      Walk the list, freeing up old instances.
-        */
-       last = &(instance->hup);
-       while (*last) {
-               mh = *last;
-
-               /*
-                *      Free only every 60 seconds.
-                */
-               if ((when - mh->when) < 60) {
-                       last = &(mh->next);
-                       continue;
-               }
-
-               talloc_free(mh->insthandle);
-
-               *last = mh->next;
-               talloc_free(mh);
-       }
-}
-
-int module_hup(CONF_SECTION *cs, module_instance_t *instance, time_t when)
-{
-       void *insthandle;
-       fr_module_hup_t *mh;
-
-       if (!instance ||
-           instance->module->bootstrap ||
-           !instance->module->instantiate ||
-           ((instance->module->type & RLM_TYPE_HUP_SAFE) == 0)) {
-               return 1;
-       }
-
-       /*
-        *      Silently ignore multiple HUPs within a short time period.
-        */
-       if ((instance->last_hup + 2) >= when) return 1;
-       instance->last_hup = when;
-
-       cf_log_module(cs, "Trying to reload module \"%s\"", instance->name);
-
-       /*
-        *      Parse the module configuration, and setup destructors so the
-        *      module's detach method is called when it's instance data is
-        *      about to be freed.
-        */
-       if (dl_module_instance_data_alloc(&insthandle, instance, instance->handle, cs) < 0) {
-               cf_log_err_cs(cs, "HUP failed for module \"%s\" (parsing config failed). "
-                       "Using old configuration", instance->name);
-
-               return 0;
-       }
-
-       if ((instance->module->instantiate)(cs, insthandle) < 0) {
-               cf_log_err_cs(cs, "HUP failed for module \"%s\".  Using old configuration.", instance->name);
-               talloc_free(insthandle);
-
-               return 0;
-       }
-
-       INFO("Module: Reloaded module \"%s\"", instance->name);
-
-       module_hup_free(instance, when);
-
-       /*
-        *      Save the old instance handle for later deletion.
-        */
-       mh = talloc_zero(instance_ctx, fr_module_hup_t);
-       mh->mi = instance;
-       mh->when = when;
-       mh->insthandle = instance->data;
-       mh->next = instance->hup;
-       instance->hup = mh;
-
-       /*
-        *      Replace the instance handle while the module is running.
-        */
-       instance->data = insthandle;
-
-       /*
-        *      FIXME: Set a timeout to come back in 60s, so that
-        *      we can pro-actively clean up the old instances.
-        */
-
-       return 1;
-}
-
-/** Reload the configurations of modules that support it
- *
- * @param modules CONF_SECTION.
- * @return
- *     - 0 on failure.
- *     - 1 on success.
- */
-int modules_hup(CONF_SECTION *modules)
-{
-       time_t when;
-       CONF_ITEM *ci;
-       CONF_SECTION *cs;
-       module_instance_t *instance;
-
-       if (!modules) return 0;
-
-       when = time(NULL);
-
-       /*
-        *      Loop over the modules
-        */
-       for (ci = cf_item_find_next(modules, NULL);
-            ci != NULL;
-            ci = cf_item_find_next(modules, ci)) {
-               char const *instance_name;
-
-               /*
-                *      If it's not a section, ignore it.
-                */
-               if (!cf_item_is_section(ci)) continue;
-
-               cs = cf_item_to_section(ci);
-
-               instance_name = cf_section_name2(cs);
-               if (!instance_name) instance_name = cf_section_name1(cs);
-
-               instance = module_find(modules, instance_name);
-               if (!instance) continue;
-
-               module_hup(cs, instance, when);
-       }
-
-       return 1;
-}
-
 /** Free all modules loaded by the server
  *
  * @return 0.
@@ -662,7 +515,6 @@ static int _module_instantiate(void *instance, UNUSED void *ctx)
 #endif
 
        inst->instantiated = true;
-       inst->last_hup = time(NULL); /* don't let us load it, then immediately hup it */
 
        return 0;
 }
@@ -719,11 +571,6 @@ static int _module_instance_free(module_instance_t *instance)
                pthread_mutex_destroy(instance->mutex);
        }
 
-       /*
-        *      Free HUP versions of the module's instance data
-        */
-       module_hup_free(instance, time(NULL) + 100);
-
        xlat_unregister(instance->data, instance->name, NULL);
 
        /*
index 128098c4599823e50ad6f7524da2f255c0a1a835..6508042f53c434fc17b18c69329bbdd22371bb51 100644 (file)
@@ -128,7 +128,6 @@ extern rad_module_t rlm_always;
 rad_module_t rlm_always = {
        .magic          = RLM_MODULE_INIT,
        .name           = "always",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(rlm_always_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index e1a8ba269d8bf2282cabb58c9e7ecf2b0900df1c..4efbbf207b02f4df787c24592dae7f9ca82584b9 100644 (file)
@@ -337,7 +337,6 @@ extern rad_module_t rlm_attr_filter;
 rad_module_t rlm_attr_filter = {
        .magic          = RLM_MODULE_INIT,
        .name           = "attr_filter",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(rlm_attr_filter_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index ac0e444e3edbaf502916de7e7174fa28697ca318..5db36618f8d3669025caae8958a00aeb47d47328 100644 (file)
@@ -521,7 +521,6 @@ extern rad_module_t rlm_detail;
 rad_module_t rlm_detail = {
        .magic          = RLM_MODULE_INIT,
        .name           = "detail",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(rlm_detail_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index d14950eb474d17281dc38fa27686cbfa75384e7d..1dffe28189ea43b891fc65ed71ccff29b44ca2c8 100644 (file)
@@ -527,7 +527,6 @@ extern rad_module_t rlm_files;
 rad_module_t rlm_files = {
        .magic          = RLM_MODULE_INIT,
        .name           = "files",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(rlm_files_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index 67386285b670d39d6a2ab5faf9e66443bea0261d..2581c844e303b5f63a3b2fae6572b634ae1c3d54 100644 (file)
@@ -460,11 +460,9 @@ extern rad_module_t rlm_krb5;
 rad_module_t rlm_krb5 = {
        .magic          = RLM_MODULE_INIT,
        .name           = "krb5",
-       .type           = RLM_TYPE_HUP_SAFE
 #ifdef KRB5_IS_THREAD_SAFE
-       | RLM_TYPE_THREAD_SAFE
+       .type           = RLM_TYPE_THREAD_SAFE,
 #endif
-       ,
        .inst_size      = sizeof(rlm_krb5_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index 0ec3392290eb24eb1280583c4c1099f15dd30a46..6e1feb4d718667545c9b11482c2d84249848b371 100644 (file)
@@ -99,7 +99,7 @@ static CONF_PARSER tls_config[] = {
 
        { FR_CONF_OFFSET("certificate_file", PW_TYPE_FILE_INPUT, rlm_ldap_t, tls_certificate_file) },
 
-       { FR_CONF_OFFSET("private_key_file", PW_TYPE_FILE_INPUT, rlm_ldap_t, tls_private_key_file) }, // OK if it changes on HUP
+       { FR_CONF_OFFSET("private_key_file", PW_TYPE_FILE_INPUT, rlm_ldap_t, tls_private_key_file) },
 
        { FR_CONF_OFFSET("random_file", PW_TYPE_FILE_EXISTS, rlm_ldap_t, tls_random_file) },
 
index 2fcceb52189a4f765061127a46c42daa2a6205bf..4c9c8b466bce6048e63940cad2253050e23e6cdc 100644 (file)
@@ -793,7 +793,6 @@ extern rad_module_t rlm_linelog;
 rad_module_t rlm_linelog = {
        .magic          = RLM_MODULE_INIT,
        .name           = "linelog",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(linelog_instance_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index 198ec4ca19fbe81a0aa7fff48deee9ac5325cb7a..1e5ea0cda63eb8a9f0598ff5f9410815c676807d 100644 (file)
@@ -1071,7 +1071,6 @@ extern rad_module_t rlm_pap;
 rad_module_t rlm_pap = {
        .magic          = RLM_MODULE_INIT,
        .name           = "pap",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(rlm_pap_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index 6f6348322aa7234800116de3c04e46052295c071..c0515d9532e1e34e017fd0bf119c491e64f37b3c 100644 (file)
@@ -562,7 +562,6 @@ extern rad_module_t rlm_passwd;
 rad_module_t rlm_passwd = {
        .magic          = RLM_MODULE_INIT,
        .name           = "passwd",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(rlm_passwd_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index 10f69972be3183edda29d7f8146e3ebe8e297ea6..e877dc15fa9beb08b40927ee8f50f0f75f6b4595 100644 (file)
@@ -737,7 +737,7 @@ extern rad_module_t rlm_radutmp;
 rad_module_t rlm_radutmp = {
        .magic          = RLM_MODULE_INIT,
        .name           = "radutmp",
-       .type           = RLM_TYPE_THREAD_UNSAFE | RLM_TYPE_HUP_SAFE,
+       .type           = RLM_TYPE_THREAD_UNSAFE,
        .inst_size      = sizeof(rlm_radutmp_t),
        .config         = module_config,
        .methods = {
index 39688976b494302a2c356b69b2136094bdb1bf79..aabd831ae16ce686af130b2d3a9e81aa14982c8b 100644 (file)
@@ -517,7 +517,6 @@ extern rad_module_t rlm_realm;
 rad_module_t rlm_realm = {
        .magic          = RLM_MODULE_INIT,
        .name           = "realm",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(struct rlm_realm_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index 57cb2c4e22f93e27a777de9dc7d3ad43f8e681be..2479df3560a4f163df0ccecefe66cc341c8b46be 100644 (file)
@@ -544,7 +544,6 @@ extern rad_module_t rlm_securid;
 rad_module_t rlm_securid = {
        .magic          = RLM_MODULE_INIT,
        .name           = "securid",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(rlm_securid_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index 09c0612560099ca43ebd2409330e3e6ce6ecce6a..67e16dd7099e159bd161534c399942e0554a42a4 100644 (file)
@@ -156,7 +156,6 @@ extern rad_module_t rlm_sometimes;
 rad_module_t rlm_sometimes = {
        .magic          = RLM_MODULE_INIT,
        .name           = "sometimes",
-       .type           = RLM_TYPE_HUP_SAFE,    /* needed for radmin */
        .inst_size      = sizeof(rlm_sometimes_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,
index e0c253139877eb5a64119762fc1b4593df8ee06b..3430eee525fd669e5207c613ca712d4c307c0afa 100644 (file)
@@ -521,7 +521,6 @@ extern rad_module_t rlm_winbind;
 rad_module_t rlm_winbind = {
        .magic          = RLM_MODULE_INIT,
        .name           = "winbind",
-       .type           = RLM_TYPE_HUP_SAFE,
        .inst_size      = sizeof(rlm_winbind_t),
        .config         = module_config,
        .instantiate    = mod_instantiate,