]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow for partially parsed sections
authorAlan T. DeKok <aland@freeradius.org>
Wed, 17 May 2017 20:47:18 +0000 (16:47 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 17 May 2017 21:01:57 +0000 (17:01 -0400)
where it doesn't print out the final }, until the caller
parses more sub-sections, and then calls cf_parse_section()
again, with variables=NULL

src/include/conf_file.h
src/main/conf_file.c

index 742430f039077e748ea3026e3248fec00786145e..29a12a0dbcd0cff2bcb2cbb7dd69d5c6d0ba1f26 100644 (file)
@@ -423,6 +423,9 @@ typedef struct CONF_PARSER {
 #define CONF_PARSER_TERMINATOR { .name = NULL, .type = ~(UINT32_MAX - 1), \
                                  .offset = 0, .data = NULL, .dflt = NULL, .quote = T_INVALID }
 
+#define CONF_PARSER_PARTIAL_TERMINATOR { .name = NULL, .type = ~(UINT32_MAX - 1), \
+                                         .offset = 1, .data = NULL, .dflt = NULL, .quote = T_INVALID }
+
 typedef int (*cf_walker_t)(void *data, void *ctx);
 
 void           cf_file_check_user(uid_t uid, gid_t gid);
index cec3cd2a170ea4f47b2e79ead3d50be3785a78f5..6640125664aef4920dce43fdacd62f366f275ebd 100644 (file)
@@ -2472,6 +2472,14 @@ int cf_section_parse(TALLOC_CTX *ctx, void *base, CONF_SECTION *cs, CONF_PARSER
        void    *data;
        bool    *is_set = NULL;
 
+       /*
+        *      Hack for partially parsed sections.
+        */
+       if (!variables) {
+               cf_log_info(cs, "%.*s}", cs->depth, parse_spaces);
+               return 0;
+       }
+
        cs->variables = variables; /* this doesn't hurt anything */
 
        if (!cs->name2) {
@@ -2548,14 +2556,21 @@ int cf_section_parse(TALLOC_CTX *ctx, void *base, CONF_SECTION *cs, CONF_PARSER
         */
        rad_cond_assert(variables[i].type == conf_term.type);
 
+       cs->base = base;
+
+       /*
+        *      Hack for partially parsed sections.  We don't print
+        *      out the final "}", that will be printed out when the
+        *      caller re-calls us with 'variable=NULL'.  And, we don't warn about unused
+        */
+       if (variables[i].offset == 1) return ret;
+
        /*
         *      Warn about items in the configuration which weren't
         *      checked during parsing.
         */
        if (rad_debug_lvl >= 3) cf_section_parse_warn(cs);
 
-       cs->base = base;
-
        cf_log_info(cs, "%.*s}", cs->depth, parse_spaces);
 
 finish: