From: Arran Cudbard-Bell Date: Wed, 23 Jun 2021 19:40:44 +0000 (-0500) Subject: Add explicit "don't cache" field to virtual_server_compile_t X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=51667a75bc88dd8d4c5ee69d4e82b831c638c635;p=thirdparty%2Ffreeradius-server.git Add explicit "don't cache" field to virtual_server_compile_t don't check that offset is 0, that's a really dumb way of determining if we want to write out the result --- diff --git a/src/lib/server/virtual_servers.c b/src/lib/server/virtual_servers.c index 2c21aa42b6f..1d6affbafa1 100644 --- a/src/lib/server/virtual_servers.c +++ b/src/lib/server/virtual_servers.c @@ -1427,8 +1427,16 @@ rlm_rcode_t virtual_server_process_auth(request_t *request, CONF_SECTION *virtua * * This function walks down the registration table, compiling each * named section. + * + * @parma[in] server to search for sections in. + * @param[in] list of sections to compiler. + * @param[in] rules to apply for pass1. + * @param[in] instance module instance data. The offset value in + * the rules array will be added to this to + * determine where to write pointers to the + * various CONF_SECTIONs. */ -int virtual_server_compile_sections(CONF_SECTION *server, virtual_server_compile_t const *list, tmpl_rules_t const *rules, void *uctx) +int virtual_server_compile_sections(CONF_SECTION *server, virtual_server_compile_t const *list, tmpl_rules_t const *rules, void *instance) { int i, found; CONF_SECTION *subcs = NULL; @@ -1459,8 +1467,8 @@ int virtual_server_compile_sections(CONF_SECTION *server, virtual_server_compile /* * Initialise CONF_SECTION pointer for missing section */ - if ((uctx) && (list[i].offset > 0)) { - *(CONF_SECTION **) (((uint8_t *) uctx) + list[i].offset) = NULL; + if ((instance) && !list[i].dont_cache) { + *(CONF_SECTION **) (((uint8_t *) instance) + list[i].offset) = NULL; } continue; } @@ -1482,12 +1490,12 @@ int virtual_server_compile_sections(CONF_SECTION *server, virtual_server_compile /* * Cache the CONF_SECTION which was found. */ - if (uctx) { - if (list[i].offset > 0) { - *(CONF_SECTION **) (((uint8_t *) uctx) + list[i].offset) = subcs; + if (instance) { + if (!list[i].dont_cache) { + *(CONF_SECTION **) (((uint8_t *) instance) + list[i].offset) = subcs; } if (list[i].instruction > 0) { - *(void **) (((uint8_t *) uctx) + list[i].instruction) = instruction; + *(void **) (((uint8_t *) instance) + list[i].instruction) = instruction; } } diff --git a/src/lib/server/virtual_servers.h b/src/lib/server/virtual_servers.h index 81d505c7d31..003d28fc1ef 100644 --- a/src/lib/server/virtual_servers.h +++ b/src/lib/server/virtual_servers.h @@ -116,6 +116,8 @@ typedef struct { char const *name2; //!< Second name, such as "Access-Request" rlm_components_t component; //!< Sets the default list of actions for this section size_t offset; //!< where the CONF_SECTION pointer is written + bool dont_cache; //!< If true, the CONF_SECTION pointer won't be written + ///< and the offset will be ignored. size_t instruction; //!< where the instruction pointer is written virtual_server_method_t const *methods; //!< list of module methods which are allowed in this section } virtual_server_compile_t; @@ -125,7 +127,7 @@ typedef struct { int virtual_server_section_register(virtual_server_compile_t const *entry) CC_HINT(nonnull); int virtual_server_compile_sections(CONF_SECTION *server, virtual_server_compile_t const *list, - tmpl_rules_t const *rules, void *uctx) CC_HINT(nonnull(1,2,3)); + tmpl_rules_t const *rules, void *instance) CC_HINT(nonnull(1,2,3)); virtual_server_method_t const *virtual_server_section_methods(char const *name1, char const *name2) CC_HINT(nonnull(1));