radius_parseattr should output errors with fr_strerror_printf (even though it's not...
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 16 Mar 2014 17:59:55 +0000 (17:59 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 16 Mar 2014 17:59:55 +0000 (17:59 +0000)
src/include/libradius.h
src/main/map.c
src/main/modcall.c
src/main/valuepair.c
src/main/xlat.c

index b7d4065..9b07068 100644 (file)
@@ -591,13 +591,11 @@ VALUE_PAIR        *readvp2(TALLOC_CTX *ctx, FILE *fp, bool *pfiledone, char const *errp
 /*
  *     Error functions.
  */
-#ifdef _LIBRADIUS
 void           fr_strerror_printf(char const *, ...)
 #ifdef __GNUC__
                __attribute__ ((format (printf, 1, 2)))
 #endif
 ;
-#endif
 void           fr_perror(char const *, ...)
 #ifdef __GNUC__
                __attribute__ ((format (printf, 1, 2)))
index 43f1cb6..a5860c8 100644 (file)
@@ -76,7 +76,7 @@ int radius_parse_attr(value_pair_tmpl_t *vpt, char const *name, request_refs_t r
        vpt->request = radius_request_name(&p, request_def);
        len = p - name;
        if (vpt->request == REQUEST_UNKNOWN) {
-               ERROR("Invalid request qualifier \"%.*s\"", (int) len, name);
+               fr_strerror_printf("Invalid request qualifier \"%.*s\"", (int) len, name);
                return -1;
        }
        name += len;
@@ -84,7 +84,7 @@ int radius_parse_attr(value_pair_tmpl_t *vpt, char const *name, request_refs_t r
        vpt->list = radius_list_name(&p, list_def);
        if (vpt->list == PAIR_LIST_UNKNOWN) {
                len = p - name;
-               ERROR("Invalid list qualifier \"%.*s\"", (int) len, name);
+               fr_strerror_printf("Invalid list qualifier \"%.*s\"", (int) len, name);
                return -1;
        }
 
@@ -97,7 +97,7 @@ int radius_parse_attr(value_pair_tmpl_t *vpt, char const *name, request_refs_t r
        if (!da) {
                da = dict_attrunknownbyname(p, false);
                if (!da) {
-                       ERROR("Unknown attribute \"%s\"", p);
+                       fr_strerror_printf("Unknown attribute \"%s\"", p);
                        return -1;
                }
        }
@@ -131,6 +131,7 @@ value_pair_tmpl_t *radius_attr2tmpl(TALLOC_CTX *ctx, char const *name,
        copy = talloc_strdup(vpt, name);
 
        if (radius_parse_attr(vpt, copy, request_def, list_def) < 0) {
+               ERROR("%s", fr_strerror());
                radius_tmplfree(&vpt);
                return NULL;
        }
@@ -233,7 +234,7 @@ value_pair_tmpl_t *radius_str2tmpl(TALLOC_CTX *ctx, char const *name, FR_TOKEN t
 }
 
 
-/** Convert strings to value_pair_map_e
+/** Convert strings to value_pair_map_t
  *
  * Treatment of operands depends on quotation, barewords are treated
  * as attribute references, double quoted values are treated as
index 01632bd..8512c68 100644 (file)
@@ -2536,10 +2536,13 @@ static bool pass2_callback(UNUSED void *ctx, fr_cond_t *c)
                value_pair_map_t *old;
                value_pair_tmpl_t vpt;
 
+               old = c->data.map;
+
                /*
                 *      It's still not an attribute.  Ignore it.
                 */
                if (radius_parse_attr(&vpt, map->dst->name, REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
+                       cf_log_err(old->ci, "Failed parsing condition: %s", fr_strerror());
                        c->pass2_fixup = PASS2_FIXUP_NONE;
                        return true;
                }
@@ -2547,7 +2550,6 @@ static bool pass2_callback(UNUSED void *ctx, fr_cond_t *c)
                /*
                 *      Re-parse the LHS as an attribute.
                 */
-               old = c->data.map;
                map = radius_str2map(c, old->dst->name, T_BARE_WORD, old->op,
                                     old->src->name, T_BARE_WORD,
                                     REQUEST_CURRENT, PAIR_LIST_REQUEST,
index 9929c8c..abfad29 100644 (file)
@@ -1440,6 +1440,7 @@ int radius_get_vp(VALUE_PAIR **vp_p, REQUEST *request, char const *name)
        *vp_p = NULL;
 
        if (radius_parse_attr(&vpt, name, REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
+               RDEBUG("%s", fr_strerror());
                return -1;
        }
 
index 1f83712..32a6e49 100644 (file)
@@ -316,6 +316,7 @@ static ssize_t xlat_debug_attr(UNUSED void *instance, REQUEST *request, char con
        if (*fmt == '&') fmt++;
 
        if (radius_parse_attr(&vpt, fmt, REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
+               RDEBUG("%s", fr_strerror());
                return -1;
        }