Compare commits

...
Author SHA1 Message Date
W.C.A. Wijngaards c3a3182edd - checkconf-zone-check, documentation in the man page. 2026-10-19 16:22:28 +02:00
W.C.A. Wijngaards d1e3d52726 - checkconf-zone-check, unbound-checkonf only reads config, -a option to read
zone files of auth-zones and RPZ.
2026-10-19 16:19:36 +02:00
7 changed files with 30 additions and 14 deletions
+1 -1
View File
@@ -1077,7 +1077,7 @@ daemon_fork(struct daemon* daemon)
daemon_setup_modules(daemon);
/* read auth zonefiles */
if(!auth_zones_apply_cfg(daemon->env->auth_zones, daemon->cfg, 1,
if(!auth_zones_apply_cfg(daemon->env->auth_zones, daemon->cfg, 1, 1,
&daemon->use_rpz, daemon->env, &daemon->mods))
fatal_exit("auth_zones could not be setup");
+1 -1
View File
@@ -5980,7 +5980,7 @@ fr_construct_from_config(struct fast_reload_thread* fr,
fr_construct_clear(ct);
return 0;
}
if(!auth_zones_apply_cfg(ct->auth_zones, newcfg, 1, &ct->use_rpz,
if(!auth_zones_apply_cfg(ct->auth_zones, newcfg, 1, 1, &ct->use_rpz,
fr->worker->daemon->env, &fr->worker->daemon->mods)) {
fr_construct_clear(ct);
return 0;
+6 -1
View File
@@ -42,7 +42,7 @@ unbound-checkconf(8)
Synopsis
--------
**unbound-checkconf** [``-hf``] [``-o option``] [cfgfile]
**unbound-checkconf** [``-ahf``] [``-o option``] [cfgfile]
Description
-----------
@@ -54,6 +54,11 @@ The config file syntax is described in
The available options are:
.. option:: -a
Also read the zonefiles for auth-zones and RPZ.
It checks if the syntax is okay of the zonefiles.
.. option:: -h
Show the version and commandline option help.
+1 -1
View File
@@ -86,7 +86,7 @@ context_finalize(struct ub_ctx* ctx)
return UB_NOMEM;
if(!local_zones_apply_cfg(ctx->local_zones, cfg))
return UB_INITFAIL;
if(!auth_zones_apply_cfg(ctx->env->auth_zones, cfg, 1, &is_rpz,
if(!auth_zones_apply_cfg(ctx->env->auth_zones, cfg, 1, 1, &is_rpz,
ctx->env, &ctx->mods))
return UB_INITFAIL;
if(!(ctx->env->fwds = forwards_create()) ||
+5 -3
View File
@@ -2350,7 +2350,7 @@ az_delete_deleted_zones(struct auth_zones* az)
}
int auth_zones_apply_cfg(struct auth_zones* az, struct config_file* cfg,
int setup, int* is_rpz, struct module_env* env,
int setup, int readauth, int* is_rpz, struct module_env* env,
struct module_stack* mods)
{
struct config_auth* p;
@@ -2367,8 +2367,10 @@ int auth_zones_apply_cfg(struct auth_zones* az, struct config_file* cfg,
}
}
az_delete_deleted_zones(az);
if(!auth_zones_read_zones(az, cfg, env, mods))
return 0;
if(readauth) {
if(!auth_zones_read_zones(az, cfg, env, mods))
return 0;
}
if(setup) {
if(!auth_zones_setup_zones(az))
return 0;
+3 -1
View File
@@ -514,13 +514,15 @@ struct auth_zones* auth_zones_create(void);
* @param az: auth zones structure
* @param cfg: config to apply.
* @param setup: if true, also sets up values in the auth zones structure
* @param readauth: if true, reads zone files. False to omit zone file read,
* for use by checkconf.
* @param is_rpz: set to 1 if at least one RPZ zone is configured.
* @param env: environment for offline verification.
* @param mods: modules in environment.
* @return false on failure.
*/
int auth_zones_apply_cfg(struct auth_zones* az, struct config_file* cfg,
int setup, int* is_rpz, struct module_env* env,
int setup, int readauth, int* is_rpz, struct module_env* env,
struct module_stack* mods);
/** initial pick up of worker timeouts, ties events to worker event loop
+13 -6
View File
@@ -90,6 +90,7 @@ usage(void)
printf("Usage: unbound-checkconf [file]\n");
printf(" Checks unbound configuration file for errors.\n");
printf("file if omitted %s is used.\n", CONFIGFILE);
printf("-a read zone files of auth-zones and RPZ.\n");
printf("-o option print value of option to stdout.\n");
printf("-f output full pathname with chroot applied, eg. with -o pidfile.\n");
printf("-q quiet (suppress output on success).\n");
@@ -1166,11 +1167,12 @@ check_hints(struct config_file* cfg)
/** check auth zones */
static void
check_auth(struct config_file* cfg)
check_auth(struct config_file* cfg, int readauth)
{
int is_rpz = 0;
struct auth_zones* az = auth_zones_create();
if(!az || !auth_zones_apply_cfg(az, cfg, 0, &is_rpz, NULL, NULL)) {
if(!az || !auth_zones_apply_cfg(az, cfg, 0, readauth, &is_rpz, NULL,
NULL)) {
fatal_exit("Could not setup authority zones");
}
if(is_rpz && !strstr(cfg->module_conf, "respip"))
@@ -1180,7 +1182,8 @@ check_auth(struct config_file* cfg)
/** check config file */
static void
checkconf(const char* cfgfile, const char* opt, int final, int quiet)
checkconf(const char* cfgfile, const char* opt, int final, int quiet,
int readauth)
{
char oldwd[4096];
struct config_file* cfg = config_create();
@@ -1212,7 +1215,7 @@ checkconf(const char* cfgfile, const char* opt, int final, int quiet)
#endif
check_fwd(cfg);
check_hints(cfg);
check_auth(cfg);
check_auth(cfg, readauth);
if(!quiet) { printf("unbound-checkconf: no errors in %s\n", cfgfile); }
config_delete(cfg);
}
@@ -1228,6 +1231,7 @@ int main(int argc, char* argv[])
int c;
int final = 0;
int quiet = 0;
int readauth = 0;
const char* f;
const char* opt = NULL;
const char* cfgfile = CONFIGFILE;
@@ -1240,8 +1244,11 @@ int main(int argc, char* argv[])
cfgfile = CONFIGFILE;
#endif /* USE_WINSOCK */
/* parse the options */
while( (c=getopt(argc, argv, "fhqo:")) != -1) {
while( (c=getopt(argc, argv, "afhqo:")) != -1) {
switch(c) {
case 'a':
readauth = 1;
break;
case 'f':
final = 1;
break;
@@ -1264,7 +1271,7 @@ int main(int argc, char* argv[])
if(argc == 1)
f = argv[0];
else f = cfgfile;
checkconf(f, opt, final, quiet);
checkconf(f, opt, final, quiet, readauth);
checklock_stop();
return 0;
}