update to 9.7.1-P2
[tridge/bind9.git] / bin / check / named-checkconf.c
index eba0d93b641d9940a1670345207130cb969080a0..e55b3403abf395cb09d96541930d5e4b207bc60f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2007, 2009  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2007, 2009, 2010  Internet Systems Consortium, Inc. ("ISC")
  * Copyright (C) 1999-2002  Internet Software Consortium.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: named-checkconf.c,v 1.46.222.2 2009/02/16 23:47:15 tbox Exp $ */
+/* $Id: named-checkconf.c,v 1.51.4.2 2010/03/09 23:49:55 tbox Exp $ */
 
 /*! \file */
 
@@ -59,9 +59,12 @@ isc_log_t *logc = NULL;
        } while (0)
 
 /*% usage */
+ISC_PLATFORM_NORETURN_PRE static void
+usage(void) ISC_PLATFORM_NORETURN_POST;
+
 static void
 usage(void) {
-       fprintf(stderr, "usage: %s [-h] [-j] [-v] [-z] [-t directory] "
+       fprintf(stderr, "usage: %s [-h] [-j] [-p] [-v] [-z] [-t directory] "
                "[named.conf]\n", program);
        exit(1);
 }
@@ -202,6 +205,24 @@ configure_zone(const char *vclass, const char *view,
                return (ISC_R_FAILURE);
        zfile = cfg_obj_asstring(fileobj);
 
+       obj = NULL;
+       if (get_maps(maps, "check-dup-records", &obj)) {
+               if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
+                       zone_options |= DNS_ZONEOPT_CHECKDUPRR;
+                       zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL;
+               } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
+                       zone_options |= DNS_ZONEOPT_CHECKDUPRR;
+                       zone_options |= DNS_ZONEOPT_CHECKDUPRRFAIL;
+               } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
+                       zone_options &= ~DNS_ZONEOPT_CHECKDUPRR;
+                       zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL;
+               } else
+                       INSIST(0);
+       } else {
+               zone_options |= DNS_ZONEOPT_CHECKDUPRR;
+               zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL;
+       }
+
        obj = NULL;
        if (get_maps(maps, "check-mx", &obj)) {
                if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
@@ -387,6 +408,15 @@ load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx) {
        return (result);
 }
 
+static void
+output(void *closure, const char *text, int textlen) {
+       UNUSED(closure);
+       if (fwrite(text, 1, textlen, stdout) != (size_t)textlen) {
+               perror("fwrite");
+               exit(1);
+       }
+}
+
 /*% The main processing routine */
 int
 main(int argc, char **argv) {
@@ -399,10 +429,11 @@ main(int argc, char **argv) {
        int exit_status = 0;
        isc_entropy_t *ectx = NULL;
        isc_boolean_t load_zones = ISC_FALSE;
+       isc_boolean_t print = ISC_FALSE;
 
        isc_commandline_errprint = ISC_FALSE;
 
-       while ((c = isc_commandline_parse(argc, argv, "dhjt:vz")) != EOF) {
+       while ((c = isc_commandline_parse(argc, argv, "dhjt:pvz")) != EOF) {
                switch (c) {
                case 'd':
                        debug++;
@@ -421,6 +452,10 @@ main(int argc, char **argv) {
                        }
                        break;
 
+               case 'p':
+                       print = ISC_TRUE;
+                       break;
+
                case 'v':
                        printf(VERSION "\n");
                        exit(0);
@@ -481,6 +516,8 @@ main(int argc, char **argv) {
                        exit_status = 1;
        }
 
+       if (print && exit_status == 0)
+               cfg_print(config, output, NULL);
        cfg_obj_destroy(parser, &config);
 
        cfg_parser_destroy(&parser);