]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
construct the rndc.conf path from rndc.key
authorEvan Hunt <each@isc.org>
Wed, 6 Feb 2019 00:08:26 +0000 (16:08 -0800)
committerMark Andrews <marka@isc.org>
Wed, 6 Feb 2019 02:18:00 +0000 (13:18 +1100)
bin/named/main.c

index 0c8b82e6a5c5cca1d774c0e1eeda8d949c9b65c4..62d9ce3db3a5f40cd7e63b7aafdef64546aa026d 100644 (file)
@@ -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 <id:%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);