From: Colin Vidal Date: Thu, 16 Oct 2025 13:30:23 +0000 (+0200) Subject: add an optional merge method on cfg_clausedef_t X-Git-Tag: v9.21.15~22^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9a0af4359cf312a55a4b534a670f6bab2ed7b54;p=thirdparty%2Fbind9.git add an optional merge method on cfg_clausedef_t 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. --- diff --git a/lib/isccfg/include/isccfg/grammar.h b/lib/isccfg/include/isccfg/grammar.h index 0ea711a9041..068d4120fdf 100644 --- a/lib/isccfg/include/isccfg/grammar.h +++ b/lib/isccfg/include/isccfg/grammar.h @@ -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. */