From: Alan T. DeKok Date: Sat, 24 Mar 2018 12:15:00 +0000 (-0400) Subject: line number is not order. X-Git-Tag: release_3_0_17~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bee85afcc61;p=thirdparty%2Ffreeradius-server.git line number is not order. 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. --- diff --git a/src/include/tmpl.h b/src/include/tmpl.h index 4392cd12064..92884b186bd 100644 --- a/src/include/tmpl.h +++ b/src/include/tmpl.h @@ -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; diff --git a/src/main/files.c b/src/main/files.c index d6a8c92789e..f1913933572 100644 --- a/src/main/files.c +++ b/src/main/files.c @@ -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; diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index 786b7564176..c825a9230b0 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -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;