From: Petr Menšík Date: Thu, 16 Oct 2025 19:42:28 +0000 (+0200) Subject: Print built-in hints via named -H X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=a8d9aec96fea7cf32c5459e5bca3bbb13ec8960a;p=thirdparty%2Fbind9.git Print built-in hints via named -H Built-ins from libdns were not easily accessible from command line. --- diff --git a/bin/named/include/named/main.h b/bin/named/include/named/main.h index 7cf35e0a212..71ef4c14e42 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:Cd:D:E:fFgL:M:m:n:N:p:sS:t:T:U:u:vVx:X:" +#define NAMED_MAIN_ARGS "46A:c:Cd:D:E:fFgHL:M:m:n:N:p:sS:t:T:U:u:vVx:X:" ISC_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 37b77bc2ed2..1bd04a0ccf4 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -866,6 +867,9 @@ parse_command_line(int argc, char *argv[]) { named_g_logflags = ISC_LOG_PRINTTIME | ISC_LOG_ISO8601 | ISC_LOG_TZINFO; break; + case 'H': + printf("%s", dns_rootns_gethints()); + exit(EXIT_SUCCESS); case 'L': named_g_logfile = isc_commandline_argument; break; diff --git a/bin/named/named.rst b/bin/named/named.rst index 8b71a388259..f84270dd124 100644 --- a/bin/named/named.rst +++ b/bin/named/named.rst @@ -87,6 +87,10 @@ Options This option runs the server in the foreground and forces all logging to ``stderr``. +.. option:: -H + + This option prints built-in root servers hints and exits. + .. option:: -L logfile This option sets the log to the file ``logfile`` by default, instead of the system log. diff --git a/lib/dns/include/dns/rootns.h b/lib/dns/include/dns/rootns.h index 574dfe11bf3..622bc727f11 100644 --- a/lib/dns/include/dns/rootns.h +++ b/lib/dns/include/dns/rootns.h @@ -20,3 +20,9 @@ isc_result_t dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, const char *filename, dns_db_t **target); + +const char * +dns_rootns_gethints(void); +/*% + * Get built-in root NS hints + */ diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index 88d853fff45..c8ba7f6e0b2 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -230,3 +230,8 @@ cleanup: return result; } + +const char * +dns_rootns_gethints(void) { + return root_ns; +}