]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
minor hacks for control sockets
authorAlan T. DeKok <aland@freeradius.org>
Mon, 22 Mar 2021 12:53:52 +0000 (08:53 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 31 Mar 2021 15:09:11 +0000 (16:09 +0100)
src/lib/server/virtual_servers.c
src/process/control/all.mk [new file with mode: 0644]
src/process/control/base.c [new file with mode: 0644]

index 3f11d832c2dcc60c68b01859431a4e5d87a50cf9..80b6105e06427c3053c03eda94242ba47be65c1c 100644 (file)
@@ -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 (file)
index 0000000..930e25b
--- /dev/null
@@ -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 (file)
index 0000000..c305929
--- /dev/null
@@ -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 <legal@networkradius.com>
+ */
+#include <freeradius-devel/server/protocol.h>
+#include <freeradius-devel/server/process.h>
+#include <freeradius-devel/util/debug.h>
+
+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,
+};