From 5a98141a00ec2be0a25773e5a77dcb98712c4277 Mon Sep 17 00:00:00 2001 From: Colin Vidal Date: Wed, 1 Oct 2025 11:16:11 +0200 Subject: [PATCH] check plugin config before registering 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ns/hooks.c b/lib/ns/hooks.c index 2ef7bc8281..851c282b86 100644 --- a/lib/ns/hooks.c +++ b/lib/ns/hooks.c @@ -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));