Skip to content

Commit

Permalink
Add PW_TYPE_MULTI
Browse files Browse the repository at this point in the history
For CONF_PAIRs which can exist multiple times in a CONF_SECTION
  • Loading branch information
alandekok committed Sep 23, 2014
1 parent 6de4c77 commit c136883
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/include/conffile.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ typedef struct timeval _timeval_t;
#define PW_TYPE_FILE_OUTPUT ((1 << 15) | PW_TYPE_STRING)

#define PW_TYPE_XLAT (1 << 16) //!< string will be dynamically expanded
#define PW_TYPE_MULTI (1 << 17) //!< CONF_PAIR can have multiple copies

#define FR_INTEGER_COND_CHECK(_name, _var, _cond, _new)\
do {\
Expand Down
10 changes: 10 additions & 0 deletions src/main/conffile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,8 @@ int cf_section_parse_pass2(CONF_SECTION *cs, UNUSED void *base,
if ((variables[i].type & PW_TYPE_XLAT) == 0) continue;

cp = cf_pair_find(cs, variables[i].name);

redo:
if (!cp || !cp->value) continue;

if ((cp->value_type != T_DOUBLE_QUOTED_STRING) &&
Expand Down Expand Up @@ -1505,6 +1507,14 @@ int cf_section_parse_pass2(CONF_SECTION *cs, UNUSED void *base,

talloc_free(value);
talloc_free(xlat);

/*
* If the "multi" flag is set, check all of them.
*/
if ((variables[i].type & PW_TYPE_MULTI) != 0) {
cp = cf_pair_find_next(cs, cp, cp->attr);
goto redo;
}
} /* for all variables in the configuration section */

return 0;
Expand Down

0 comments on commit c136883

Please sign in to comment.