]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add and use "ignore default" flag
authorAlan T. DeKok <aland@freeradius.org>
Fri, 16 Feb 2024 13:23:09 +0000 (08:23 -0500)
committerMatthew Newton <matthew-git@newtoncomputing.co.uk>
Mon, 8 Jul 2024 19:38:14 +0000 (20:38 +0100)
which means that if the configuration item is missing, we do not
set the value from the default.

This change allows the value to be set before the configuration
file is parsed, and then only changed if the named configuration
item exists, and is manually set by the admin

src/include/conffile.h
src/main/conffile.c

index b99688196bbb8acb01f9b222016302527e7e59c2..237469c880603666a5975d8c4699af35ca81a7d8 100644 (file)
@@ -140,6 +140,7 @@ typedef struct timeval _timeval_t;
 #define PW_TYPE_MULTI          (1 << 18) //!< CONF_PAIR can have multiple copies.
 #define PW_TYPE_NOT_EMPTY      (1 << 19) //!< CONF_PAIR is required to have a non zero length value.
 #define PW_TYPE_FILE_EXISTS    ((1 << 20) | PW_TYPE_STRING) //!< File matching value must exist
+#define PW_TYPE_IGNORE_DEFAULT (1 << 21) //!< don't set from .dflt if the CONF_PAIR is missing
 /* @} **/
 
 #define FR_INTEGER_COND_CHECK(_name, _var, _cond, _new)\
index 8461d242e397db5e7e6cc974e2251bb6d7367e44..d458792cd5b84bfe7302578200e01e35c062c980 100644 (file)
@@ -1424,6 +1424,7 @@ int cf_item_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d
 {
        int rcode;
        bool deprecated, required, attribute, secret, file_input, cant_be_empty, tmpl, multi, file_exists;
+       bool ignore_dflt;
        char **q;
        char const *value;
        CONF_PAIR *cp = NULL;
@@ -1447,6 +1448,7 @@ int cf_item_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d
        cant_be_empty = (type & PW_TYPE_NOT_EMPTY);
        tmpl = (type & PW_TYPE_TMPL);
        multi = (type & PW_TYPE_MULTI);
+       ignore_dflt = (type & PW_TYPE_IGNORE_DEFAULT);
 
        if (attribute) required = true;
        if (required) cant_be_empty = true;     /* May want to review this in the future... */
@@ -1470,7 +1472,7 @@ int cf_item_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d
         *      section, use the default value.
         */
        if (!cp) {
-               if (deprecated) return 0;       /* Don't set the default value */
+               if (deprecated || ignore_dflt) return 0;        /* Don't set the default value */
 
                rcode = 1;
                value = dflt;