Merge from vendor branch SENDMAIL:
[dragonfly.git] / contrib / bind-9.2.4rc7 / bin / named / zoneconf.c
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: zoneconf.c,v 1.87.2.6 2004/03/09 06:09:20 marka Exp $ */
19
20 #include <config.h>
21
22 #include <isc/buffer.h>
23 #include <isc/mem.h>
24 #include <isc/string.h>         /* Required for HP/UX (and others?) */
25 #include <isc/util.h>
26
27 #include <dns/acl.h>
28 #include <dns/fixedname.h>
29 #include <dns/log.h>
30 #include <dns/name.h>
31 #include <dns/rdatatype.h>
32 #include <dns/ssu.h>
33 #include <dns/zone.h>
34
35 #include <named/config.h>
36 #include <named/globals.h>
37 #include <named/log.h>
38 #include <named/server.h>
39 #include <named/zoneconf.h>
40
41 /*
42  * These are BIND9 server defaults, not necessarily identical to the
43  * library defaults defined in zone.c.
44  */
45 #define RETERR(x) do { \
46         isc_result_t _r = (x); \
47         if (_r != ISC_R_SUCCESS) \
48                 return (_r); \
49         } while (0)
50
51 /*
52  * Convenience function for configuring a single zone ACL.
53  */
54 static isc_result_t
55 configure_zone_acl(cfg_obj_t *zconfig, cfg_obj_t *vconfig, cfg_obj_t *config,
56                    const char *aclname, ns_aclconfctx_t *actx,
57                    dns_zone_t *zone, 
58                    void (*setzacl)(dns_zone_t *, dns_acl_t *),
59                    void (*clearzacl)(dns_zone_t *))
60 {
61         isc_result_t result;
62         cfg_obj_t *maps[4];
63         cfg_obj_t *aclobj = NULL;
64         int i = 0;
65         dns_acl_t *dacl = NULL;
66
67         if (zconfig != NULL)
68                 maps[i++] = cfg_tuple_get(zconfig, "options");
69         if (vconfig != NULL)
70                 maps[i++] = cfg_tuple_get(vconfig, "options");
71         if (config != NULL) {
72                 cfg_obj_t *options = NULL;
73                 (void)cfg_map_get(config, "options", &options);
74                 if (options != NULL)
75                         maps[i++] = options;
76         }
77         maps[i] = NULL;
78
79         result = ns_config_get(maps, aclname, &aclobj);
80         if (aclobj == NULL) {
81                 (*clearzacl)(zone);
82                 return (ISC_R_SUCCESS);
83         }
84
85         result = ns_acl_fromconfig(aclobj, config, actx,
86                                    dns_zone_getmctx(zone), &dacl);
87         if (result != ISC_R_SUCCESS)
88                 return (result);
89         (*setzacl)(zone, dacl);
90         dns_acl_detach(&dacl);
91         return (ISC_R_SUCCESS);
92 }
93
94 /*
95  * Parse the zone update-policy statement.
96  */
97 static isc_result_t
98 configure_zone_ssutable(cfg_obj_t *zconfig, dns_zone_t *zone) {
99         cfg_obj_t *updatepolicy = NULL;
100         cfg_listelt_t *element, *element2;
101         dns_ssutable_t *table = NULL;
102         isc_mem_t *mctx = dns_zone_getmctx(zone);
103         isc_result_t result;
104
105         (void)cfg_map_get(zconfig, "update-policy", &updatepolicy);
106         if (updatepolicy == NULL)
107                 return (ISC_R_SUCCESS);
108
109         result = dns_ssutable_create(mctx, &table);
110         if (result != ISC_R_SUCCESS)
111                 return (result);
112
113         for (element = cfg_list_first(updatepolicy);
114              element != NULL;
115              element = cfg_list_next(element))
116         {
117                 cfg_obj_t *stmt = cfg_listelt_value(element);
118                 cfg_obj_t *mode = cfg_tuple_get(stmt, "mode");
119                 cfg_obj_t *identity = cfg_tuple_get(stmt, "identity");
120                 cfg_obj_t *matchtype = cfg_tuple_get(stmt, "matchtype");
121                 cfg_obj_t *dname = cfg_tuple_get(stmt, "name");
122                 cfg_obj_t *typelist = cfg_tuple_get(stmt, "types");
123                 char *str;
124                 isc_boolean_t grant = ISC_FALSE;
125                 unsigned int mtype = DNS_SSUMATCHTYPE_NAME;
126                 dns_fixedname_t fname, fident;
127                 isc_buffer_t b;
128                 dns_rdatatype_t *types;
129                 unsigned int i, n;
130
131                 str = cfg_obj_asstring(mode);
132                 if (strcasecmp(str, "grant") == 0)
133                         grant = ISC_TRUE;
134                 else if (strcasecmp(str, "deny") == 0)
135                         grant = ISC_FALSE;
136                 else
137                         INSIST(0);
138
139                 str = cfg_obj_asstring(matchtype);
140                 if (strcasecmp(str, "name") == 0)
141                         mtype = DNS_SSUMATCHTYPE_NAME;
142                 else if (strcasecmp(str, "subdomain") == 0)
143                         mtype = DNS_SSUMATCHTYPE_SUBDOMAIN;
144                 else if (strcasecmp(str, "wildcard") == 0)
145                         mtype = DNS_SSUMATCHTYPE_WILDCARD;
146                 else if (strcasecmp(str, "self") == 0)
147                         mtype = DNS_SSUMATCHTYPE_SELF;
148                 else
149                         INSIST(0);
150
151                 dns_fixedname_init(&fident);
152                 str = cfg_obj_asstring(identity);
153                 isc_buffer_init(&b, str, strlen(str));
154                 isc_buffer_add(&b, strlen(str));
155                 result = dns_name_fromtext(dns_fixedname_name(&fident), &b,
156                                            dns_rootname, ISC_FALSE, NULL);
157                 if (result != ISC_R_SUCCESS) {
158                         cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
159                                     "'%s' is not a valid name", str);
160                         goto cleanup;
161                 }
162
163                 dns_fixedname_init(&fname);
164                 str = cfg_obj_asstring(dname);
165                 isc_buffer_init(&b, str, strlen(str));
166                 isc_buffer_add(&b, strlen(str));
167                 result = dns_name_fromtext(dns_fixedname_name(&fname), &b,
168                                            dns_rootname, ISC_FALSE, NULL);
169                 if (result != ISC_R_SUCCESS) {
170                         cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
171                                     "'%s' is not a valid name", str);
172                         goto cleanup;
173                 }
174
175                 n = ns_config_listcount(typelist);
176                 if (n == 0)
177                         types = NULL;
178                 else {
179                         types = isc_mem_get(mctx, n * sizeof(dns_rdatatype_t));
180                         if (types == NULL) {
181                                 result = ISC_R_NOMEMORY;
182                                 goto cleanup;
183                         }
184                 }
185
186                 i = 0;
187                 for (element2 = cfg_list_first(typelist);
188                      element2 != NULL;
189                      element2 = cfg_list_next(element2))
190                 {
191                         cfg_obj_t *typeobj;
192                         isc_textregion_t r;
193
194                         INSIST(i < n);
195
196                         typeobj = cfg_listelt_value(element2);
197                         str = cfg_obj_asstring(typeobj);
198                         r.base = str;
199                         r.length = strlen(str);
200
201                         result = dns_rdatatype_fromtext(&types[i++], &r);
202                         if (result != ISC_R_SUCCESS) {
203                                 cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
204                                             "'%s' is not a valid type", str);
205                                 isc_mem_put(mctx, types,
206                                             n * sizeof(dns_rdatatype_t));
207                                 goto cleanup;
208                         }
209                 }
210                 INSIST(i == n);
211
212                 result = dns_ssutable_addrule(table, grant,
213                                               dns_fixedname_name(&fident),
214                                               mtype,
215                                               dns_fixedname_name(&fname),
216                                               n, types);
217                 if (types != NULL)
218                         isc_mem_put(mctx, types, n * sizeof(dns_rdatatype_t));
219                 if (result != ISC_R_SUCCESS) {
220                         goto cleanup;
221                 }
222
223         }
224
225         result = ISC_R_SUCCESS;
226         dns_zone_setssutable(zone, table);
227
228  cleanup:
229         dns_ssutable_detach(&table);
230         return (result);
231 }
232
233 /*
234  * Convert a config file zone type into a server zone type.
235  */
236 static inline dns_zonetype_t
237 zonetype_fromconfig(cfg_obj_t *map) {
238         cfg_obj_t *obj = NULL;
239         isc_result_t result;
240
241         result = cfg_map_get(map, "type", &obj);
242         INSIST(result == ISC_R_SUCCESS);
243         return (ns_config_getzonetype(obj));
244 }
245
246 /*
247  * Helper function for strtoargv().  Pardon the gratuitous recursion.
248  */
249 static isc_result_t
250 strtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp,
251              char ***argvp, unsigned int n)
252 {
253         isc_result_t result;
254         
255         /* Discard leading whitespace. */
256         while (*s == ' ' || *s == '\t')
257                 s++;
258         
259         if (*s == '\0') {
260                 /* We have reached the end of the string. */
261                 *argcp = n;
262                 *argvp = isc_mem_get(mctx, n * sizeof(char *));
263                 if (*argvp == NULL)
264                         return (ISC_R_NOMEMORY);
265         } else {
266                 char *p = s;
267                 while (*p != ' ' && *p != '\t' && *p != '\0')
268                         p++;
269                 if (*p != '\0')
270                         *p++ = '\0';
271
272                 result = strtoargvsub(mctx, p, argcp, argvp, n + 1);
273                 if (result != ISC_R_SUCCESS)
274                         return (result);
275                 (*argvp)[n] = s;
276         }
277         return (ISC_R_SUCCESS);
278 }
279
280 /*
281  * Tokenize the string "s" into whitespace-separated words,
282  * return the number of words in '*argcp' and an array
283  * of pointers to the words in '*argvp'.  The caller
284  * must free the array using isc_mem_put().  The string
285  * is modified in-place.
286  */
287 static isc_result_t
288 strtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp) {
289         return (strtoargvsub(mctx, s, argcp, argvp, 0));
290 }
291
292 isc_result_t
293 ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig,
294                   ns_aclconfctx_t *ac, dns_zone_t *zone)
295 {
296         isc_result_t result;
297         char *zname;
298         dns_rdataclass_t zclass;
299         dns_rdataclass_t vclass;
300         cfg_obj_t *maps[5];
301         cfg_obj_t *zoptions = NULL;
302         cfg_obj_t *options = NULL;
303         cfg_obj_t *obj;
304         const char *filename = NULL;
305         dns_notifytype_t notifytype = dns_notifytype_yes;
306         isc_sockaddr_t *addrs;
307         dns_name_t **keynames;
308         isc_uint32_t count;
309         char *cpval;
310         unsigned int dbargc;
311         char **dbargv;
312         static char default_dbtype[] = "rbt";
313         isc_mem_t *mctx = dns_zone_getmctx(zone);
314         dns_dialuptype_t dialup = dns_dialuptype_no;
315         dns_zonetype_t ztype;
316         int i;
317
318         i = 0;
319         if (zconfig != NULL) {
320                 zoptions = cfg_tuple_get(zconfig, "options");
321                 maps[i++] = zoptions;
322         }
323         if (vconfig != NULL)
324                 maps[i++] = cfg_tuple_get(vconfig, "options");
325         if (config != NULL) {
326                 (void)cfg_map_get(config, "options", &options);
327                 if (options != NULL)
328                         maps[i++] = options;
329         }
330         maps[i++] = ns_g_defaults;
331         maps[i++] = NULL;
332
333         if (vconfig != NULL)
334                 RETERR(ns_config_getclass(cfg_tuple_get(vconfig, "class"),
335                                           dns_rdataclass_in, &vclass));
336         else
337                 vclass = dns_rdataclass_in;
338
339         /*
340          * Configure values common to all zone types.
341          */
342
343         zname = cfg_obj_asstring(cfg_tuple_get(zconfig, "name"));
344
345         RETERR(ns_config_getclass(cfg_tuple_get(zconfig, "class"),
346                                   vclass, &zclass));
347         dns_zone_setclass(zone, zclass);
348
349         ztype = zonetype_fromconfig(zoptions);
350         dns_zone_settype(zone, ztype);
351
352         obj = NULL;
353         result = cfg_map_get(zoptions, "database", &obj);
354         if (result == ISC_R_SUCCESS)
355                 cpval = cfg_obj_asstring(obj);
356         else
357                 cpval = default_dbtype;
358         RETERR(strtoargv(mctx, cpval, &dbargc, &dbargv));
359         /*
360          * ANSI C is strange here.  There is no logical reason why (char **)
361          * cannot be promoted automatically to (const char * const *) by the
362          * compiler w/o generating a warning.
363          */
364         RETERR(dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv));
365         isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
366
367         obj = NULL;
368         result = cfg_map_get(zoptions, "file", &obj);
369         if (result == ISC_R_SUCCESS)
370                 filename = cfg_obj_asstring(obj);
371         RETERR(dns_zone_setfile(zone, filename));
372
373         if (ztype == dns_zone_slave)
374                 RETERR(configure_zone_acl(zconfig, vconfig, config,
375                                           "allow-notify", ac, zone,
376                                           dns_zone_setnotifyacl,
377                                           dns_zone_clearnotifyacl));
378         /*
379          * XXXAG This probably does not make sense for stubs.
380          */
381         RETERR(configure_zone_acl(zconfig, vconfig, config,
382                                   "allow-query", ac, zone,
383                                   dns_zone_setqueryacl,
384                                   dns_zone_clearqueryacl));
385
386         obj = NULL;
387         result = ns_config_get(maps, "dialup", &obj);
388         INSIST(result == ISC_R_SUCCESS);
389         if (cfg_obj_isboolean(obj)) {
390                 if (cfg_obj_asboolean(obj))
391                         dialup = dns_dialuptype_yes;
392                 else
393                         dialup = dns_dialuptype_no;
394         } else {
395                 char *dialupstr = cfg_obj_asstring(obj);
396                 if (strcasecmp(dialupstr, "notify") == 0)
397                         dialup = dns_dialuptype_notify;
398                 else if (strcasecmp(dialupstr, "notify-passive") == 0)
399                         dialup = dns_dialuptype_notifypassive;
400                 else if (strcasecmp(dialupstr, "refresh") == 0)
401                         dialup = dns_dialuptype_refresh;
402                 else if (strcasecmp(dialupstr, "passive") == 0)
403                         dialup = dns_dialuptype_passive;
404                 else
405                         INSIST(0);
406         }
407         dns_zone_setdialup(zone, dialup);
408
409         obj = NULL;
410         result = ns_config_get(maps, "zone-statistics", &obj);
411         INSIST(result == ISC_R_SUCCESS);
412         dns_zone_setstatistics(zone, cfg_obj_asboolean(obj));
413
414         /*
415          * Configure master functionality.  This applies
416          * to primary masters (type "master") and slaves
417          * acting as masters (type "slave"), but not to stubs.
418          */
419         if (ztype != dns_zone_stub) {
420                 obj = NULL;
421                 result = ns_config_get(maps, "notify", &obj);
422                 INSIST(result == ISC_R_SUCCESS);
423                 if (cfg_obj_isboolean(obj)) {
424                         if (cfg_obj_asboolean(obj))
425                                 notifytype = dns_notifytype_yes;
426                         else
427                                 notifytype = dns_notifytype_no;
428                 } else {
429                         char *notifystr = cfg_obj_asstring(obj);
430                         if (strcasecmp(notifystr, "explicit") == 0)
431                                 notifytype = dns_notifytype_explicit;
432                         else
433                                 INSIST(0);
434                 }
435                 dns_zone_setnotifytype(zone, notifytype);
436
437                 obj = NULL;
438                 result = ns_config_get(maps, "also-notify", &obj);
439                 if (result == ISC_R_SUCCESS) {
440                         isc_sockaddr_t *addrs = NULL;
441                         isc_uint32_t addrcount;
442                         result = ns_config_getiplist(config, obj, 0, mctx,
443                                                      &addrs, &addrcount);
444                         if (result != ISC_R_SUCCESS)
445                                 return (result);
446                         result = dns_zone_setalsonotify(zone, addrs,
447                                                         addrcount);
448                         ns_config_putiplist(mctx, &addrs, addrcount);
449                         if (result != ISC_R_SUCCESS)
450                                 return (result);
451                 } else
452                         RETERR(dns_zone_setalsonotify(zone, NULL, 0));
453
454                 obj = NULL;
455                 result = ns_config_get(maps, "notify-source", &obj);
456                 INSIST(result == ISC_R_SUCCESS);
457                 dns_zone_setnotifysrc4(zone, cfg_obj_assockaddr(obj));
458                 ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
459
460                 obj = NULL;
461                 result = ns_config_get(maps, "notify-source-v6", &obj);
462                 INSIST(result == ISC_R_SUCCESS);
463                 dns_zone_setnotifysrc6(zone, cfg_obj_assockaddr(obj));
464                 ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
465
466                 RETERR(configure_zone_acl(zconfig, vconfig, config,
467                                           "allow-transfer", ac, zone,
468                                           dns_zone_setxfracl,
469                                           dns_zone_clearxfracl));
470
471                 obj = NULL;
472                 result = ns_config_get(maps, "max-transfer-time-out", &obj);
473                 INSIST(result == ISC_R_SUCCESS);
474                 dns_zone_setmaxxfrout(zone, cfg_obj_asuint32(obj) * 60);
475
476                 obj = NULL;
477                 result = ns_config_get(maps, "max-transfer-idle-out", &obj);
478                 INSIST(result == ISC_R_SUCCESS);
479                 dns_zone_setidleout(zone, cfg_obj_asuint32(obj) * 60);
480         }
481
482         /*
483          * Configure update-related options.  These apply to
484          * primary masters only.
485          */
486         if (ztype == dns_zone_master) {
487                 dns_acl_t *updateacl;
488                 RETERR(configure_zone_acl(zconfig, vconfig, config,
489                                           "allow-update", ac, zone,
490                                           dns_zone_setupdateacl,
491                                           dns_zone_clearupdateacl));
492                 
493                 updateacl = dns_zone_getupdateacl(zone);
494                 if (updateacl != NULL  && dns_acl_isinsecure(updateacl))
495                         isc_log_write(ns_g_lctx, DNS_LOGCATEGORY_SECURITY,
496                                       NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
497                                       "zone '%s' allows updates by IP "
498                                       "address, which is insecure",
499                                       zname);
500                 
501                 RETERR(configure_zone_ssutable(zoptions, zone));
502
503                 obj = NULL;
504                 result = ns_config_get(maps, "sig-validity-interval", &obj);
505                 INSIST(result == ISC_R_SUCCESS);
506                 dns_zone_setsigvalidityinterval(zone,
507                                                 cfg_obj_asuint32(obj) * 86400);
508         } else if (ztype == dns_zone_slave) {
509                 RETERR(configure_zone_acl(zconfig, vconfig, config,
510                                           "allow-update-forwarding", ac, zone,
511                                           dns_zone_setforwardacl,
512                                           dns_zone_clearforwardacl));
513         }
514
515         /*
516          * Configure slave functionality.
517          */
518         switch (ztype) {
519         case dns_zone_slave:
520         case dns_zone_stub:
521                 obj = NULL;
522                 result = cfg_map_get(zoptions, "masters", &obj);
523                 if (obj != NULL) {
524                         addrs = NULL;
525                         keynames = NULL;
526                         RETERR(ns_config_getipandkeylist(config, obj, mctx,
527                                                          &addrs, &keynames,
528                                                          &count));
529                         result = dns_zone_setmasterswithkeys(zone, addrs,
530                                                              keynames, count);
531                         ns_config_putipandkeylist(mctx, &addrs, &keynames,
532                                                   count);
533                 } else
534                         result = dns_zone_setmasters(zone, NULL, 0);
535                 RETERR(result);
536
537                 obj = NULL;
538                 result = ns_config_get(maps, "max-transfer-time-in", &obj);
539                 INSIST(result == ISC_R_SUCCESS);
540                 dns_zone_setmaxxfrin(zone, cfg_obj_asuint32(obj) * 60);
541
542                 obj = NULL;
543                 result = ns_config_get(maps, "max-transfer-idle-in", &obj);
544                 INSIST(result == ISC_R_SUCCESS);
545                 dns_zone_setidlein(zone, cfg_obj_asuint32(obj) * 60);
546
547                 obj = NULL;
548                 result = ns_config_get(maps, "max-refresh-time", &obj);
549                 INSIST(result == ISC_R_SUCCESS);
550                 dns_zone_setmaxrefreshtime(zone, cfg_obj_asuint32(obj));
551
552                 obj = NULL;
553                 result = ns_config_get(maps, "min-refresh-time", &obj);
554                 INSIST(result == ISC_R_SUCCESS);
555                 dns_zone_setminrefreshtime(zone, cfg_obj_asuint32(obj));
556
557                 obj = NULL;
558                 result = ns_config_get(maps, "max-retry-time", &obj);
559                 INSIST(result == ISC_R_SUCCESS);
560                 dns_zone_setmaxretrytime(zone, cfg_obj_asuint32(obj));
561
562                 obj = NULL;
563                 result = ns_config_get(maps, "min-retry-time", &obj);
564                 INSIST(result == ISC_R_SUCCESS);
565                 dns_zone_setminretrytime(zone, cfg_obj_asuint32(obj));
566
567                 obj = NULL;
568                 result = ns_config_get(maps, "transfer-source", &obj);
569                 INSIST(result == ISC_R_SUCCESS);
570                 dns_zone_setxfrsource4(zone, cfg_obj_assockaddr(obj));
571                 ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
572
573                 obj = NULL;
574                 result = ns_config_get(maps, "transfer-source-v6", &obj);
575                 INSIST(result == ISC_R_SUCCESS);
576                 dns_zone_setxfrsource6(zone, cfg_obj_assockaddr(obj));
577                 ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
578
579                 break;
580
581         default:
582                 break;
583         }
584
585         return (ISC_R_SUCCESS);
586 }
587
588 isc_boolean_t
589 ns_zone_reusable(dns_zone_t *zone, cfg_obj_t *zconfig) {
590         cfg_obj_t *zoptions = NULL;
591         cfg_obj_t *obj = NULL;
592         const char *cfilename;
593         const char *zfilename;
594
595         zoptions = cfg_tuple_get(zconfig, "options");
596
597         if (zonetype_fromconfig(zoptions) != dns_zone_gettype(zone))
598                 return (ISC_FALSE);
599
600         obj = NULL;
601         (void)cfg_map_get(zoptions, "file", &obj);
602         if (obj != NULL)
603                 cfilename = cfg_obj_asstring(obj);
604         else
605                 cfilename = NULL;
606         zfilename = dns_zone_getfile(zone);
607         if (!((cfilename == NULL && zfilename == NULL) ||
608               (cfilename != NULL && zfilename != NULL &&
609                strcmp(cfilename, zfilename) == 0)))
610             return (ISC_FALSE);
611
612         return (ISC_TRUE);
613 }