From: Alan T. DeKok Date: Mon, 26 Apr 2021 19:26:46 +0000 (-0400) Subject: use fr_htrie_match() API X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9d0474bb0209a445a8cb885ad691dc2e7741848;p=thirdparty%2Ffreeradius-server.git use fr_htrie_match() API When we're rearranging the entries, we want to find entries which are exact matches. We don't want to do prefix lookups. --- diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index ba5d5d7beed..a7c831e84ef 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -294,8 +294,10 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, fr_htrie_t **ptre goto error; } - user_list = fr_htrie_find(tree, &search_list); - + /* + * Find an exact match, especially for patricia tries. + */ + user_list = fr_htrie_match(tree, &search_list); if (!user_list) { user_list = talloc_zero(ctx, PAIR_LIST_LIST); pairlist_list_init(user_list); diff --git a/src/tests/modules/files/prefix b/src/tests/modules/files/prefix index 9c76c7b3ca3..1402f5b69f9 100644 --- a/src/tests/modules/files/prefix +++ b/src/tests/modules/files/prefix @@ -9,4 +9,4 @@ Reply-Message := "10/8 subnet" 10.1.0.0/16 Password.Cleartext == "hello" - Reply-Message := "2nd 10.1/16 subnet" + Reply-Message += "2nd 10.1/16 subnet" diff --git a/src/tests/modules/files/prefix.unlang b/src/tests/modules/files/prefix.unlang index fbd616070ed..89f5eaf87ab 100644 --- a/src/tests/modules/files/prefix.unlang +++ b/src/tests/modules/files/prefix.unlang @@ -4,12 +4,19 @@ update request { subnet -if (&reply.Reply-Message != '10.1/16 subnet') { +if (&reply.Reply-Message[0] != '10.1/16 subnet') { test_fail } else { test_pass } +if (&reply.Reply-Message[1] != "2nd 10.1/16 subnet") { + test_fail +} else { + test_pass +} + + update request { &FreeRADIUS-Client-IP-Prefix := 10.2.3.4/32 } @@ -37,12 +44,6 @@ update reply { subnet -if (&reply.Reply-Message != "2nd 10.1/16 subnet") { - test_fail -} else { - test_pass -} - update request { &FreeRADIUS-Client-IP-Prefix := 192.168.1.1/32 }