From: Alan T. DeKok Date: Mon, 22 Mar 2021 12:53:52 +0000 (-0400) Subject: minor hacks for control sockets X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=33908aaf7c99bc56d8689e114fca717351001a32;p=thirdparty%2Ffreeradius-server.git minor hacks for control sockets --- diff --git a/src/lib/server/virtual_servers.c b/src/lib/server/virtual_servers.c index 3f11d832c2d..80b6105e064 100644 --- a/src/lib/server/virtual_servers.c +++ b/src/lib/server/virtual_servers.c @@ -247,7 +247,8 @@ static int namespace_on_read(UNUSED TALLOC_CTX *ctx, UNUSED void *out, UNUSED vo * The "control" socket does not have a dictionary. */ if (strcmp(namespace, "control") == 0) { - return 0; + dict = fr_dict_unconst(fr_dict_internal()); + goto set; } file = namespace; /* the default */ @@ -271,6 +272,7 @@ static int namespace_on_read(UNUSED TALLOC_CTX *ctx, UNUSED void *out, UNUSED vo return -1; } +set: virtual_server_dict_set(server_cs, dict, true); /* @@ -855,7 +857,10 @@ int virtual_servers_instantiate(void) fr_assert(virtual_servers[i]->process_module); - if (!dict) return -1; /* should never happen */ + if (!dict) { + cf_log_err(server_cs, "No dictionary for namespace %s", virtual_servers[i]->namespace); + return -1; /* should never happen */ + } if (process_instantiate(server_cs, virtual_servers[i]->process_module, dict->dict) < 0) return -1; diff --git a/src/process/control/all.mk b/src/process/control/all.mk new file mode 100644 index 00000000000..930e25b72a1 --- /dev/null +++ b/src/process/control/all.mk @@ -0,0 +1,9 @@ +TARGETNAME := process_control + +ifneq "$(TARGETNAME)" "" +TARGET := $(TARGETNAME).a +endif + +SOURCES := base.c + +TGT_PREREQS := libfreeradius-util.a diff --git a/src/process/control/base.c b/src/process/control/base.c new file mode 100644 index 00000000000..c305929e9dd --- /dev/null +++ b/src/process/control/base.c @@ -0,0 +1,58 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * $Id$ + * @file src/process/control/base.c + * @brief CONTROL processing. + * + * @copyright 2020 Network RADIUS SARL + */ +#include +#include +#include + +static fr_dict_t const *dict_freeradius; + +extern fr_dict_autoload_t process_control_dict[]; +fr_dict_autoload_t process_control_dict[] = { + { .out = &dict_freeradius, .proto = "freeradius" }, + { NULL } +}; + +static fr_dict_attr_t const *attr_module_failure_message; +static fr_dict_attr_t const *attr_module_success_message; + +extern fr_dict_attr_autoload_t process_control_dict_attr[]; +fr_dict_attr_autoload_t process_control_dict_attr[] = { + { .out = &attr_module_failure_message, .name = "Module-Failure-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius }, + { .out = &attr_module_success_message, .name = "Module-Success-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius }, + + { NULL } +}; + +static unlang_action_t mod_process(rlm_rcode_t *p_result, UNUSED module_ctx_t const *mctx, UNUSED request_t *request) +{ + RETURN_MODULE_FAIL; +} + +extern fr_process_module_t process_control; +fr_process_module_t process_control = { + .magic = RLM_MODULE_INIT, + .name = "process_control", + .process = mod_process, + .dict = &dict_freeradius, +};