]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow policies to refer to modules of the same name
authorAlan T. DeKok <aland@freeradius.org>
Mon, 13 Jun 2011 09:31:47 +0000 (11:31 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 13 Jun 2011 09:33:57 +0000 (11:33 +0200)
policy {
files {
files
...

}
}

Means that you can over-ride the behavior of the "files" module,
and add anything else you need.

src/include/conffile.h
src/main/conffile.c
src/main/modcall.c

index 9baca4f8f68a6afb299effcc75d4b7d92d77ec12..cc9eb4f6c2fabee1611a07c0e0598180f455dc59 100644 (file)
@@ -92,6 +92,7 @@ int cf_pair_lineno(CONF_PAIR *pair);
 const char *cf_pair_filename(CONF_PAIR *pair);
 const char *cf_section_filename(CONF_SECTION *section);
 CONF_ITEM *cf_item_find_next(CONF_SECTION *section, CONF_ITEM *item);
+CONF_SECTION *cf_item_parent(CONF_ITEM *ci);
 int cf_item_is_section(CONF_ITEM *item);
 int cf_item_is_pair(CONF_ITEM *item);
 CONF_PAIR *cf_itemtopair(CONF_ITEM *item);
index 2d827fcec9f1aae8fea3beabb0a4c45d16ae87af..cb9a8a9bcc77efdbedf9b647fe585b3fbb062bbb 100644 (file)
@@ -2183,6 +2183,13 @@ CONF_ITEM *cf_item_find_next(CONF_SECTION *section, CONF_ITEM *item)
        }
 }
 
+CONF_SECTION *cf_item_parent(CONF_ITEM *ci)
+{
+       if (!ci) return NULL;
+
+       return ci->parent;
+}
+
 int cf_section_lineno(CONF_SECTION *section)
 {
        return cf_sectiontoitem(section)->lineno;
index 0fecc7f3cf82444d71c224a1b07a83379142f959..3585b5f334a4b3f2bc0ffc73fc355a181e1bf8ff 100644 (file)
@@ -1982,6 +1982,7 @@ static modcallable *do_compile_modsingle(modcallable *parent,
                 *      codes.
                 */
        } else {
+               CONF_SECTION *loop;
                CONF_PAIR *cp = cf_itemtopair(ci);
                modrefname = cf_pair_attr(cp);
 
@@ -2013,6 +2014,20 @@ static modcallable *do_compile_modsingle(modcallable *parent,
                        if (cs) subcs = cf_section_sub_find_name2(cs, NULL,
                                                                  modrefname);
                }
+
+               /*
+                *      Allow policies to over-ride module names.
+                *      i.e. the "sql" policy can do some extra things,
+                *      and then call the "sql" module.
+                */
+               for (loop = cf_item_parent(ci);
+                    loop && subcs;
+                    loop = cf_item_parent(cf_sectiontoitem(loop))) {
+                       if (loop == subcs) {
+                               subcs = NULL;
+                       }
+               }
+
                if (subcs) {
                        DEBUG2(" Module: Loading virtual module %s",
                               modrefname);