]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove test paircmp, and this paircmp_register_by_name
authorAlan T. DeKok <aland@freeradius.org>
Fri, 25 Aug 2023 14:59:18 +0000 (10:59 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 25 Aug 2023 14:59:18 +0000 (10:59 -0400)
src/lib/server/paircmp.c
src/lib/server/paircmp.h
src/modules/rlm_test/rlm_test.c
src/tests/keywords/if-paircmp
src/tests/keywords/paircmp

index 74c90496e3d84280faa6a1a1d448dfc4ce4ae79d..e6ac3e5d7ad830dd37dd4f916f4934a81f426b93 100644 (file)
@@ -663,56 +663,6 @@ int paircmp_find(fr_dict_attr_t const *da)
        return false;
 }
 
-/** Register a function as compare function
- *
- * @param[in] name             the attribute comparison to register.
- * @param[in] from             the attribute we want to compare with.
- *                             Normally this is the same as attribute.
- *                             If null call the comparison function on
- *                             every attributes in the request if
- *                             first_only is false.
- * @param[in] first_only       will decide if we loop over the request
- *                             attributes or stop on the first one.
- * @param[in] func             comparison function.
- * @param[in] instance         argument to comparison function.
- * @return
- *     - 0 on success
- *     - <0 on error
- */
-int paircmp_register_by_name(char const *name, fr_dict_attr_t const *from,
-                            bool first_only, fr_paircmp_func_t func, void *instance)
-{
-       fr_dict_attr_flags_t    flags;
-       fr_dict_attr_t const    *da;
-
-       memset(&flags, 0, sizeof(flags));
-
-       da = fr_dict_attr_by_name(NULL, fr_dict_root(fr_dict_internal()), name);
-       if (da) {
-               if (paircmp_find(da)) {
-                       fr_strerror_printf_push("Cannot register two comparions for attribute %s",
-                                               name);
-                       return -1;
-               }
-       } else if (from) {
-               if (fr_dict_attr_add(fr_dict_unconst(fr_dict_internal()), fr_dict_root(fr_dict_internal()),
-                                    name, -1, from->type, &flags) < 0) {
-                       fr_strerror_printf_push("Failed creating attribute '%s'", name);
-                       return -1;
-               }
-
-               da = fr_dict_attr_by_name(NULL, fr_dict_root(fr_dict_internal()), name);
-               if (!da) {
-                       fr_strerror_printf("Failed finding attribute '%s'", name);
-                       return -1;
-               }
-
-               DEBUG("Creating attribute %s", name);
-       }
-
-       return paircmp_register(da, from, first_only, func, instance);
-}
-
 /** Register a function as compare function.
  *
  * @param[in] da               to register comparison function for.
index 7e14e77766683423da2f6e2c56ce66a6b52b8433..9c6867f4390fdbebfe38d222beac4af5ce08f0f8 100644 (file)
@@ -45,9 +45,6 @@ int           paircmp_virtual(request_t *request, fr_dict_attr_t const *da, fr_token_t op
 
 int            paircmp_find(fr_dict_attr_t const *da);
 
-int            paircmp_register_by_name(char const *name, fr_dict_attr_t const *from,
-                                        bool first_only, fr_paircmp_func_t func, void *instance);
-
 int            paircmp_register(fr_dict_attr_t const *attribute, fr_dict_attr_t const *from,
                                 bool first_only, fr_paircmp_func_t func, void *instance);
 
index f85765d7814e159fb542dc8775a0e7ef33e1db0a..49c7042258bf53e7b6e18d2259f4c074487f713f 100644 (file)
@@ -193,16 +193,6 @@ fr_dict_attr_autoload_t rlm_test_dict_attr[] = {
        { NULL }
 };
 
-static int rlm_test_cmp(UNUSED void *instance, request_t *request, fr_pair_t const *check)
-{
-       fr_assert(check->vp_type == FR_TYPE_STRING);
-
-       RINFO("Test-Paircmp called with \"%pV\"", &check->data);
-
-       if (strcmp(check->vp_strvalue, "yes") == 0) return 0;
-       return 1;
-}
-
 /*
  *     Find the named user in this modules database.  Create the set
  *     of attribute-value pairs to check and reply with for this user
@@ -449,14 +439,6 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        rlm_test_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_test_t);
        xlat_t *xlat;
 
-       if (!cf_section_name2(mctx->inst->conf)) {
-               if (paircmp_register_by_name("Test-Paircmp", attr_user_name, false,
-                                            rlm_test_cmp, inst) < 0) {
-                       PERROR("Failed registering \"Test-Paircmp\"");
-                       return -1;
-               }
-       }
-
        /*
         *      Log some messages
         */
index 1a1ede5b405013cb871eeb63222382141d1bc464..f393690d95a0cf424071287e94c0d1cdd0d14ddc 100644 (file)
@@ -1,20 +1,11 @@
 #
-# PRE: update if
+# PRE: update if paircmp
 #
-
-#
-#  Paircmp
-#
-
-#
-#  Passing 'yes' causes the test paircmp to return match
-#  Passing 'no' causes the test paircmp to return a non-match
-#
-if (!(&Test-Paircmp == 'yes')) {
+if (!(&Packet-Src-IP-Address == 127.0.0.1)) {
        test_fail
 }
 
-if (&Test-Paircmp == 'no') {
+if (&Packet-Src-IP-Address == 127.0.0.2) {
        test_fail
 }
 
index 8c8cef0904d9e4739966b5281044fdb10c4e8ab0..451f6447f4b5791c3942d0131ea3bc61a9d28b13 100644 (file)
@@ -2,26 +2,21 @@
 #  PRE: if update
 #
 update request {
-       &NAS-Identifier = "yes"
+       &NAS-IP-Address := 127.0.0.1
 }
 
 #
 #  test raw values
 #
-if (&Test-Paircmp == 'yes') {
-       success
-
-}
-else {
+if !(&Packet-Src-IP-Address == 127.0.0.1) {
        test_fail
 }
 
 #
 #  test inter-attribute comparisons
 #
-if (&Test-Paircmp == &NAS-Identifier) {
-       success
-}
-else {
+if !(&Packet-Src-IP-Address == &NAS-IP-Address) {
        test_fail
 }
+
+success