]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
check plugin config before registering
authorColin Vidal <colin@isc.org>
Wed, 1 Oct 2025 09:16:11 +0000 (11:16 +0200)
committerColin Vidal <colin@isc.org>
Wed, 1 Oct 2025 09:16:11 +0000 (11:16 +0200)
In named_config_parsefile(), when checking the validity of
named.conf, the checking of plugin correctness was deliberately
postponed until the plugin is loaded and registered. However,
when the plugin was registered, the checking was never actually
done: the plugin_register() implementation was called, but
plugin_check() was not.

This made it necessary to duplicate the correctness checking in both
functions, so that both named-checkconf and named could catch errors.
That should not be required.

ns_plugin_register() now calls the check function before the register
function, and aborts if either one fails.  ns_plugin_check() calls only
the check function.  ns_plugin_check() is used by named-checkconf, and
ns_plugin_register() is used by named. (Note: this design has a
side effect that a call to ns_plugin_register() will result in the
plugin parameters being parsed twice at registration time.)

Partial backport of !11031

lib/ns/hooks.c

index 2ef7bc82812811c9c7b2254a464cc2a4e0d222d8..851c282b86e13f6687eacb339ca026edc6f43feb 100644 (file)
@@ -224,6 +224,9 @@ ns_plugin_register(const char *modpath, const char *parameters, const void *cfg,
        isc_log_write(ns_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
                      ISC_LOG_INFO, "registering plugin '%s'", modpath);
 
+       CHECK(plugin->check_func(parameters, cfg, cfg_file, cfg_line, mctx,
+                                lctx, actx));
+
        CHECK(plugin->register_func(parameters, cfg, cfg_file, cfg_line, mctx,
                                    lctx, actx, view->hooktable,
                                    &plugin->inst));