]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove crap code
authorAlan T. DeKok <aland@freeradius.org>
Fri, 19 Feb 2021 13:44:42 +0000 (08:44 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 19 Feb 2021 13:44:42 +0000 (08:44 -0500)
it makes no sense to look up the parents name in the parent
CONF_PARSER?

Also add the new section to the parent AFTER the callback is done

src/lib/server/cf_util.c

index 02ba180076e0bf8954540055af0d9261cb1b746f..1f7717d82c799eacd32ad915e790382dc6fcc400 100644 (file)
@@ -760,46 +760,8 @@ CONF_SECTION *_cf_section_alloc(TALLOC_CTX *ctx, CONF_SECTION *parent,
                CONF_DATA const *cd;
                CONF_PARSER *rule;
 
-               cs->depth = parent->depth + 1;
-               cf_item_add(parent, &(cs->item));
-
-               cd = cf_data_find(CF_TO_ITEM(parent), CONF_PARSER, cf_section_name1(parent));
-               if (cd) {
-                       rule = cf_data_value(cd);
-
-                       /*
-                        *      The parent has an ON_READ rule.  Check
-                        *      if that rule has a child which matches
-                        *      this section.
-                        */
-                       if ((FR_BASE_TYPE(rule->type) == FR_TYPE_SUBSECTION) &&
-                           ((rule->type & FR_TYPE_ON_READ) != 0) &&
-                           rule->subcs) {
-                               CONF_PARSER const *rule_p;
-
-                               for (rule_p = rule->subcs; rule_p->name; rule_p++) {
-                                       if ((FR_BASE_TYPE(rule_p->type) == FR_TYPE_SUBSECTION) &&
-                                           ((rule_p->type & FR_TYPE_ON_READ) != 0) &&
-                                           (strcmp(rule_p->name, name1) == 0)) {
-                                               if (_cf_section_rule_push(cs, rule_p,
-                                                                         cd->item.filename, cd->item.lineno) < 0) {
-                                               error:
-                                                       talloc_free(cs);
-                                                       return NULL;
-                                               }
-
-                                               if (rule_p->func(ctx, NULL, NULL,
-                                                                cf_section_to_item(cs), rule_p) < 0) goto error;
-                                               return cs;
-                                       }
-                               }
-                       }
-               }
-
                /*
-                *      Call any ON_READ callback.  And push this rule
-                *      to the child section, so that the child can
-                *      pick it up.
+                *      Call any ON_READ callback.
                 */
                cd = cf_data_find(CF_TO_ITEM(parent), CONF_PARSER, name1);
                if (cd) {
@@ -807,10 +769,19 @@ CONF_SECTION *_cf_section_alloc(TALLOC_CTX *ctx, CONF_SECTION *parent,
                        if (rule->func &&
                            (FR_BASE_TYPE(rule->type) == FR_TYPE_SUBSECTION) &&
                            ((rule->type & FR_TYPE_ON_READ) != 0)) {
-                               if (cf_section_rules_push(cs, rule) < 0) goto error;
-                               if (rule->func(ctx, NULL, NULL, cf_section_to_item(cs), rule) < 0) goto error;
+                               if (rule->func(ctx, NULL, NULL, cf_section_to_item(cs), rule) < 0) {
+                                       talloc_free(cs);
+                                       return NULL;
+                               }
                        }
                }
+
+               /*
+                *      Add the item to the parent after all sanity
+                *      checks have been done.
+                */
+               cs->depth = parent->depth + 1;
+               cf_item_add(parent, &(cs->item));
        }
 
        return cs;