]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
force flatten unless migration flags are set
authorAlan T. DeKok <aland@freeradius.org>
Mon, 21 Aug 2023 16:22:39 +0000 (12:22 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 21 Aug 2023 16:22:39 +0000 (12:22 -0400)
this means we can safely update all of the decoders to create
nested attributes

raddb/radiusd.conf.in
src/lib/server/main_config.c

index 4fad44caf83a262f442966f8099123192942ffa3..382236e536f05af1ad2807b1a9b36f7d4b931902 100644 (file)
@@ -597,6 +597,19 @@ global {
 #  `-S flag=value`.
 #
 migrate {
+       #
+       #  flatten_after_decode:: Convert "nested" attribute lists to
+       #  "flat" ones after the protocol decoders have run, but
+       #  before any `unlang` policies are used.
+       #
+       flatten_after_decode = yes
+
+       #
+       #  flatten_before_encode:: Convert "nested" attribute lists to
+       #  "flat" ones before calling the protocol encoders.
+       #
+       flatten_before_encode = yes
+
        #
        #  unflatten_after_decode:: Convert "flat" attribute lists to
        #  "nested" ones after the protocol decoders have run, but
index 8595c962f83da9d69471ac8aca3f0f9886455786..5ac3426af25db505bcaf110b175cb5cc787e63ba 100644 (file)
@@ -191,8 +191,8 @@ static const CONF_PARSER thread_config[] = {
 static const CONF_PARSER migrate_config[] = {
        { FR_CONF_OFFSET("unflatten_after_decode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, unflatten_after_decode) },
        { FR_CONF_OFFSET("unflatten_before_encode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, unflatten_before_encode) },
-       { FR_CONF_OFFSET("flatten_after_decode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, flatten_after_decode) },
-       { FR_CONF_OFFSET("flatten_before_encode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, flatten_before_encode) },
+       { FR_CONF_OFFSET("flatten_after_decode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, flatten_after_decode), .dflt = "yes" },
+       { FR_CONF_OFFSET("flatten_before_encode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, flatten_before_encode), .dflt = "yes" },
        { FR_CONF_OFFSET("tmpl_tokenize_all_nested", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, tmpl_tokenize_all_nested) },
        { FR_CONF_OFFSET("use_new_conditions", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, use_new_conditions) },
        { FR_CONF_OFFSET("rewrite_update", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, rewrite_update) },
@@ -1263,6 +1263,22 @@ do {\
                goto failure;
        }
 
+       /*
+        *      Handle migration.
+        *
+        *      If all of the tmpls are tokenized as nested, then we
+        *      MUST use the new conditions.  The old conditions can't
+        *      handle nested attributes.
+        *
+        *      Similarly, we MUST NOT flatten the attributes after
+        *      decoding, or before encoding.  The code should handle everything correctly.
+        */
+       if (config->tmpl_tokenize_all_nested) {
+               config->use_new_conditions = true;
+               config->flatten_after_decode = false;
+               config->flatten_before_encode = false;
+       }
+
        /*
         *      If there was no log destination set on the command line,
         *      set it now.