]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add parent to map_afrom_substr()
authorAlan T. DeKok <aland@freeradius.org>
Tue, 18 May 2021 17:28:49 +0000 (13:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 18 May 2021 17:28:49 +0000 (13:28 -0400)
the other functions don't seem to need parents.

The next step is to support relative attributes, and make "parent"
a "map_t **", so that the parsing can walk back up (or down)
the map stack, in order to place the maps in the correct place

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

index 7247caa253e5163da3cd271a00b8b6a0505139e7..fde2a567159a67d7d5b5e7ff383e09b11f1a9b13 100644 (file)
@@ -286,7 +286,8 @@ fr_sbuff_parse_rules_t const *map_parse_rules_quoted[T_TOKEN_LAST] = {
  *
  * @param[in] ctx              for talloc.
  * @param[in] out              Where to write the pointer to the new #map_t.
- * @param[in] in               to convert to map.
+ * @param[in] parent           the parent map
+ * @param[in] in               the data to parse for creating the map.
  * @param[in] op_table         for lhs OP rhs
  * @param[in] op_table_len     length of op_table
  * @param[in] lhs_rules                rules for parsing LHS attribute references.
@@ -297,7 +298,7 @@ fr_sbuff_parse_rules_t const *map_parse_rules_quoted[T_TOKEN_LAST] = {
  *     - >0 on success.
  *     - <=0 on error.
  */
-ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in,
+ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t *parent, fr_sbuff_t *in,
                         fr_table_num_sorted_t const *op_table, size_t op_table_len,
                         tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules,
                         fr_sbuff_parse_rules_t const *p_rules)
@@ -310,7 +311,7 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in,
        fr_sbuff_term_t const   *tt = p_rules ? p_rules->terminals : NULL;
 
        *out = NULL;
-       MEM(map = map_alloc(ctx, NULL));
+       MEM(map = map_alloc(ctx, parent));
 
        (void)fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, tt);
 
@@ -753,7 +754,7 @@ int map_afrom_attr_str(TALLOC_CTX *ctx, map_t **out, char const *vp_str,
 {
        fr_sbuff_t sbuff = FR_SBUFF_IN(vp_str, strlen(vp_str));
 
-       if (map_afrom_substr(ctx, out, &sbuff, map_assignment_op_table, map_assignment_op_table_len,
+       if (map_afrom_substr(ctx, out, NULL, &sbuff, map_assignment_op_table, map_assignment_op_table_len,
                            lhs_rules, rhs_rules, NULL) < 0) {
                return -1;
        }
index 4ae5098c9b24b639dabf358ec8dec0cad97369b9..58baa3f5a174d26b57a41f820a63de3bb12e3c88 100644 (file)
@@ -130,7 +130,7 @@ int         map_afrom_attr_str(TALLOC_CTX *ctx, map_t **out, char const *raw,
 int            map_afrom_vp(TALLOC_CTX *ctx, map_t **out, fr_pair_t *vp,
                             tmpl_rules_t const *rules);
 
-ssize_t                map_afrom_substr(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in,
+ssize_t                map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t *parent, fr_sbuff_t *in,
                                fr_table_num_sorted_t const *op_table, size_t op_table_len,
                                tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules,
                                fr_sbuff_parse_rules_t const *p_rules);
index 9699e835ec868ccfe1564640cf0e6acdbb995ccc..4a780c7bf7b3664f1658b59e8767e2e81b8faa2d 100644 (file)
@@ -398,7 +398,7 @@ check_item:
                /*
                 *      Try to parse the check item.
                 */
-               slen = map_afrom_substr(t, &new_map, &sbuff, check_cmp_op_table, check_cmp_op_table_len,
+               slen = map_afrom_substr(t, &new_map, NULL, &sbuff, check_cmp_op_table, check_cmp_op_table_len,
                                       &lhs_rules, &rhs_rules, &rhs_term);
                if (!new_map) {
                        ERROR_MARKER_ADJ(&sbuff, slen, fr_strerror());
@@ -588,7 +588,7 @@ next_reply_item:
                 *      lead to here have already checked for those
                 *      cases.
                 */
-               slen = map_afrom_substr(t, &new_map, &sbuff, map_assignment_op_table, map_assignment_op_table_len,
+               slen = map_afrom_substr(t, &new_map, NULL, &sbuff, map_assignment_op_table, map_assignment_op_table_len,
                                       &lhs_rules, &rhs_rules, &rhs_term);
                if (!new_map) {
                        ERROR_MARKER_ADJ(&sbuff, slen, fr_strerror());