{ "debug", POLICY_RESERVED_DEBUG },
{ "print", POLICY_RESERVED_PRINT },
{ "policy", POLICY_RESERVED_POLICY },
- { "call", POLICY_RESERVED_CALL },
{ "control", POLICY_RESERVED_CONTROL },
{ "request", POLICY_RESERVED_REQUEST },
{ "reply", POLICY_RESERVED_REPLY },
policy_lex_t token;
char mystring[256];
policy_named_t *this;
+ DICT_ATTR *dattr;
tail = tail; /* -Wunused */
return 0;
}
+ dattr = dict_attrbyname(mystring);
+ if (dattr) {
+ fprintf(stderr, "%s[%d]: Invalid policy name \"%s\": it is already defined as a dictionary attribute\n",
+ lexer->filename, lexer->lineno, mystring);
+ rlm_policy_free_item((policy_item_t *) this);
+ return 0;
+ }
+
rcode = parse_block(lexer, &(this->policy));
if (!rcode) {
rlm_policy_free_item((policy_item_t *) this);
/*
* Parse a reference to a named policy "call foo"
*/
-static int parse_call(policy_lex_file_t *lexer, policy_item_t **tail)
+static int parse_call(policy_lex_file_t *lexer, policy_item_t **tail,
+ const char *name)
{
policy_lex_t token;
- char mystring[256];
policy_call_t *this;
debug_tokens("[CALL] ");
- this = rad_malloc(sizeof(*this));
- memset(this, 0, sizeof(*this));
-
- this->item.type = POLICY_TYPE_CALL;
- this->item.lineno = lexer->lineno;
+ token = policy_lex_file(lexer, 0, NULL, 0);
+ if (token != POLICY_LEX_L_BRACKET) {
+ fprintf(stderr, "%s[%d]: Expected left bracket, got \"%s\"\n",
+ lexer->filename, lexer->lineno,
+ lrad_int2str(rlm_policy_tokens, token, "?"));
+ return 0;
+ }
- token = policy_lex_file(lexer, 0, mystring, sizeof(mystring));
- if (token != POLICY_LEX_BARE_WORD) {
- fprintf(stderr, "%s[%d]: Expected policy name, got \"%s\"\n",
+ token = policy_lex_file(lexer, 0, NULL, 0);
+ if (token != POLICY_LEX_R_BRACKET) {
+ fprintf(stderr, "%s[%d]: Expected right bracket, got \"%s\"\n",
lexer->filename, lexer->lineno,
lrad_int2str(rlm_policy_tokens, token, "?"));
- rlm_policy_free_item((policy_item_t *) this);
return 0;
}
- this->name = strdup(mystring);
+ this = rad_malloc(sizeof(*this));
+ memset(this, 0, sizeof(*this));
+
+ this->item.type = POLICY_TYPE_CALL;
+ this->item.lineno = lexer->lineno;
+
+ this->name = strdup(name);
*tail = (policy_item_t *) this;
return 0;
break;
- case POLICY_RESERVED_CALL:
- if (parse_call(lexer, tail)) {
- return 1;
+ case POLICY_RESERVED_UNKNOWN: /* wasn't a reserved word */
+ if (rlm_policy_find(lexer->policies, lhs)) {
+ if (parse_call(lexer, tail, lhs)) {
+ return 1;
+ }
}
- return 0;
- break;
- case POLICY_RESERVED_UNKNOWN: /* wasn't a reserved word */
/*
* Maybe include another file.
*/