From a6ccb2f74daad494565cff7fcf284f0ac5e81485 Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Tue, 1 Sep 2026 08:48:27 +0200 Subject: [PATCH] - Fix to allow block_a and other local-zone types in a view. --- doc/Changelog | 3 +++ util/config_file.c | 37 +++++++++++++++++++++++++++++++ util/config_file.h | 6 +++++ util/configparser.y | 54 +++++---------------------------------------- 4 files changed, 52 insertions(+), 48 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index d7231b302..d4516b5c4 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +1 September 2026: Wouter + - Fix to allow block_a and other local-zone types in a view. + 26 August 2026: Wouter - Fix notify for auth-zone during initial start up. It performs the transfer and not only lookup. diff --git a/util/config_file.c b/util/config_file.c index 6f44ab90b..a100e0e5c 100644 --- a/util/config_file.c +++ b/util/config_file.c @@ -3090,3 +3090,40 @@ file_get_mtime(const char* file, time_t* mtime, long* ns, int* nonexist) #endif return 1; } + +int cfg_local_zone_type_value_check(const char* str) +{ + if(strcmp(str, "static")!=0 && strcmp(str, "deny")!=0 && + strcmp(str, "refuse")!=0 && strcmp(str, "redirect")!=0 && + strcmp(str, "transparent")!=0 && strcmp(str, "nodefault")!=0 + && strcmp(str, "typetransparent")!=0 + && strcmp(str, "always_transparent")!=0 + && strcmp(str, "block_a")!=0 + && strcmp(str, "block_aaaa")!=0 + && strcmp(str, "block_a_wdata")!=0 + && strcmp(str, "block_aaaa_wdata")!=0 + && strcmp(str, "always_refuse")!=0 + && strcmp(str, "always_nxdomain")!=0 + && strcmp(str, "always_nodata")!=0 + && strcmp(str, "always_deny")!=0 + && strcmp(str, "always_null")!=0 + && strcmp(str, "noview")!=0 + && strcmp(str, "inform")!=0 && strcmp(str, "inform_deny")!=0 + && strcmp(str, "inform_redirect") != 0 + && strcmp(str, "ipset") != 0) + return 0; + return 1; +} + +const char* cfg_local_zone_type_list(void) +{ + return "static, deny, " + "refuse, redirect, transparent, " + "typetransparent, inform, inform_deny, " + "inform_redirect, always_transparent, " + "block_a, block_aaaa, " + "block_a_wdata, block_aaaa_wdata, " + "always_refuse, always_nxdomain, " + "always_nodata, always_deny, always_null, " + "noview, nodefault or ipset"; +} diff --git a/util/config_file.h b/util/config_file.h index 819a321af..862d2eb38 100644 --- a/util/config_file.h +++ b/util/config_file.h @@ -1519,4 +1519,10 @@ void cfg_tls_protocols_allowed(const char* tls_protocols, int* allow12, int* all /** get the file mtime stat (or error, with errno and nonexist) */ int file_get_mtime(const char* file, time_t* mtime, long* ns, int* nonexist); +/** check local-zone type for correctness */ +int cfg_local_zone_type_value_check(const char* str); + +/** the list of local-zone types, for error printout. */ +const char* cfg_local_zone_type_list(void); + #endif /* UTIL_CONFIG_FILE_H */ diff --git a/util/configparser.y b/util/configparser.y index 96c30de0c..62e0fface 100644 --- a/util/configparser.y +++ b/util/configparser.y @@ -2401,33 +2401,9 @@ server_neg_cache_size: VAR_NEG_CACHE_SIZE STRING_ARG server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG { OUTYY(("P(server_local_zone:%s %s)\n", $2, $3)); - if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 && - strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 && - strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0 - && strcmp($3, "typetransparent")!=0 - && strcmp($3, "always_transparent")!=0 - && strcmp($3, "block_a")!=0 - && strcmp($3, "block_aaaa")!=0 - && strcmp($3, "block_a_wdata")!=0 - && strcmp($3, "block_aaaa_wdata")!=0 - && strcmp($3, "always_refuse")!=0 - && strcmp($3, "always_nxdomain")!=0 - && strcmp($3, "always_nodata")!=0 - && strcmp($3, "always_deny")!=0 - && strcmp($3, "always_null")!=0 - && strcmp($3, "noview")!=0 - && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0 - && strcmp($3, "inform_redirect") != 0 - && strcmp($3, "ipset") != 0) { - yyerror("local-zone type: expected static, deny, " - "refuse, redirect, transparent, " - "typetransparent, inform, inform_deny, " - "inform_redirect, always_transparent, " - "block_a, block_aaaa, " - "block_a_wdata, block_aaaa_wdata, " - "always_refuse, always_nxdomain, " - "always_nodata, always_deny, always_null, " - "noview, nodefault or ipset"); + if(!cfg_local_zone_type_value_check($3)) { + ub_c_error_msg("local-zone type: expected %s", + cfg_local_zone_type_list()); free($2); free($3); } else if(strcmp($3, "nodefault")==0) { @@ -3393,27 +3369,9 @@ view_name: VAR_NAME STRING_ARG view_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG { OUTYY(("P(view_local_zone:%s %s)\n", $2, $3)); - if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 && - strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 && - strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0 - && strcmp($3, "typetransparent")!=0 - && strcmp($3, "always_transparent")!=0 - && strcmp($3, "always_refuse")!=0 - && strcmp($3, "always_nxdomain")!=0 - && strcmp($3, "always_nodata")!=0 - && strcmp($3, "always_deny")!=0 - && strcmp($3, "always_null")!=0 - && strcmp($3, "noview")!=0 - && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0 - && strcmp($3, "inform_redirect") != 0 - && strcmp($3, "ipset") != 0) { - yyerror("local-zone type: expected static, deny, " - "refuse, redirect, transparent, " - "typetransparent, inform, inform_deny, " - "inform_redirect, always_transparent, " - "always_refuse, always_nxdomain, " - "always_nodata, always_deny, always_null, " - "noview, nodefault or ipset"); + if(!cfg_local_zone_type_value_check($3)) { + ub_c_error_msg("local-zone type: expected %s", + cfg_local_zone_type_list()); free($2); free($3); } else if(strcmp($3, "nodefault")==0) {