]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove "op" from fr_pair_make()
authorAlan T. DeKok <aland@freeradius.org>
Fri, 10 Dec 2021 21:25:07 +0000 (16:25 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 10 Dec 2021 21:36:54 +0000 (16:36 -0500)
which was only called from rlm_passwd and rlm_perl.  And those
only used it to append attributes to a list.

Also removed the call to fr_pair_mark_xlat() from fr_pair_make()
Neither module used that functionality

src/lib/util/pair_legacy.c
src/lib/util/pair_legacy.h
src/lib/util/pair_legacy_tests.c
src/modules/rlm_passwd/rlm_passwd.c
src/modules/rlm_perl/rlm_perl.c

index 9a46eaf5a15ccf9c91cb27250d09439d12813736..846994fd634deb3825b8e6e9486742b0d83e6c54 100644 (file)
@@ -100,12 +100,10 @@ int fr_pair_mark_xlat(fr_pair_t *vp, char const *value)
  * @param dict to user for partial resolution.
  * @param attribute name to parse.
  * @param value to parse (must be a hex string).
- * @param op to assign to new valuepair.
  * @return new #fr_pair_t or NULL on error.
  */
 static fr_pair_t *fr_pair_make_unknown(TALLOC_CTX *ctx, fr_dict_t const *dict,
-                                       char const *attribute, char const *value,
-                                       fr_token_t op)
+                                       char const *attribute, char const *value)
 {
        fr_pair_t               *vp;
        fr_dict_attr_t          *n;
@@ -139,7 +137,7 @@ static fr_pair_t *fr_pair_make_unknown(TALLOC_CTX *ctx, fr_dict_t const *dict,
 
        if (fr_pair_value_from_str(vp, value, strlen(value), &fr_value_unescape_double, false) < 0) goto error;
 
-       vp->op = (op == 0) ? T_OP_EQ : op;
+       vp->op = T_OP_EQ;
        return vp;
 }
 
@@ -155,11 +153,10 @@ static fr_pair_t *fr_pair_make_unknown(TALLOC_CTX *ctx, fr_dict_t const *dict,
  * @param[in] vps      list where the attribute will be added (optional)
  * @param[in] attribute        name.
  * @param[in] value    attribute value (may be NULL if value will be set later).
- * @param[in] op       to assign to new #fr_pair_t.
  * @return a new #fr_pair_t.
  */
 fr_pair_t *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t *vps,
-                       char const *attribute, char const *value, fr_token_t op)
+                       char const *attribute, char const *value)
 {
        fr_dict_attr_t const    *da;
        fr_pair_t               *vp;
@@ -171,7 +168,7 @@ fr_pair_t *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t *
         */
        da = fr_dict_attr_search_by_qualified_oid(NULL, dict, attrname, true, true);
        if (!da) {
-               vp = fr_pair_make_unknown(ctx, dict, attrname, value, op);
+               vp = fr_pair_make_unknown(ctx, dict, attrname, value);
                if (!vp) return NULL;
 
                if (vps) fr_pair_append(vps, vp);
@@ -185,60 +182,7 @@ fr_pair_t *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t *
 
        vp = fr_pair_afrom_da(ctx, da);
        if (!vp) return NULL;
-       vp->op = (op == 0) ? T_OP_EQ : op;
-
-       switch (vp->op) {
-       case T_OP_CMP_TRUE:
-       case T_OP_CMP_FALSE:
-               fr_pair_value_clear(vp);
-               value = NULL;   /* ignore it! */
-               break;
-
-               /*
-                *      Regular expression comparison of integer attributes
-                *      does a STRING comparison of the names of their
-                *      integer attributes.
-                */
-       case T_OP_REG_EQ:       /* =~ */
-       case T_OP_REG_NE:       /* !~ */
-       {
-#ifndef HAVE_REGEX
-               fr_strerror_const("Regular expressions are not supported");
-               return NULL;
-#else
-               ssize_t slen;
-               regex_t *preg;
-
-               /*
-                *      Someone else will fill in the value.
-                */
-               if (!value) break;
-
-               talloc_free(vp);
-
-               slen = regex_compile(ctx, &preg, value, strlen(value), NULL, false, true);
-               if (slen <= 0) {
-                       fr_strerror_printf_push("Error at offset %zu compiling regex for %s", -slen, attribute);
-                       return NULL;
-               }
-               talloc_free(preg);
-
-               vp = fr_pair_afrom_da(ctx, da);
-               if (!vp) return NULL;
-               vp->op = op;
-
-               if (fr_pair_mark_xlat(vp, value) < 0) {
-                       talloc_free(vp);
-                       return NULL;
-               }
-
-               value = NULL;   /* ignore it */
-               break;
-#endif
-       }
-       default:
-               break;
-       }
+       vp->op = T_OP_EQ;
 
        /*
         *      We probably want to fix fr_pair_value_from_str to accept
index 468a348b3ebeeb5d73d3e1e36ee1efe3e271bb8b..0afb5bcda95173ce895d1f17439e7035a05f9fd5 100644 (file)
@@ -35,7 +35,7 @@ extern "C" {
 #endif
 
 fr_pair_t      *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict,
-                             fr_pair_list_t *vps, char const *attribute, char const *value, fr_token_t op);
+                             fr_pair_list_t *vps, char const *attribute, char const *value);
 
 int            fr_pair_mark_xlat(fr_pair_t *vp, char const *value);
 
index 966f04d52a7eda16b2841a38720c93297d6fd501..1b75e641a3017c27ce3e21ff0229c8db1d58e8d7 100644 (file)
@@ -92,7 +92,7 @@ static void test_fr_pair_make(void)
        fr_pair_list_init(&list);
 
        TEST_CASE("Creating 'vp' using fr_pair_make()");
-       TEST_CHECK((vp = fr_pair_make(ctx, test_dict, &list, "Test-String-0", test_string, T_DOUBLE_QUOTED_STRING)) != NULL);
+       TEST_CHECK((vp = fr_pair_make(ctx, test_dict, &list, "Test-String-0", test_string)) != NULL);
 
        TEST_CASE("Validating PAIR_VERIFY()");
        PAIR_VERIFY(vp);
index 5625a54f4c8ababf9bdb5524dfc25ae28dd920fd..65a83e9a2e89e53eb4301c878159101e5f2322db 100644 (file)
@@ -524,7 +524,7 @@ static void result_add(TALLOC_CTX *ctx, rlm_passwd_t const *inst, request_t *req
                    (i != inst->key_field) && inst->pwd_fmt->listflag[i] == when) {
                        if (!inst->ignore_empty || pw->field[i][0] != 0 ) { /* if value in key/value pair is not empty */
                                vp = fr_pair_make(ctx, request->dict,
-                                                 vps, inst->pwd_fmt->field[i], pw->field[i], T_OP_EQ);
+                                                 vps, inst->pwd_fmt->field[i], pw->field[i]);
                                if (vp) {
                                        RDEBUG2("Added %s: '%s' to %s ", inst->pwd_fmt->field[i], pw->field[i], listname);
                                }
index df67088f7e99b5928f0a2118718c62652247df93..5b65d226fd5e2592d7cb0008eea147481f5aef3d 100644 (file)
@@ -738,7 +738,7 @@ static void perl_store_vps(UNUSED TALLOC_CTX *ctx, request_t *request, fr_pair_l
  *     Value Pair Format
  *
  */
-static int pairadd_sv(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vps, char *key, SV *sv, fr_token_t op,
+static int pairadd_sv(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vps, char *key, SV *sv,
                      const char *hash_name, const char *list_name)
 {
        char            *val;
@@ -748,11 +748,10 @@ static int pairadd_sv(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vps,
        if (!SvOK(sv)) return -1;
 
        val = SvPV(sv, len);
-       vp = fr_pair_make(ctx, request->dict, vps, key, NULL, op);
+       vp = fr_pair_make(ctx, request->dict, vps, key, NULL);
        if (!vp) {
        fail:
-               REDEBUG("Failed to create pair %s.%s %s %s", list_name, key,
-                       fr_table_str_by_value(fr_tokens_table, op, "<INVALID>"), val);
+               REDEBUG("Failed to create pair %s.%s = %s", list_name, key, val);
                return -1;
        }
 
@@ -771,8 +770,7 @@ static int pairadd_sv(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vps,
 
        PAIR_VERIFY(vp);
 
-       RDEBUG2("&%s.%s %s $%s{'%s'} -> '%s'", list_name, key, fr_table_str_by_value(fr_tokens_table, op, "<INVALID>"),
-               hash_name, key, val);
+       RDEBUG2("&%s.%s = $%s{'%s'} -> '%s'", list_name, key, hash_name, key, val);
        return 0;
 }
 
@@ -795,9 +793,9 @@ static int get_hv_content(TALLOC_CTX *ctx, request_t *request, HV *my_hv, fr_pai
                        len = av_len(av);
                        for (j = 0; j <= len; j++) {
                                av_sv = av_fetch(av, j, 0);
-                               ret = pairadd_sv(ctx, request, vps, key, *av_sv, T_OP_ADD_EQ, hash_name, list_name) + ret;
+                               ret = pairadd_sv(ctx, request, vps, key, *av_sv, hash_name, list_name) + ret;
                        }
-               } else ret = pairadd_sv(ctx, request, vps, key, res_sv, T_OP_EQ, hash_name, list_name) + ret;
+               } else ret = pairadd_sv(ctx, request, vps, key, res_sv, hash_name, list_name) + ret;
        }
 
        if (!fr_pair_list_empty(vps)) PAIR_LIST_VERIFY(vps);