diff --git a/CHANGES b/CHANGES index 204ddb23ef..35ec839cb0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3450. [bug] Stop logfileconfig system test spam system logs. + [RT #32315] + 3449. [bug] gen.c: use the pre-processor to construct format strings so that compiler can perform sanity checks; check the snprintf results. [RT #17576] diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h index 890037826e..531849c075 100644 --- a/bin/named/include/named/globals.h +++ b/bin/named/include/named/globals.h @@ -112,6 +112,7 @@ EXTERN isc_boolean_t ns_g_coreok INIT(ISC_TRUE); EXTERN const char * ns_g_chrootdir INIT(NULL); EXTERN isc_boolean_t ns_g_foreground INIT(ISC_FALSE); EXTERN isc_boolean_t ns_g_logstderr INIT(ISC_FALSE); +EXTERN isc_boolean_t ns_g_nosyslog INIT(ISC_FALSE); #if NS_RUN_PID_DIR EXTERN const char * ns_g_defaultpidfile INIT(NS_LOCALSTATEDIR diff --git a/bin/named/log.c b/bin/named/log.c index c3287d5214..4ef0c707c8 100644 --- a/bin/named/log.c +++ b/bin/named/log.c @@ -201,7 +201,7 @@ isc_result_t ns_log_setdefaultcategory(isc_logconfig_t *lcfg) { isc_result_t result; - if (! ns_g_logstderr) { + if (! ns_g_logstderr && ! ns_g_nosyslog) { result = isc_log_usechannel(lcfg, "default_syslog", ISC_LOGCATEGORY_DEFAULT, NULL); if (result != ISC_R_SUCCESS) diff --git a/bin/named/logconf.c b/bin/named/logconf.c index f5a427062b..f82e0f5f25 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -246,14 +246,16 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *lctx) { isc_result_totext(result)); } else (void)isc_stdio_close(fp); - } else { - syslog(LOG_ERR, "isc_file_isplainfile '%s' failed: %s", - dest.file.name, isc_result_totext(result)); - fprintf(stderr, "isc_file_isplainfile '%s' failed: %s", - dest.file.name, isc_result_totext(result)); + goto done; } + if (!ns_g_nosyslog) + syslog(LOG_ERR, "isc_file_isplainfile '%s' failed: %s", + dest.file.name, isc_result_totext(result)); + fprintf(stderr, "isc_file_isplainfile '%s' failed: %s", + dest.file.name, isc_result_totext(result)); } + done: return (result); } diff --git a/bin/named/main.c b/bin/named/main.c index 582355998c..64f83a8653 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -462,6 +462,8 @@ parse_command_line(int argc, char *argv[]) { ns_g_nosoa = ISC_TRUE; else if (!strcmp(isc_commandline_argument, "noaa")) ns_g_noaa = ISC_TRUE; + else if (!strcmp(isc_commandline_argument, "nosyslog")) + ns_g_nosyslog = ISC_TRUE; else fprintf(stderr, "unknown -T flag '%s\n", isc_commandline_argument); diff --git a/bin/tests/system/logfileconfig/tests.sh b/bin/tests/system/logfileconfig/tests.sh index 63dad69c79..772ce1fa7c 100644 --- a/bin/tests/system/logfileconfig/tests.sh +++ b/bin/tests/system/logfileconfig/tests.sh @@ -30,7 +30,7 @@ PIPEFILE="named_pipe" SYMFILE="named_sym" PIDFILE="${THISDIR}/${CONFDIR}/named.pid" myRNDC="$RNDC -c ${THISDIR}/${CONFDIR}/rndc.conf" -myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record,size,mctx -d 99" +myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record,size,mctx -T nosyslog -d 99" # Stop the server and run through a series of tests with various config # files while controlling the stop/start of the server. @@ -93,7 +93,7 @@ then echo "I:exit status: 2" exit 2 fi - grep "invalid file" named.run > /dev/null 2>&1 + grep "configuring logging: invalid file" named.run > /dev/null 2>&1 if [ $? -ne 0 ] then echo "I: testing directory as file succeeded (UNEXPECTED)" @@ -122,7 +122,7 @@ then echo "I:exit status: 2" exit 2 fi - grep "invalid file" named.run > /dev/null 2>&1 + grep "configuring logging: invalid file" named.run > /dev/null 2>&1 if [ $? -ne 0 ] then echo "I: testing pipe file as log file succeeded (UNEXPECTED)"