Ignore subsections which statically evaluate to "false"
authorAlan T. DeKok <aland@freeradius.org>
Wed, 15 May 2013 14:13:33 +0000 (10:13 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 15 May 2013 14:13:33 +0000 (10:13 -0400)
So that large swaths of the configuration can be taken out
of the configuration with zero run-time memory or CPU impact

src/main/modules.c

index 33d1138..6dd8476 100644 (file)
@@ -27,6 +27,7 @@ RCSID("$Id$")
 #include <freeradius-devel/radiusd.h>
 #include <freeradius-devel/modpriv.h>
 #include <freeradius-devel/modcall.h>
+#include <freeradius-devel/parser.h>
 #include <freeradius-devel/rad_assert.h>
 
 extern int check_config;
@@ -878,6 +879,21 @@ static int load_component_section(CONF_SECTION *cs,
 
                        cp = NULL;
 
+                       if ((strcmp(name1, "if") == 0) ||
+                           (strcmp(name1, "elsif") == 0)) {
+                               fr_cond_t const *c;
+
+                               c = cf_data_find(scs, "if");
+                               if (!c) continue;
+
+                               if (c->type == COND_TYPE_FALSE) {
+                                       DEBUG(" # Skipping contents of '%s' at %s:%d as it statically evaluates to 'false'",
+                                            name1, cf_section_filename(scs), cf_section_lineno(scs));
+                                       continue;
+                               }
+                       }
+
+
                } else if (cf_item_is_pair(modref)) {
                        cp = cf_itemtopair(modref);