]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add explicit "don't cache" field to virtual_server_compile_t
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 23 Jun 2021 19:40:44 +0000 (14:40 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 24 Jun 2021 00:08:55 +0000 (19:08 -0500)
don't check that offset is 0, that's a really dumb way of determining if we want to write out the result

src/lib/server/virtual_servers.c
src/lib/server/virtual_servers.h

index 2c21aa42b6fe33f15eb3d68813844d3bdcdee831..1d6affbafa1da27f3a9d52742af980cb377c11a1 100644 (file)
@@ -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;
                                }
                        }
 
index 81d505c7d31098ad3588d00fbee13717fba00cee..003d28fc1ef994fa4930793a2627b5d5573f0f10 100644 (file)
@@ -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));