From: Arran Cudbard-Bell Date: Tue, 29 Sep 2020 21:21:47 +0000 (-0500) Subject: Log better errors when we fail to resolve attributes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68c2a1894286badaa2ae2ae2456c976376287df2;p=thirdparty%2Ffreeradius-server.git Log better errors when we fail to resolve attributes --- diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index b7c764cdace..1c19cab7a8d 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -1777,7 +1777,7 @@ ssize_t fr_dict_attr_by_name_substr(fr_dict_attr_err_t *err, fr_dict_attr_t cons da = fr_hash_table_finddata(dict->attributes_by_name, &(fr_dict_attr_t){ .name = buffer }); if (!da) { if (err) *err = FR_DICT_ATTR_NOTFOUND; - fr_strerror_printf("Unknown attribute '%s'", buffer); + fr_strerror_printf("Attribute '%s' not found in the %s dictionary", buffer, fr_dict_root(dict)->name); return 0; } @@ -2054,14 +2054,14 @@ inline fr_dict_attr_t *dict_attr_child_by_num(fr_dict_attr_t const *parent, unsi DA_VERIFY(parent); - if (!parent->children) return NULL; - /* * We return the child of the referenced attribute, and * not of the "group" attribute. */ if (parent->type == FR_TYPE_GROUP) parent = parent->ref; + if (!parent->children) return NULL; + /* * Child arrays may be trimmed back to save memory. * Check that so we don't SEGV. @@ -2109,23 +2109,25 @@ ssize_t fr_dict_attr_child_by_name_substr(fr_dict_attr_err_t *err, DA_VERIFY(parent); - if (!parent->children) { - if (err) *err = FR_DICT_ATTR_NO_CHILDREN; - return 0; - } - /* * We return the child of the referenced attribute, and * not of the "group" attribute. */ if (parent->type == FR_TYPE_GROUP) parent = parent->ref; + if (!parent->children) { + fr_strerror_printf("%s has no children", parent->name); + if (err) *err = FR_DICT_ATTR_NO_CHILDREN; + return 0; + } + slen = fr_dict_attr_by_name_substr(err, out, fr_dict_by_da(parent), name); if (slen <= 0) return slen; if (is_direct_decendent) { if ((*out)->parent != parent) { not_decendent: + fr_strerror_printf("%s is not a descendent of %s", parent->name, (*out)->name); if (err) *err = FR_DICT_ATTR_NOT_DESCENDENT; *out = NULL; return 0;