Skip to content

Commit

Permalink
Expose tmpl_define_unknown_attr
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Sep 30, 2014
1 parent 4b2d2c2 commit 21aacd1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/include/tmpl.h
Expand Up @@ -237,4 +237,7 @@ int tmpl_copy_vps(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request,
value_pair_tmpl_t const *vpt);

int tmpl_find_vp(VALUE_PAIR **out, REQUEST *request, value_pair_tmpl_t const *vpt);

bool tmpl_define_unknown_attr(value_pair_tmpl_t *vpt);

#endif /* TMPL_H */
21 changes: 21 additions & 0 deletions src/main/tmpl.c
Expand Up @@ -1425,3 +1425,24 @@ int tmpl_find_vp(VALUE_PAIR **out, REQUEST *request, value_pair_tmpl_t const *vp

return err;
}

bool tmpl_define_unknown_attr(value_pair_tmpl_t *vpt)
{
DICT_ATTR const *da;

if (!vpt) return false;

VERIFY_TMPL(vpt);

if ((vpt->type != TMPL_TYPE_ATTR) &&
(vpt->type != TMPL_TYPE_DATA)) {
return true;
}

if (!vpt->tmpl_da->flags.is_unknown) return true;

da = dict_unknown_add(vpt->tmpl_da);
if (!da) return false;
vpt->tmpl_da = da;
return true;
}
15 changes: 15 additions & 0 deletions src/tests/keywords/unknown-name
@@ -0,0 +1,15 @@
#
# PRE: update unknown
#
update control {
Cleartext-Password := 'hello'
}

#
# This delayed binding should result in a parse error
#
if (&User-Name == &Foo-Bar-Baz) { # ERROR
update reply {
Filter-Id += "fail-2"
}
}

0 comments on commit 21aacd1

Please sign in to comment.