]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add an optional merge method on cfg_clausedef_t
authorColin Vidal <colin@isc.org>
Thu, 16 Oct 2025 13:30:23 +0000 (15:30 +0200)
committerEvan Hunt <each@isc.org>
Wed, 29 Oct 2025 20:55:04 +0000 (13:55 -0700)
In order to handle specific cases when merging configurations (i.e.
some specific clauses which require specific handling, not just
overriding values for instance), the cfg_clausedef_t includes an
optional merge method.

The merge function is NULL by default. If it is defined for a given
clause, and this clause is defined in both the user and default
configurations, the merge function is then called with both the user and
default clause instances. It's up the the implementation of that function
do to anything needed to keep the correct named.conf semantic.

lib/isccfg/include/isccfg/grammar.h

index 0ea711a9041b2da86345b637956d633a6cd058d6..068d4120fdf22ee16cc6d7828f67068090a5e5da 100644 (file)
@@ -118,11 +118,26 @@ struct cfg_printer {
        int   flags;
 };
 
-/*% A clause definition. */
+/*%
+ * A clause definition and its optional merge method, which will be called
+ * when merging a default configuration with a user configuration, if
+ * provided.
+ *
+ * Note: the merge method is associated with the clause instead of
+ * the data representation, because different semantics may apply
+ * for different named.conf statements. For example, the user-defined
+ * options can't simply be merged with the default options as a normal
+ * cfg_rep_map, because the allow-query and allow-recursion ACLs have
+ * complex semantics that need to be preserved.
+ */
+typedef void (*cfg_mergefunc_t)(cfg_obj_t      *effectiveobj,
+                               const cfg_obj_t *defaultobj);
+
 struct cfg_clausedef {
-       const char  *name;
-       cfg_type_t  *type;
-       unsigned int flags;
+       const char     *name;
+       cfg_type_t     *type;
+       unsigned int    flags;
+       cfg_mergefunc_t merge;
 };
 
 /*% A tuple field definition. */