+4124. [func] Log errors or warnings encountered when parsing the
+ internal default configuration. Clarify the logging
+ of errors and warnings encountered in rndc
+ addzone or modzone parameters. [RT #39440]
+
4123. [port] Added %z (size_t) format options to the portable
internal printf/sprintf implementation. [RT #39586]
"# session-keyfile \"" NS_LOCALSTATEDIR "/run/named/session.key\";\n\
session-keyname local-ddns;\n\
session-keyalg hmac-sha256;\n\
- deallocate-on-exit true;\n\
+# deallocate-on-exit <obsolete>;\n\
# directory <none>\n\
dump-file \"named_dump.db\";\n\
- fake-iquery no;\n\
- has-old-clients false;\n\
+# fake-iquery <obsolete>;\n\
+# has-old-clients <obsolete>;\n\
heartbeat-interval 60;\n\
- host-statistics no;\n\
+# host-statistics <obsolete>;\n\
interface-interval 60;\n\
# keep-response-order {none;};\n\
listen-on {any;};\n\
match-mapped-addresses no;\n\
max-rsa-exponent-size 0; /* no limit */\n\
memstatistics-file \"named.memstats\";\n\
- multiple-cnames no;\n\
+# multiple-cnames <obsolete>;\n\
# named-xfer <obsolete>;\n\
nta-lifetime 3600;\n\
nta-recheck 300;\n\
recursive-clients 1000;\n\
resolver-query-timeout 10;\n\
rrset-order { order random; };\n\
- serial-queries 20;\n\
+# serial-queries <obsolete>;\n\
serial-query-rate 20;\n\
server-id none;\n\
startup-notify-rate 20;\n\
statistics-file \"named.stats\";\n\
- statistics-interval 60;\n\
+# statistics-interval <obsolete>;\n\
tcp-clients 150;\n\
tcp-listen-queue 10;\n\
# tkey-dhkey <none>\n\
transfers-per-ns 2;\n\
transfers-in 10;\n\
transfers-out 10;\n\
- treat-cr-as-space true;\n\
- use-id-pool true;\n\
+# treat-cr-as-space <obsolete>;\n\
+# use-id-pool <obsolete>;\n\
use-ixfr true;\n\
edns-udp-size 4096;\n\
max-udp-size 4096;\n\
provide-ixfr true;\n\
request-ixfr true;\n\
request-expire true;\n\
- fetch-glue no;\n\
- rfc2308-type1 no;\n\
+# fetch-glue <obsolete>;\n\
+# rfc2308-type1 <obsolete>;\n\
additional-from-auth true;\n\
additional-from-cache true;\n\
query-source address *;\n\
notify-source *;\n\
notify-source-v6 *;\n\
cleaning-interval 0; /* now meaningless */\n\
- min-roots 2;\n\
+# min-roots <obsolete>;\n\
lame-ttl 600;\n\
servfail-ttl 10;\n\
max-ncache-ttl 10800; /* 3 hours */\n\
dialup no;\n\
# forward <none>\n\
# forwarders <none>\n\
- maintain-ixfr-base no;\n\
+# maintain-ixfr-base <obsolete>;\n\
# max-ixfr-log-size <obsolete>\n\
transfer-source *;\n\
transfer-source-v6 *;\n\
isc_buffer_init(&b, defaultconf, sizeof(defaultconf) - 1);
isc_buffer_add(&b, sizeof(defaultconf) - 1);
- return (cfg_parse_buffer(parser, &b, &cfg_type_namedconf, conf));
+ return (cfg_parse_buffer2(parser, &b, __FILE__,
+ &cfg_type_namedconf, conf));
}
isc_result_t
* Parse the global default pseudo-config file.
*/
if (first_time) {
- CHECK(ns_config_parsedefaults(ns_g_parser, &ns_g_config));
+ result = ns_config_parsedefaults(ns_g_parser, &ns_g_config);
+ if (result != ISC_R_SUCCESS)
+ ns_main_earlyfatal("unable to load "
+ "internal defaults: %s",
+ isc_result_totext(result));
RUNTIME_CHECK(cfg_map_get(ns_g_config, "options",
&ns_g_defaults) == ISC_R_SUCCESS);
}
server, &server->pps_timer),
"creating pps timer");
- CHECKFATAL(cfg_parser_create(ns_g_mctx, NULL, &ns_g_parser),
+ CHECKFATAL(cfg_parser_create(ns_g_mctx, ns_g_lctx, &ns_g_parser),
"creating default configuration parser");
- CHECKFATAL(cfg_parser_create(ns_g_mctx, NULL, &ns_g_addparser),
+ CHECKFATAL(cfg_parser_create(ns_g_mctx, ns_g_lctx, &ns_g_addparser),
"creating additional configuration parser");
if (ns_g_lwresdonly)
const char *viewname = NULL;
dns_rdataclass_t rdclass;
dns_view_t *view = NULL;
+ const char *bn;
REQUIRE(viewp != NULL && *viewp == NULL);
isc_buffer_init(&argbuf, args, (unsigned int) strlen(args));
isc_buffer_add(&argbuf, strlen(args));
+ if (strncasecmp(args, "add", 3) == 0)
+ bn = "addzone";
+ else if (strncasecmp(args, "mod", 3) == 0)
+ bn = "modzone";
+ else
+ INSIST(0);
+
/*
* Convert the "addzone" or "modzone" to just "zone", for
* the benefit of the parser
isc_buffer_forward(&argbuf, 3);
cfg_parser_reset(ns_g_addparser);
- CHECK(cfg_parse_buffer(ns_g_addparser, &argbuf,
+ CHECK(cfg_parse_buffer2(ns_g_addparser, &argbuf, bn,
&cfg_type_addzoneconf, &zoneconf));
CHECK(cfg_map_get(zoneconf, "zone", &zlist));
if (! cfg_obj_islist(zlist))
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
+echo "I:checking addzone errors are logged correctly"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone bad.example '{ type mister; };' 2>&1 | grep 'unexpected token' > /dev/null 2>&1 || ret=1
+grep "addzone: 'mister' unexpected" ns2/named.run >/dev/null 2>&1 || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:checking modzone errors are logged correctly"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 modzone added.example '{ type mister; };' 2>&1 | grep 'unexpected token' > /dev/null 2>&1 || ret=1
+grep "modzone: 'mister' unexpected" ns2/named.run >/dev/null 2>&1 || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
echo "I:adding a zone that requires quotes ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"32/1.0.0.127-in-addr.added.example" { check-names ignore; type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
isc_result_t
cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
const cfg_type_t *type, cfg_obj_t **ret);
+isc_result_t
+cfg_parse_buffer2(cfg_parser_t *pctx, isc_buffer_t *buffer,
+ const char *bufname, const cfg_type_t *type,
+ cfg_obj_t **ret);
/*%<
* Read a configuration containing data of type 'type'
* and make '*ret' point to its parse tree.
* (isc_parse_file()) or the buffer 'buffer'
* (isc_parse_buffer()).
*
+ * If 'bufname' is not NULL, it is a name for the buffer that
+ * can be reported when logging errors.
+ *
* Returns an error if the file does not parse correctly.
*
* Requires:
*/
cfg_obj_t * closed_files;
+ /*%
+ * Name of a buffer being parsed; used only for
+ * logging.
+ */
+ char const * buf_name;
+
/*%
* Current line number. We maintain our own
* copy of this so that it is available even
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id$ */
-
/*! \file */
#include <config.h>
pctx->callbackarg = NULL;
pctx->token.type = isc_tokentype_unknown;
pctx->flags = 0;
+ pctx->buf_name = NULL;
memset(specials, 0, sizeof(specials));
specials['{'] = 1;
const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
+ cfg_listelt_t *elt;
REQUIRE(filename != NULL);
CHECK(parser_openfile(pctx, filename));
- CHECK(parse2(pctx, type, ret));
+
+ result = parse2(pctx, type, ret);
+
+ /* Clean up the opened file */
+ elt = ISC_LIST_TAIL(pctx->open_files->value.list);
+ INSIST(elt != NULL);
+ ISC_LIST_UNLINK(pctx->open_files->value.list, elt, link);
+ ISC_LIST_APPEND(pctx->closed_files->value.list, elt, link);
+
cleanup:
return (result);
}
isc_result_t
cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
const cfg_type_t *type, cfg_obj_t **ret)
+{
+ return (cfg_parse_buffer2(pctx, buffer, NULL, type, ret));
+}
+
+isc_result_t
+cfg_parse_buffer2(cfg_parser_t *pctx, isc_buffer_t *buffer,
+ const char *bufname, const cfg_type_t *type,
+ cfg_obj_t **ret)
{
isc_result_t result;
REQUIRE(buffer != NULL);
CHECK(isc_lex_openbuffer(pctx->lexer, buffer));
+ pctx->buf_name = bufname;
CHECK(parse2(pctx, type, ret));
+ pctx->buf_name = NULL;
cleanup:
return (result);
if (have_current_file(pctx))
snprintf(where, sizeof(where), "%s:%u: ",
current_file(pctx), pctx->line);
+ else if (pctx->buf_name != NULL)
+ snprintf(where, sizeof(where), "%s: ", pctx->buf_name);
len = vsnprintf(message, sizeof(message), format, args);
if (len >= sizeof(message))