]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
line number is not order.
authorAlan T. DeKok <aland@freeradius.org>
Sat, 24 Mar 2018 12:15:00 +0000 (08:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 24 Mar 2018 12:15:00 +0000 (08:15 -0400)
The "users" file may have multiple $INCLUDES.
We DON'T want a "user" entry at line 266 of "$INCLUDE 1" to conflict
with a "DEFAULT" entry at line 266 of "$INCLUDE 2".

So we add an "order", which tracks the entry number.  The "lineno"
is no longer used for ordering comparisons.  Instead, it's only
used for debugging.

src/include/tmpl.h
src/main/files.c
src/modules/rlm_files/rlm_files.c

index 4392cd12064912ed93affaabda058aaa1ed8c043..92884b186bddef23432c4ad74bd1dc1d10c6466c 100644 (file)
@@ -121,6 +121,7 @@ typedef struct pair_list {
        char const              *name;
        VALUE_PAIR              *check;
        VALUE_PAIR              *reply;
+       int                     order;          /* for ordering! */
        int                     lineno;
        struct pair_list        *next;
 } PAIR_LIST;
index d6a8c92789e5c0f396bf32a48ef5261d022670b0..f191393357214584ff3c3d84f7ef64aa85c880ee 100644 (file)
@@ -88,6 +88,7 @@ int pairlist_read(TALLOC_CTX *ctx, char const *file, PAIR_LIST **list, int compl
        VALUE_PAIR *reply_tmp = NULL;
        PAIR_LIST *pl = NULL, *t;
        PAIR_LIST **last = &pl;
+       int order = 0;
        int lineno = 0;
        int entry_lineno = 0;
        FR_TOKEN parsecode;
@@ -199,8 +200,10 @@ parse_again:
                                 *      of entries.  Go to the end of the
                                 *      list.
                                 */
-                               while (*last)
+                               while (*last) {
+                                       (*last)->order = order++;
                                        last = &((*last)->next);
+                               }
                                continue;
                        } /* $INCLUDE ... */
 
@@ -316,6 +319,7 @@ parse_again:
                t->check = check_tmp;
                t->reply = reply_tmp;
                t->lineno = entry_lineno;
+               t->order = order++;
                check_tmp = NULL;
                reply_tmp = NULL;
 
index 786b75641765eb8344b36614422d97bffd24fe49..c825a9230b01e58b8d8b8f26d49a46b9de9990f9 100644 (file)
@@ -395,7 +395,7 @@ static rlm_rcode_t file_common(rlm_files_t *inst, REQUEST *request, char const *
                        pl = default_pl;
                        default_pl = default_pl->next;
 
-               } else if (user_pl->lineno < default_pl->lineno) {
+               } else if (user_pl->order < default_pl->order) {
                        pl = user_pl;
                        user_pl = user_pl->next;