]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow dots in policy / module names. Fixes #1237
authorAlan T. DeKok <aland@freeradius.org>
Tue, 15 Sep 2015 13:22:38 +0000 (09:22 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 15 Sep 2015 13:22:38 +0000 (09:22 -0400)
src/main/modcall.c
src/tests/keywords/radiusd.conf
src/tests/keywords/with_dots [new file with mode: 0644]

index ac6b4b6618b23921ea14f481f1db6c3ace06285d..0cc3f1eb3516160389d5fba26daca86f71ff5366 100644 (file)
@@ -2153,7 +2153,7 @@ static int all_children_are_modules(CONF_SECTION *cs, char const *name)
  *     If it's "foo.method", look for "foo", and return "method" as the method
  *     we wish to use, instead of the input component.
  */
-static CONF_SECTION *virtual_module_find_cs(char const *virtual_name, char const *method_name,
+static CONF_SECTION *virtual_module_find_cs(char const *real_name, char const *virtual_name, char const *method_name,
                                            rlm_components_t *pcomponent)
 {
        CONF_SECTION *cs, *subcs;
@@ -2170,9 +2170,12 @@ static CONF_SECTION *virtual_module_find_cs(char const *virtual_name, char const
                        if (strcmp(comp2str[i], method_name) == 0) break;
                }
 
-               if (i == MOD_COUNT) return NULL;
-
-               method = i;
+               if (i != MOD_COUNT) {
+                       method = i;
+               } else {
+                       method_name = NULL;
+                       virtual_name = real_name;
+               }
        }
 
        /*
@@ -2511,14 +2514,14 @@ static modcallable *do_compile_modsingle(modcallable *parent,
        subcs = NULL;
        p = strrchr(modrefname, '.');
        if (!p) {
-               subcs = virtual_module_find_cs(modrefname, NULL, &method);
+               subcs = virtual_module_find_cs(modrefname, modrefname, NULL, &method);
        } else {
                char buffer[256];
 
                strlcpy(buffer, modrefname, sizeof(buffer));
                buffer[p - modrefname] = '\0';
 
-               subcs = virtual_module_find_cs(buffer, buffer + (p - modrefname) + 1, &method);
+               subcs = virtual_module_find_cs(modrefname, buffer, buffer + (p - modrefname) + 1, &method);
        }
 
        /*
index a57d7097c54303f8cb753591e11fc33be7dd9552..3b4521a96ce56032fa51182bf41e8d3eeb60a596 100644 (file)
@@ -88,6 +88,10 @@ policy {
        virtual_policy {
                ok
        }
+
+       with.dots {
+               ok
+       }
 }
 
 instantiate {
diff --git a/src/tests/keywords/with_dots b/src/tests/keywords/with_dots
new file mode 100644 (file)
index 0000000..4fc6b06
--- /dev/null
@@ -0,0 +1,19 @@
+#
+#  PRE: update
+#
+
+#
+#  Ensure that policies can have dots.
+#
+#  The main problem is that conf section references
+#  also have dots in them...
+#
+with.dots
+
+update control {
+       Cleartext-Password := 'hello'
+}
+
+update reply {
+       Filter-Id := "filter"
+}