CONF_SECTION *parent; //!< which started this file
CONF_SECTION *current; //!< sub-section we're reading
- CONF_SECTION *assignment_only; //!< map / update section
int braces;
bool from_dir; //!< this file was read from $include foo/
/*
* Can't do this inside of update / map.
*/
- if (frame->assignment_only) {
+ if (parent->unlang == CF_UNLANG_ASSIGNMENT) {
ERROR("%s[%d]: Parse error: Invalid location for $INCLUDE",
frame->filename, frame->lineno);
return -1;
frame->required = required;
frame->parent = parent;
frame->current = parent;
- frame->assignment_only = NULL;
/*
* For better debugging.
frame->parent = parent;
frame->current = parent;
frame->filename = talloc_strdup(frame->parent, value);
- frame->assignment_only = NULL;
return 1;
}
(void) fr_heap_insert(&frame->heap, h);
}
closedir(dir);
-
- /*
- * No "$INCLUDE dir/" inside of update / map. That's dumb.
- */
- frame->assignment_only = NULL;
return 1;
}
#else
css->argc++;
}
stack->ptr = ptr;
- frame->assignment_only = css;
+ css->unlang = CF_UNLANG_ASSIGNMENT;
return cf_section_to_item(css);
}
}
stack->ptr = ptr;
- frame->assignment_only = css;
+ css->unlang = CF_UNLANG_ASSIGNMENT;
- css->allow_locals = true;
- css->unlang = CF_UNLANG_ALLOW;
+ css->allow_locals = true;
+ css->unlang = CF_UNLANG_ALLOW;
return cf_section_to_item(css);
}
*/
if (!cf_template_merge(parent, parent->template)) return -1;
- if (parent == frame->assignment_only) frame->assignment_only = NULL;
-
frame->current = cf_item_to_section(parent->item.parent);
ptr++;
cf_lineno_set(css, frame->lineno);
css->name2_quote = name2_token;
- /*
- * Hack for better error messages in
- * nested sections. parent information
- * should really be put into a parser
- * struct, as with tmpls.
- */
- if (!frame->assignment_only && (strcmp(css->name1, "update") == 0)) {
- frame->assignment_only = css;
- }
-
/*
* Only a few top-level sections allow "unlang"
* statements. And for those, "unlang"
css->unlang = CF_UNLANG_EDIT;
}
+ } else if (parent->unlang == CF_UNLANG_ASSIGNMENT) {
+ /*
+ * Do nothing
+ */
+ css->unlang = CF_UNLANG_ASSIGNMENT;
+ css->allow_locals = false;
+
} else {
fr_assert(parent->unlang == CF_UNLANG_NONE);
+
+ /*
+ * Module configuration can contain "update" statements.
+ */
+ if (parent->item.parent &&
+ (cf_item_to_section(parent->item.parent)->unlang == CF_UNLANG_MODULES) &&
+ (strcmp(css->name1, "update") == 0)) {
+ css->unlang = CF_UNLANG_ASSIGNMENT;
+ }
+
+ css->allow_locals = false;
}
add_section:
/*
* As a hack, allow any operators when using &foo=bar
*/
- if (!frame->assignment_only && (buff[1][0] != '&')) {
+ if ((parent->unlang != CF_UNLANG_ASSIGNMENT) && (buff[1][0] != '&')) {
ERROR("%s[%d]: Invalid operator in assignment for %s ...",
frame->filename, frame->lineno, buff[1]);
return -1;
*
* If it's not an "update" section, and it's an "edit" thing, then try to parse an expression.
*/
- if (!frame->assignment_only && ((parent->unlang == CF_UNLANG_EDIT) || (*buff[1] == '&'))) {
+ if ((parent->unlang == CF_UNLANG_EDIT) || (*buff[1] == '&')) {
bool eol;
ssize_t slen;
char const *ptr2 = ptr;
frame->filename = h->filename;
frame->lineno = 0;
frame->from_dir = true;
- frame->assignment_only = NULL; /* can't do includes inside of update / map */
return 1;
}