From cf722d18b35771e4d7bb52a3b87e80815d9766d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Wed, 23 Mar 2022 12:52:33 +0100 Subject: [PATCH] Export built-in default configuration for named binary It might be useful to display built-in configuration with all its values. It should make it easier to test what default values has changed in a new release. Related: #1326 --- CHANGES | 3 +++ bin/named/config.c | 5 +++++ bin/named/include/named/config.h | 3 +++ bin/named/include/named/main.h | 2 +- bin/named/main.c | 7 ++++++- bin/named/named.rst | 10 +++++++++- doc/man/named.8in | 11 ++++++++++- 7 files changed, 37 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 16c041563a..35af6a82ed 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5880. [func] Add new named command-line option -C to print built-in + defaults. [GL #1326] + 5879. [contrib] dlz: Add FALLTHROUGH and UNREACHABLE macros. [GL #3306] 5878. [func] Check the algorithm name or OID embedded at the start diff --git a/bin/named/config.c b/bin/named/config.c index 7bf3122617..8c64c1ff2a 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -334,6 +334,11 @@ named_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf) { CFG_PCTX_NODEPRECATED, conf)); } +const char * +named_config_getdefault() { + return (defaultconf); +} + isc_result_t named_config_get(cfg_obj_t const *const *maps, const char *name, const cfg_obj_t **obj) { diff --git a/bin/named/include/named/config.h b/bin/named/include/named/config.h index e9aef21f47..834c53f6e7 100644 --- a/bin/named/include/named/config.h +++ b/bin/named/include/named/config.h @@ -27,6 +27,9 @@ isc_result_t named_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf); +const char * +named_config_getdefault(void); + isc_result_t named_config_get(cfg_obj_t const *const *maps, const char *name, const cfg_obj_t **obj); diff --git a/bin/named/include/named/main.h b/bin/named/include/named/main.h index 7d01851b9b..42fd138314 100644 --- a/bin/named/include/named/main.h +++ b/bin/named/include/named/main.h @@ -24,7 +24,7 @@ /* * Commandline arguments for named; */ -#define NAMED_MAIN_ARGS "46A:c:d:D:E:fFgL:M:m:n:N:p:sS:t:T:U:u:vVx:X:" +#define NAMED_MAIN_ARGS "46A:c:Cd:D:E:fFgL:M:m:n:N:p:sS:t:T:U:u:vVx:X:" noreturn void named_main_earlyfatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); diff --git a/bin/named/main.c b/bin/named/main.c index 67c16304d9..33421faeaa 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -316,7 +316,7 @@ usage(void) { " [-X lockfile] [-m " "{usage|trace|record|size|mctx}]\n" " [-M fill|nofill]\n" - "usage: named [-v|-V]\n"); + "usage: named [-v|-V|-C]\n"); } static void @@ -778,6 +778,11 @@ parse_command_line(int argc, char *argv[]) { named_g_conffile = isc_commandline_argument; named_g_conffileset = true; break; + case 'C': + printf("# Built-in default values. " + "This is NOT the run-time configuration!\n"); + printf("%s", named_config_getdefault()); + exit(0); case 'd': named_g_debuglevel = parse_int(isc_commandline_argument, "debug " diff --git a/bin/named/named.rst b/bin/named/named.rst index 21a82c4dbd..d6a239c282 100644 --- a/bin/named/named.rst +++ b/bin/named/named.rst @@ -21,7 +21,7 @@ named - Internet domain name server Synopsis ~~~~~~~~ -:program:`named` [ [**-4**] | [**-6**] ] [**-c** config-file] [**-d** debug-level] [**-D** string] [**-E** engine-name] [**-f**] [**-g**] [**-L** logfile] [**-M** option] [**-m** flag] [**-n** #cpus] [**-p** port] [**-s**] [**-t** directory] [**-U** #listeners] [**-u** user] [**-v**] [**-V**] [**-X** lock-file] +:program:`named` [ [**-4**] | [**-6**] ] [**-c** config-file] [**-C**] [**-d** debug-level] [**-D** string] [**-E** engine-name] [**-f**] [**-g**] [**-L** logfile] [**-M** option] [**-m** flag] [**-n** #cpus] [**-p** port] [**-s**] [**-t** directory] [**-U** #listeners] [**-u** user] [**-v**] [**-V**] [**-X** lock-file] Description ~~~~~~~~~~~ @@ -55,6 +55,14 @@ Options due to to a possible ``directory`` option in the configuration file, ``config-file`` should be an absolute pathname. +.. option:: -C + + This option prints out the default built-in configuration and exits. + + NOTE: This is for debugging purposes only and is not an + accurate representation of the actual configuration used by :iscman:`named` + at runtime. + .. option:: -d debug-level This option sets the daemon's debug level to ``debug-level``. Debugging traces from diff --git a/doc/man/named.8in b/doc/man/named.8in index 0fd8c74f1d..2927a6f38a 100644 --- a/doc/man/named.8in +++ b/doc/man/named.8in @@ -32,7 +32,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] named \- Internet domain name server .SH SYNOPSIS .sp -\fBnamed\fP [ [\fB\-4\fP] | [\fB\-6\fP] ] [\fB\-c\fP config\-file] [\fB\-d\fP debug\-level] [\fB\-D\fP string] [\fB\-E\fP engine\-name] [\fB\-f\fP] [\fB\-g\fP] [\fB\-L\fP logfile] [\fB\-M\fP option] [\fB\-m\fP flag] [\fB\-n\fP #cpus] [\fB\-p\fP port] [\fB\-s\fP] [\fB\-t\fP directory] [\fB\-U\fP #listeners] [\fB\-u\fP user] [\fB\-v\fP] [\fB\-V\fP] [\fB\-X\fP lock\-file] +\fBnamed\fP [ [\fB\-4\fP] | [\fB\-6\fP] ] [\fB\-c\fP config\-file] [\fB\-C\fP] [\fB\-d\fP debug\-level] [\fB\-D\fP string] [\fB\-E\fP engine\-name] [\fB\-f\fP] [\fB\-g\fP] [\fB\-L\fP logfile] [\fB\-M\fP option] [\fB\-m\fP flag] [\fB\-n\fP #cpus] [\fB\-p\fP port] [\fB\-s\fP] [\fB\-t\fP directory] [\fB\-U\fP #listeners] [\fB\-u\fP user] [\fB\-v\fP] [\fB\-V\fP] [\fB\-X\fP lock\-file] .SH DESCRIPTION .sp \fBnamed\fP is a Domain Name System (DNS) server, part of the BIND 9 @@ -66,6 +66,15 @@ due to to a possible \fBdirectory\fP option in the configuration file, .UNINDENT .INDENT 0.0 .TP +.B \-C +This option prints out the default built\-in configuration and exits. +.sp +NOTE: This is for debugging purposes only and is not an +accurate representation of the actual configuration used by \fI\%named\fP +at runtime. +.UNINDENT +.INDENT 0.0 +.TP .B \-d debug\-level This option sets the daemon\(aqs debug level to \fBdebug\-level\fP\&. Debugging traces from \fBnamed\fP become more verbose as the debug level increases.