diff --git a/bin/named/main.c b/bin/named/main.c index 0c8b82e6a5..62d9ce3db3 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -447,6 +447,8 @@ set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) { static void printversion(bool verbose) { + char rndcconf[PATH_MAX], *dot = NULL; + printf("%s %s%s%s \n", named_g_product, named_g_version, (*named_g_description != '\0') ? " " : "", @@ -507,12 +509,27 @@ OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */ #endif printf("threads support is enabled\n\n"); + + /* + * The default rndc.conf and rndc.key paths are in the same + * directory, but named only has rndc.key defined internally. + * We construct the rndc.conf path from it. (We could use + * NAMED_SYSCONFDIR here but the result would look wrong on + * Windows.) + */ + strlcpy(rndcconf, named_g_keyfile, sizeof(rndcconf)); + dot = strrchr(rndcconf, '.'); + if (dot != NULL) { + size_t len = dot - rndcconf + 1; + snprintf(dot + 1, PATH_MAX - len, "conf"); + } + /* * Print default configuration paths. */ printf("default paths:\n"); printf(" named configuration: %s\n", named_g_conffile); - printf(" rndc configuration: %s/rndc.conf\n", NAMED_SYSCONFDIR); + printf(" rndc configuration: %s\n", rndcconf); printf(" DNSSEC root key: %s\n", named_g_defaultbindkeys); printf(" nsupdate session key: %s\n", named_g_defaultsessionkeyfile); printf(" named PID file: %s\n", named_g_defaultpidfile);