]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add parent map to map_afrom_cp()
authorAlan T. DeKok <aland@freeradius.org>
Tue, 18 May 2021 17:15:26 +0000 (13:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 18 May 2021 17:15:26 +0000 (13:15 -0400)
this function is only called by map.c, so it could likely be
private to that file.

src/lib/server/map.c
src/lib/server/map.h

index d445f1b13141a1ea1402e37e8fb30a9a127867bc..70a8e754319f9f5583ddaccc14c3401fe15d7572 100644 (file)
@@ -80,6 +80,7 @@ static inline map_t *map_alloc(TALLOC_CTX *ctx, map_t *parent)
  *
  * @param[in] ctx              for talloc.
  * @param[in] out              Where to write the pointer to the new #map_t.
+ * @param[in] parent           the parent map
  * @param[in] cp               to convert to map.
  * @param[in] lhs_rules                rules for parsing LHS attribute references.
  * @param[in] rhs_rules                rules for parsing RHS attribute references.
@@ -87,7 +88,7 @@ static inline map_t *map_alloc(TALLOC_CTX *ctx, map_t *parent)
  *     - #map_t if successful.
  *     - NULL on error.
  */
-int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, CONF_PAIR *cp,
+int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp,
                 tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules)
 {
        map_t   *map;
@@ -99,7 +100,7 @@ int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, CONF_PAIR *cp,
 
        if (!cp) return -1;
 
-       MEM(map = map_alloc(ctx, NULL));
+       MEM(map = map_alloc(ctx, parent));
        map->op = cf_pair_operator(cp);
        map->ci = cf_pair_to_item(cp);
 
@@ -638,7 +639,7 @@ int map_afrom_cs(TALLOC_CTX *ctx, fr_map_list_t *out, CONF_SECTION *cs,
                cp = cf_item_to_pair(ci);
                fr_assert(cp != NULL);
 
-               if (map_afrom_cp(parent, &map, cp, &our_lhs_rules, rhs_rules) < 0) {
+               if (map_afrom_cp(parent, &map, NULL, cp, &our_lhs_rules, rhs_rules) < 0) {
                        cf_log_err(ci, "Failed creating map from '%s = %s'",
                                   cf_pair_attr(cp), cf_pair_value(cp));
                        goto error;
index 77f9df4b4e503bfe00f9122dc49db6b582390c39..4ae5098c9b24b639dabf358ec8dec0cad97369b9 100644 (file)
@@ -112,7 +112,7 @@ typedef int (*map_validate_t)(map_t *map, void *ctx);
 typedef int (*radius_map_getvalue_t)(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request,
                                     map_t const *map, void *uctx);
 
-int            map_afrom_cp(TALLOC_CTX *ctx, map_t **out, CONF_PAIR *cp,
+int            map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp,
                             tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules);
 
 int            map_afrom_cs(TALLOC_CTX *ctx, fr_map_list_t *out, CONF_SECTION *cs,