Commit cd87d615 authored by Mark Andrews's avatar Mark Andrews

Merge branch '859-named-paths' into 'master'

Resolve "print default file paths in named -V"

Closes #859

See merge request !1458
parents 755efa9b 25a3bb04
Pipeline #9519 passed with stages
in 58 seconds
5155. [func] "named -V" now outputs the default paths to
named.conf, rndc.conf, bind.keys, and other
files used or created by named and other tools, so
that the correct paths to these files can quickly be
determined regardless of the configure settings
used when BIND was built. [GL #859]
5154. [bug] dig: process_opt could be called twice on the same
message leading to a assertion failure. [GL #860]
......
......@@ -90,7 +90,8 @@ EXTERN cfg_obj_t * named_g_config INIT(NULL);
EXTERN const cfg_obj_t * named_g_defaults INIT(NULL);
EXTERN const char * named_g_conffile INIT(NAMED_SYSCONFDIR
"/named.conf");
EXTERN cfg_obj_t * named_g_bindkeys INIT(NULL);
EXTERN const char * named_g_defaultbindkeys INIT(NAMED_SYSCONFDIR
"/bind.keys");
EXTERN const char * named_g_keyfile INIT(NAMED_SYSCONFDIR
"/rndc.key");
......
......@@ -445,6 +445,98 @@ set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) {
*ret = 0;
}
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') ? " " : "",
named_g_description, named_g_srcid);
if (!verbose) {
return;
}
printf("running on %s\n", named_os_uname());
printf("built by %s with %s\n",
named_g_builder, named_g_configargs);
#ifdef __clang__
printf("compiled by CLANG %s\n", __VERSION__);
#else
#if defined(__ICC) || defined(__INTEL_COMPILER)
printf("compiled by ICC %s\n", __VERSION__);
#else
#ifdef __GNUC__
printf("compiled by GCC %s\n", __VERSION__);
#endif
#endif
#endif
#ifdef _MSC_VER
printf("compiled by MSVC %d\n", _MSC_VER);
#endif
#ifdef __SUNPRO_C
printf("compiled by Solaris Studio %x\n", __SUNPRO_C);
#endif
printf("compiled with OpenSSL version: %s\n",
OPENSSL_VERSION_TEXT);
#if !defined(LIBRESSL_VERSION_NUMBER) && \
OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */
printf("linked to OpenSSL version: %s\n",
OpenSSL_version(OPENSSL_VERSION));
#else
printf("linked to OpenSSL version: %s\n",
SSLeay_version(SSLEAY_VERSION));
#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
#ifdef HAVE_LIBXML2
printf("compiled with libxml2 version: %s\n",
LIBXML_DOTTED_VERSION);
printf("linked to libxml2 version: %s\n",
xmlParserVersion);
#endif
#if defined(HAVE_JSON) && defined(JSON_C_VERSION)
printf("compiled with libjson-c version: %s\n",
JSON_C_VERSION);
printf("linked to libjson-c version: %s\n",
json_c_version());
#endif
#if defined(HAVE_ZLIB) && defined(ZLIB_VERSION)
printf("compiled with zlib version: %s\n",
ZLIB_VERSION);
printf("linked to zlib version: %s\n",
zlibVersion());
#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\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);
printf(" named lock file: %s\n", named_g_defaultlockfile);
}
static void
parse_fuzz_arg(void) {
if (!strncmp(isc_commandline_argument, "client:", 7)) {
......@@ -670,66 +762,10 @@ parse_command_line(int argc, char *argv[]) {
named_g_username = isc_commandline_argument;
break;
case 'v':
printf("%s %s%s%s <id:%s>\n",
named_g_product, named_g_version,
(*named_g_description != '\0') ? " " : "",
named_g_description, named_g_srcid);
printversion(false);
exit(0);
case 'V':
printf("%s %s%s%s <id:%s>\n",
named_g_product, named_g_version,
(*named_g_description != '\0') ? " " : "",
named_g_description, named_g_srcid);
printf("running on %s\n", named_os_uname());
printf("built by %s with %s\n",
named_g_builder, named_g_configargs);
#ifdef __clang__
printf("compiled by CLANG %s\n", __VERSION__);
#else
#if defined(__ICC) || defined(__INTEL_COMPILER)
printf("compiled by ICC %s\n", __VERSION__);
#else
#ifdef __GNUC__
printf("compiled by GCC %s\n", __VERSION__);
#endif
#endif
#endif
#ifdef _MSC_VER
printf("compiled by MSVC %d\n", _MSC_VER);
#endif
#ifdef __SUNPRO_C
printf("compiled by Solaris Studio %x\n", __SUNPRO_C);
#endif
printf("compiled with OpenSSL version: %s\n",
OPENSSL_VERSION_TEXT);
#if !defined(LIBRESSL_VERSION_NUMBER) && \
OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */
printf("linked to OpenSSL version: %s\n",
OpenSSL_version(OPENSSL_VERSION));
#else
printf("linked to OpenSSL version: %s\n",
SSLeay_version(SSLEAY_VERSION));
#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
#ifdef HAVE_LIBXML2
printf("compiled with libxml2 version: %s\n",
LIBXML_DOTTED_VERSION);
printf("linked to libxml2 version: %s\n",
xmlParserVersion);
#endif
#if defined(HAVE_JSON) && defined(JSON_C_VERSION)
printf("compiled with libjson-c version: %s\n",
JSON_C_VERSION);
printf("linked to libjson-c version: %s\n",
json_c_version());
#endif
#if defined(HAVE_ZLIB) && defined(ZLIB_VERSION)
printf("compiled with zlib version: %s\n",
ZLIB_VERSION);
printf("linked to zlib version: %s\n",
zlibVersion());
#endif
printf("threads support is enabled\n");
printversion(true);
exit(0);
case 'x':
/* Obsolete. No longer in use. Ignore. */
......
......@@ -9714,7 +9714,8 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) {
CHECKFATAL(server->statsfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS,
"isc_mem_strdup");
server->bindkeysfile = isc_mem_strdup(server->mctx, "bind.keys");
server->bindkeysfile = isc_mem_strdup(server->mctx,
named_g_defaultbindkeys);
CHECKFATAL(server->bindkeysfile == NULL ? ISC_R_NOMEMORY :
ISC_R_SUCCESS,
"isc_mem_strdup");
......
......@@ -59,6 +59,7 @@ named_paths_init(void) {
named_g_defaultlockfile = isc_ntpaths_get(NAMED_LOCK_PATH);
named_g_keyfile = isc_ntpaths_get(RNDC_KEY_PATH);
named_g_defaultsessionkeyfile = isc_ntpaths_get(SESSION_KEY_PATH);
named_g_defaultbindkeys = isc_ntpaths_get(BIND_KEYS_PATH);
named_g_defaultdnstap = NULL;
Initialized = TRUE;
......
......@@ -33,7 +33,8 @@ enum NtPaths {
LOCAL_STATE_DIR,
SYS_CONF_DIR,
RNDC_KEY_PATH,
SESSION_KEY_PATH
SESSION_KEY_PATH,
BIND_KEYS_PATH
};
/*
......
......@@ -39,6 +39,7 @@ static char sys_conf_dir[MAX_PATH];
static char rndc_keyFile[MAX_PATH];
static char session_keyFile[MAX_PATH];
static char resolv_confFile[MAX_PATH];
static char bind_keysFile[MAX_PATH];
static DWORD baseLen = MAX_PATH;
static BOOL Initialized = FALSE;
......@@ -98,6 +99,9 @@ isc_ntpaths_init(void) {
strlcat(resolv_confFile, "\\etc\\resolv.conf",
sizeof(resolv_confFile));
strlcpy(bind_keysFile, namedBase, sizeof(bind_keysFile));
strlcat(bind_keysFile, "\\etc\\bind.keys", sizeof(bind_keysFile));
Initialized = TRUE;
}
......@@ -134,6 +138,9 @@ isc_ntpaths_get(int ind) {
case SESSION_KEY_PATH:
return (session_keyFile);
break;
case BIND_KEYS_PATH:
return (bind_keysFile);
break;
default:
return (NULL);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment