From: Arran Cudbard-Bell Date: Thu, 24 Nov 2016 17:01:58 +0000 (-0500) Subject: Rip out server/module hup X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa7f46d661533b6462059eba36b8ae730bebb256;p=thirdparty%2Ffreeradius-server.git Rip out server/module hup They need to be re-added once v4 re-architecture is complete --- diff --git a/src/include/modpriv.h b/src/include/modpriv.h index 1511b7bf1a9..2037711d79c 100644 --- a/src/include/modpriv.h +++ b/src/include/modpriv.h @@ -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 diff --git a/src/include/modules.h b/src/include/modules.h index e2ac9c56510..52fded63a2f 100644 --- a/src/include/modules.h +++ b/src/include/modules.h @@ -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); /* diff --git a/src/main/command.c b/src/main/command.c index eb34300aa28..36612acb04e 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -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"); diff --git a/src/main/mainconfig.c b/src/main/mainconfig.c index b33508873e8..18f256dcf49 100644 --- a/src/main/mainconfig.c +++ b/src/main/mainconfig.c @@ -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 */ } diff --git a/src/main/modules.c b/src/main/modules.c index 35ac84dcc34..e21b8428a05 100644 --- a/src/main/modules.c +++ b/src/main/modules.c @@ -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); /* diff --git a/src/modules/rlm_always/rlm_always.c b/src/modules/rlm_always/rlm_always.c index 128098c4599..6508042f53c 100644 --- a/src/modules/rlm_always/rlm_always.c +++ b/src/modules/rlm_always/rlm_always.c @@ -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, diff --git a/src/modules/rlm_attr_filter/rlm_attr_filter.c b/src/modules/rlm_attr_filter/rlm_attr_filter.c index e1a8ba269d8..4efbbf207b0 100644 --- a/src/modules/rlm_attr_filter/rlm_attr_filter.c +++ b/src/modules/rlm_attr_filter/rlm_attr_filter.c @@ -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, diff --git a/src/modules/rlm_detail/rlm_detail.c b/src/modules/rlm_detail/rlm_detail.c index ac0e444e3ed..5db36618f8d 100644 --- a/src/modules/rlm_detail/rlm_detail.c +++ b/src/modules/rlm_detail/rlm_detail.c @@ -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, diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index d14950eb474..1dffe28189e 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -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, diff --git a/src/modules/rlm_krb5/rlm_krb5.c b/src/modules/rlm_krb5/rlm_krb5.c index 67386285b67..2581c844e30 100644 --- a/src/modules/rlm_krb5/rlm_krb5.c +++ b/src/modules/rlm_krb5/rlm_krb5.c @@ -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, diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 0ec3392290e..6e1feb4d718 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -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) }, diff --git a/src/modules/rlm_linelog/rlm_linelog.c b/src/modules/rlm_linelog/rlm_linelog.c index 2fcceb52189..4c9c8b466bc 100644 --- a/src/modules/rlm_linelog/rlm_linelog.c +++ b/src/modules/rlm_linelog/rlm_linelog.c @@ -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, diff --git a/src/modules/rlm_pap/rlm_pap.c b/src/modules/rlm_pap/rlm_pap.c index 198ec4ca19f..1e5ea0cda63 100644 --- a/src/modules/rlm_pap/rlm_pap.c +++ b/src/modules/rlm_pap/rlm_pap.c @@ -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, diff --git a/src/modules/rlm_passwd/rlm_passwd.c b/src/modules/rlm_passwd/rlm_passwd.c index 6f6348322aa..c0515d9532e 100644 --- a/src/modules/rlm_passwd/rlm_passwd.c +++ b/src/modules/rlm_passwd/rlm_passwd.c @@ -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, diff --git a/src/modules/rlm_radutmp/rlm_radutmp.c b/src/modules/rlm_radutmp/rlm_radutmp.c index 10f69972be3..e877dc15fa9 100644 --- a/src/modules/rlm_radutmp/rlm_radutmp.c +++ b/src/modules/rlm_radutmp/rlm_radutmp.c @@ -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 = { diff --git a/src/modules/rlm_realm/rlm_realm.c b/src/modules/rlm_realm/rlm_realm.c index 39688976b49..aabd831ae16 100644 --- a/src/modules/rlm_realm/rlm_realm.c +++ b/src/modules/rlm_realm/rlm_realm.c @@ -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, diff --git a/src/modules/rlm_securid/rlm_securid.c b/src/modules/rlm_securid/rlm_securid.c index 57cb2c4e22f..2479df3560a 100644 --- a/src/modules/rlm_securid/rlm_securid.c +++ b/src/modules/rlm_securid/rlm_securid.c @@ -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, diff --git a/src/modules/rlm_sometimes/rlm_sometimes.c b/src/modules/rlm_sometimes/rlm_sometimes.c index 09c06125600..67e16dd7099 100644 --- a/src/modules/rlm_sometimes/rlm_sometimes.c +++ b/src/modules/rlm_sometimes/rlm_sometimes.c @@ -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, diff --git a/src/modules/rlm_winbind/rlm_winbind.c b/src/modules/rlm_winbind/rlm_winbind.c index e0c25313987..3430eee525f 100644 --- a/src/modules/rlm_winbind/rlm_winbind.c +++ b/src/modules/rlm_winbind/rlm_winbind.c @@ -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,