]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clean up old code
authorAlan T. DeKok <aland@freeradius.org>
Tue, 16 Feb 2021 21:11:13 +0000 (16:11 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 17 Feb 2021 12:45:05 +0000 (07:45 -0500)
after some inspection, the code was left over from other things.
Before we go crazy adding new features, let's clean things up
first.

src/lib/server/virtual_servers.c

index a9728c9f764999a5b7ddf33f1ff662e596f40e74..3f2d614503836833e6e4cfab5ed196f63d16639a 100644 (file)
@@ -97,7 +97,6 @@ static rbtree_t *server_section_name_tree = NULL;
 static int server_section_name_cmp(void const *one, void const *two);
 
 static int listen_on_read(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, CONF_PARSER const *rule);
-static int server_on_read(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED CONF_PARSER const *rule);
 
 static int listen_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, CONF_PARSER const *rule);
 static int server_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED CONF_PARSER const *rule);
@@ -122,12 +121,14 @@ const CONF_PARSER virtual_servers_on_read_config[] = {
        { FR_CONF_POINTER("server", FR_TYPE_SUBSECTION | FR_TYPE_MULTI | FR_TYPE_OK_MISSING | FR_TYPE_ON_READ, &virtual_servers), \
                          .subcs_size = sizeof(fr_virtual_server_t), .subcs_type = "fr_virtual_server_t",
                          .subcs = (void const *) listen_on_read_config, .ident2 = CF_IDENT_ANY,
-                         .func = server_on_read },
+       },
 
        CONF_PARSER_TERMINATOR
 };
 
 static const CONF_PARSER server_config[] = {
+       { FR_CONF_OFFSET("namespace", FR_TYPE_STRING, fr_virtual_server_t, namespace), },
+
        { FR_CONF_OFFSET("listen", FR_TYPE_SUBSECTION | FR_TYPE_MULTI | FR_TYPE_OK_MISSING,
                         fr_virtual_server_t, listener),                \
                         .subcs_size = sizeof(fr_virtual_listen_t), .subcs_type = "fr_virtual_listen_t",
@@ -136,12 +137,6 @@ static const CONF_PARSER server_config[] = {
        CONF_PARSER_TERMINATOR
 };
 
-static const CONF_PARSER namespace_config[] = {
-       { FR_CONF_OFFSET("namespace", FR_TYPE_STRING, fr_virtual_server_t, namespace), },
-
-       CONF_PARSER_TERMINATOR
-};
-
 const CONF_PARSER virtual_servers_config[] = {
        /*
         *      Not really ok if it's missing but we want to
@@ -241,23 +236,6 @@ static int listen_on_read(UNUSED TALLOC_CTX *ctx, UNUSED void *out, UNUSED void
 }
 
 
-/** Callback to set up listen_on_read
- *
- * @param[in] ctx      to allocate data in.
- * @param[out] out     Where to our listen configuration.  Is a #fr_virtual_server_t structure.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_SECTION containing the listen section.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int server_on_read(UNUSED TALLOC_CTX *ctx, UNUSED void *out, UNUSED void *parent,
-                         CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
-{
-       return cf_section_rules_push(cf_item_to_section(ci), namespace_config);
-}
-
 /** dl_open a proto_* module
  *
  * @param[in] ctx      to allocate data in.
@@ -302,23 +280,26 @@ static int server_parse(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent,
 {
        fr_virtual_server_t     *server = talloc_get_type_abort(out, fr_virtual_server_t);
        CONF_SECTION            *server_cs = cf_item_to_section(ci);
-       CONF_PAIR               *namespace;
-
-       namespace = cf_pair_find(server_cs, "namespace");
-       if (!namespace) {
-               cf_log_err(server_cs, "virtual server %s MUST contain a 'namespace' option",
-                          cf_section_name2(server_cs));
-               return -1;
-       }
 
        server->server_cs = server_cs;
-       server->namespace = cf_pair_value(namespace);
 
        /*
-        *      Now parse the listeners
+        *      Now parse everything in the virtual server.
         */
        if (cf_section_parse(out, server, server_cs) < 0) return -1;
 
+       if (!server->namespace) {
+               cf_log_err(server_cs, "virtual server %s MUST contain a 'namespace' configuration",
+                          cf_section_name2(server_cs));
+               return -1;
+       }
+
+       if (!*server->namespace) {
+               cf_log_err(server_cs, "virtual server %s MUST NOT have an empty 'namespace' configuration",
+                          cf_section_name2(server_cs));
+               return -1;
+       }
+
        return 0;
 }