zoneconf.c revision 54477d367bb80484ba8e9ca4eac43c0c317d4968
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Copyright (C) 1999, 2000 Internet Software Consortium.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Permission to use, copy, modify, and distribute this software for any
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * purpose with or without fee is hereby granted, provided that the above
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * copyright notice and this permission notice appear in all copies.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt/* $Id: zoneconf.c,v 1.62 2000/10/13 23:21:16 bwelling Exp $ */
bbedadf76ab670b01887fb9b41097120ea4fdf14Evan Hunt#include <isc/string.h> /* Required for HP/UX (and others?) */
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews * These are BIND9 server defaults, not necessarily identical to the
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews * library defaults defined in zone.c.
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews#define MAX_XFER_TIME (2*3600) /* Documented default is 2 hours. */
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews#define RETERR(x) do { \
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews * Convenience function for configuring a single zone ACL.
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrewsconfigure_zone_acl(dns_c_zone_t *czone, dns_c_ctx_t *cctx, dns_c_view_t *cview,
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews dns_aclconfctx_t *aclconfctx, dns_zone_t *zone,
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews if (result == ISC_R_NOTFOUND && getviewcacl != NULL && cview != NULL) {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt if (result == ISC_R_NOTFOUND && getglobalcacl != NULL) {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt result = dns_acl_fromconfig(cacl, cctx, aclconfctx,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Conver a config file zone type into a server zone type.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Hint and forward zones are not really zones;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * they should never get this far.
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * Helper function for strtoargv(). Pardon the gratuitous recursion.
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstrtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp,
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt char ***argvp, unsigned int n)
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt /* Discard leading whitespace. */
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt if (*s == '\0') {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt /* We have reached the end of the string. */
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt char *p = s;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (*p != '\0')
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt *p++ = '\0';
36b2d5f93c22b096c0417495f27ae0bdebf06ae1Evan Hunt result = strtoargvsub(mctx, p, argcp, argvp, n + 1);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * Tokenize the string "s" into whitespace-separated words,
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * return the number of words in '*argcp' and an array
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * of pointers to the words in '*argvp'. The caller
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * must free the array using isc_mem_put(). The string
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * is modified in-place.
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstrtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp) {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntdns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt unsigned int dbargc;
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * Configure values common to all zone types.
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt dns_zone_settype(zone, dns_zonetype_fromconf(czone->ztype));
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * ANSI C is strange here. There is no logical reason why (char **)
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * cannot be promoted automatically to (const char * const *) by the
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * compiler w/o generating a warning.
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt RETERR(dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv));
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt result = dns_c_zone_getchecknames(czone, &severity);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setchecknames(zone, dns_c_severity_warn);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#endif /* NOMINUM_PUBLIC */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * XXXAG This probably does not make sense for stubs.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setoption(zone, DNS_ZONEOPT_DIALUP, boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getnotifyforward(czone, &boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getnotifyforward(cview, &boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getnotifyforward(cctx, &boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setoption(zone, DNS_ZONEOPT_NOTIFYFORWARD, boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#endif /* NOMINUM_PUBLIC */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Configure master functionality. This applies
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * to primary masters (type "master") and slaves
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * acting as masters (type "slave"), but not to stubs.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getnotify(czone, ¬ifytype);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getnotify(cview, ¬ifytype);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getalsonotify(czone, &iplist);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getalsonotify(cview, &iplist);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_zone_setalsonotify(zone, iplist->ips,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxtranstimeout(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxtransidleout(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Configure update-related options. These apply to
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * primary masters only.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(configure_zone_acl(czone, cctx, NULL, ac, zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getsigvalidityinterval(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Configure slave functionality.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#else /* NOMINUM_PUBLIC */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#endif /* NOMINUM_PUBLIC */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxtranstimein(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxtransidlein(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_gettransfersource(czone, &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_gettransfersourcev6(czone, &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxrefreshtime(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getmaxrefreshtime(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxrefreshtime(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getminrefreshtime(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getminrefreshtime(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getminrefreshtime(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxretrytime(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getmaxretrytime(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxretrytime(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getminretrytime(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getminretrytime(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getminretrytime(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntdns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (dns_zonetype_fromconf(czone->ztype) != dns_zone_gettype(zone))