rndc reconfig reports configuration errors the same way rndc reload does [RT #39635]

This commit is contained in:
Witold Krecicki 2015-06-12 10:19:29 +02:00
parent ed2fcdc27f
commit ece6e87818
5 changed files with 36 additions and 25 deletions

View file

@ -1,3 +1,6 @@
4137. [bug] rndc reconfig reports configuration errors the same
way rndc reload does [RT #39635]
4132. [cleanup] dig: added +rd as a synonym for +recurse,
added +class as an unabbreviated alternative
to +cl. [RT #39686]

View file

@ -101,7 +101,7 @@ ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
if (command_compare(command, NS_COMMAND_RELOAD)) {
result = ns_server_reloadcommand(ns_g_server, command, text);
} else if (command_compare(command, NS_COMMAND_RECONFIG)) {
result = ns_server_reconfigcommand(ns_g_server, command);
result = ns_server_reconfigcommand(ns_g_server);
} else if (command_compare(command, NS_COMMAND_REFRESH)) {
result = ns_server_refreshcommand(ns_g_server, command, text);
} else if (command_compare(command, NS_COMMAND_RETRANSFER)) {

View file

@ -213,7 +213,7 @@ ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text);
*/
isc_result_t
ns_server_reconfigcommand(ns_server_t *server, char *args);
ns_server_reconfigcommand(ns_server_t *server);
/*%<
* Act on a "reconfig" command from the command channel.
*/

View file

@ -6474,25 +6474,6 @@ reload(ns_server_t *server) {
return (result);
}
static void
reconfig(ns_server_t *server) {
isc_result_t result;
CHECK(loadconfig(server));
result = load_new_zones(server, ISC_FALSE);
if (result == ISC_R_SUCCESS)
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_INFO,
"any newly configured zones are now loaded");
else
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
"loading new zones failed: %s",
isc_result_totext(result));
cleanup: ;
}
/*
* Handle a reload event (from SIGHUP).
*/
@ -6730,11 +6711,23 @@ ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text) {
* Act on a "reconfig" command from the command channel.
*/
isc_result_t
ns_server_reconfigcommand(ns_server_t *server, char *args) {
UNUSED(args);
ns_server_reconfigcommand(ns_server_t *server) {
isc_result_t result;
reconfig(server);
return (ISC_R_SUCCESS);
CHECK(loadconfig(server));
result = load_new_zones(server, ISC_FALSE);
if (result == ISC_R_SUCCESS)
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_INFO,
"any newly configured zones are now loaded");
else
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
"loading new zones failed: %s",
isc_result_totext(result));
cleanup:
return (result);
}
/*

View file

@ -275,5 +275,20 @@ grep "query: foo9876.bind CH TXT" ns3/named.run > /dev/null && ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:test 'rndc reconfig' with a broken config"
ret=0
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reconfig > /dev/null || ret=1
sleep 1
mv ns3/named.conf ns3/named.conf.save
echo "error error error" >> ns3/named.conf
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reconfig > rndc.output 2>&1 && ret=1
grep "rndc: 'reconfig' failed: unexpected token" rndc.output > /dev/null || ret=1
mv ns3/named.conf.save ns3/named.conf
sleep 1
$RNDC -s 10.53.0.3 -p 9953 -c ../common/rndc.conf reconfig > /dev/null || ret=1
sleep 1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:exit status: $status"
exit $status