2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Improve the diagnostic 'rndc retransfer' error message

This commit is contained in:
Mark Andrews 2020-12-09 16:32:11 +11:00
parent 1fcc6132c4
commit dd3520ae41
4 changed files with 46 additions and 55 deletions

View File

@ -7493,36 +7493,12 @@ portset_fromconf(isc_portset_t *portset, const cfg_obj_t *ports,
static isc_result_t
removed(dns_zone_t *zone, void *uap) {
const char *type;
if (dns_zone_getview(zone) != uap) {
return (ISC_R_SUCCESS);
}
switch (dns_zone_gettype(zone)) {
case dns_zone_master:
type = "primary";
break;
case dns_zone_slave:
type = "secondary";
break;
case dns_zone_mirror:
type = "mirror";
break;
case dns_zone_stub:
type = "stub";
break;
case dns_zone_staticstub:
type = "static-stub";
break;
case dns_zone_redirect:
type = "redirect";
break;
default:
type = "other";
break;
}
dns_zone_log(zone, ISC_LOG_INFO, "(%s) removed", type);
dns_zone_log(zone, ISC_LOG_INFO, "(%s) removed",
dns_zonetype_name(dns_zone_gettype(zone)));
return (ISC_R_SUCCESS);
}
@ -10792,7 +10768,16 @@ named_server_retransfercommand(named_server_t *server, isc_lex_t *lex,
{
dns_zone_forcereload(zone);
} else {
result = ISC_R_NOTFOUND;
(void)putstr(text, "retransfer: inappropriate zone type: ");
(void)putstr(text, dns_zonetype_name(type));
if (type == dns_zone_redirect) {
type = dns_zone_getredirecttype(zone);
(void)putstr(text, "(");
(void)putstr(text, dns_zonetype_name(type));
(void)putstr(text, ")");
}
(void)putnull(text);
result = ISC_R_FAILURE;
}
dns_zone_detach(&zone);
return (result);
@ -15161,34 +15146,7 @@ named_server_zonestatus(named_server_t *server, isc_lex_t *lex,
zonetype = dns_zone_gettype(zone);
}
switch (zonetype) {
case dns_zone_master:
type = "primary";
break;
case dns_zone_slave:
type = "secondary";
break;
case dns_zone_mirror:
type = "mirror";
break;
case dns_zone_stub:
type = "stub";
break;
case dns_zone_staticstub:
type = "staticstub";
break;
case dns_zone_redirect:
type = "redirect";
break;
case dns_zone_key:
type = "key";
break;
case dns_zone_dlz:
type = "dlz";
break;
default:
type = "unknown";
}
type = dns_zonetype_name(zonetype);
/* Serial number */
result = dns_zone_getserial(mayberaw, &serial);

View File

@ -2585,4 +2585,10 @@ dns_zone_verifydb(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver);
* \li #DNS_R_VERIFYFAILURE any other case
*/
const char *
dns_zonetype_name(dns_zonetype_t type);
/*%<
* Return the name of the zone type 'type'.
*/
#endif /* DNS_ZONE_H */

View File

@ -1397,6 +1397,7 @@ dns_zonemgr_shutdown
dns_zonemgr_unreachable
dns_zonemgr_unreachableadd
dns_zonemgr_unreachabledel
dns_zonetype_name
dns_zoneverify_dnssec
dns_zt_apply
dns_zt_asyncload

View File

@ -15629,6 +15629,32 @@ dns_zone_gettype(dns_zone_t *zone) {
return (zone->type);
}
const char *
dns_zonetype_name(dns_zonetype_t type) {
switch (type) {
case dns_zone_none:
return ("none");
case dns_zone_master:
return ("primary");
case dns_zone_slave:
return ("secondary");
case dns_zone_mirror:
return ("mirror");
case dns_zone_stub:
return ("stub");
case dns_zone_staticstub:
return ("static-stub");
case dns_zone_key:
return ("key");
case dns_zone_dlz:
return ("dlz");
case dns_zone_redirect:
return ("redirect");
default:
return ("unknown");
}
}
dns_zonetype_t
dns_zone_getredirecttype(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));