]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
narrow down the scope of bare words in the configuration files
authorAlan T. DeKok <aland@freeradius.org>
Sat, 24 Aug 2024 12:23:25 +0000 (08:23 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 24 Aug 2024 12:38:30 +0000 (08:38 -0400)
only unlang (module references) and edit sections (lists of values)
can have bare words.

as a result, remove old configuration sections which haven't been
used for a while.

Outside of unlang (map, switch) name2 must be alphanumeric

src/lib/server/cf_file.c
src/tests/keywords/dhcpv4.conf
src/tests/keywords/dhcpv6.conf

index 4febffaba93ab1c2b36342c122a30ae767d78905..2e89c4430078eefdaf961b0dfc781231cb94bc12 100644 (file)
@@ -2165,7 +2165,7 @@ static int parse_input(cf_stack_t *stack)
        /*
         *      See if this thing is a variable definition.
         */
-       if (parent->allow_locals) {
+       if (parent->allow_locals && (name1_token == T_BARE_WORD)) {
                fr_type_t type;
 
                type = fr_table_value_by_str(fr_type_table, buff[1], FR_TYPE_NULL);
@@ -2193,15 +2193,27 @@ static int parse_input(cf_stack_t *stack)
        }
 
        /*
-        *      parent single word is done.  Create a CONF_PAIR.
+        *      We've parsed the LHS thing.  The RHS might be empty, or an operator, or another word, or an
+        *      open bracket.
         */
 check_for_eol:
        if (!*ptr || (*ptr == '#') || (*ptr == ',') || (*ptr == ';') || (*ptr == '}')) {
-               parent->allow_locals = false;
-               value_token = T_INVALID;
-               op_token = T_OP_EQ;
-               value = NULL;
-               goto alloc_pair;
+               /*
+                *      Only unlang sections can have module references.
+                *
+                *      We also allow bare words in edit lists, where the RHS is a list of values.
+                */
+               if( (parent->unlang == CF_UNLANG_ALLOW) || (parent->unlang == CF_UNLANG_EDIT)) {
+                       parent->allow_locals = false;
+                       value_token = T_INVALID;
+                       op_token = T_OP_EQ;
+                       value = NULL;
+                       goto alloc_pair;
+               }
+
+               ERROR("%s[%d]: Parse error: Unexpected bare word.  There should be a '{' or operator after it",
+                     frame->filename, frame->lineno);
+               return -1;
        }
 
        /*
@@ -2231,6 +2243,15 @@ check_for_eol:
        if ((*ptr == '"') || (*ptr == '`') || (*ptr == '\'') || ((*ptr == '&') && (ptr[1] != '=')) ||
            ((*((uint8_t const *) ptr) & 0x80) != 0) || isalpha((uint8_t) *ptr) || isdigit((uint8_t) *ptr)) {
        parse_name2:
+               /*
+                *      Other than "unlang" sections, the second name MUST be alphanumeric
+                */
+               if ((parent->unlang != CF_UNLANG_ALLOW) && !isalpha((uint8_t) *ptr) && !isdigit((uint8_t) *ptr)) {
+                       ERROR("%s[%d]: Parse error: Unexpected text after section name",
+                             frame->filename, frame->lineno);
+                       return -1;
+               }
+
                if (cf_get_token(parent, &ptr, &name2_token, buff[2], stack->bufsize,
                                 frame->filename, frame->lineno) < 0) {
                        return -1;
index a4b331782c62e95b9438b56db2de9620a0f82534..6170bd8fb6ca4c3d90c4701e9dbd7020ca123844 100644 (file)
@@ -22,16 +22,6 @@ policy {
 $INCLUDE policy.conf
 }
 
-instantiate {
-       #
-       #  Just check that this can be referred to as "virtual_instantiate.post-auth"
-       #
-       load-balance virtual_instantiate {
-               ok
-               updated
-       }
-}
-
 #
 #  Virtual server for the DHCPv4 protocol.
 #
index f5ca12be81a3d11c4f94bd72d78ab211676bd7b8..1896beb315f0e0b7f2a73505561cbb15dc5a2e08 100644 (file)
@@ -22,16 +22,6 @@ policy {
 $INCLUDE policy.conf
 }
 
-instantiate {
-       #
-       #  Just check that this can be referred to as "virtual_instantiate.post-auth"
-       #
-       load-balance virtual_instantiate {
-               ok
-               updated
-       }
-}
-
 #
 #  Virtual server for the DHCPv6 protocol.
 #