]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
make named-checkconf able to check dns64 module parameters 15-dns64-module 968/head
authorEvan Hunt <each@isc.org>
Sat, 3 Nov 2018 23:04:58 +0000 (16:04 -0700)
committerEvan Hunt <each@isc.org>
Fri, 30 Aug 2019 22:27:56 +0000 (15:27 -0700)
- restored the checkconf test cases from the dns64 system test
- implemented plugin_check() in the dns64 module

16 files changed:
bin/plugins/dns64.c
bin/tests/system/dns64/conf/bad1.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/bad2.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/bad3.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/bad4.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/bad5.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/bad6.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/bad7.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/bad8.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/bad9.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/good1.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/good2.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/good3.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/good4.conf [new file with mode: 0644]
bin/tests/system/dns64/conf/good5.conf [new file with mode: 0644]
bin/tests/system/dns64/tests.sh

index 1fcb2de2d329fa36e0ff8f39b12bf4bf898ecdb9..c7320466226e4a0999641c395c756edcc35a2a9f 100644 (file)
@@ -412,7 +412,7 @@ cleanup:
 }
 
 static isc_result_t
-check_syntax(cfg_obj_t *dmap, const cfg_obj_t *cfg,
+check_syntax(cfg_obj_t *dmap, const void *cfg,
             isc_mem_t *mctx, isc_log_t *lctx, void *actx)
 {
        isc_result_t result = ISC_R_SUCCESS;
@@ -537,8 +537,7 @@ parse_parameters(dns64_instance_t *inst, const char *parameters,
        CHECK(cfg_parse_buffer(parser, &b, cfg_file, cfg_line,
                               &cfg_type_parameters, 0, &param_obj));
 
-       CHECK(check_syntax(param_obj, (const cfg_obj_t *) cfg,
-                          mctx, lctx, actx));
+       CHECK(check_syntax(param_obj, cfg, mctx, lctx, actx));
 
        CHECK(cfg_map_get(param_obj, "dns64", &dns64_obj));
 
@@ -1106,15 +1105,28 @@ plugin_check(const char *parameters,
             const void *cfg, const char *cfg_file, unsigned long cfg_line,
             isc_mem_t *mctx, isc_log_t *lctx, void *actx)
 {
-       UNUSED(parameters);
-       UNUSED(cfg_file);
-       UNUSED(cfg_line);
-       UNUSED(cfg);
-       UNUSED(mctx);
-       UNUSED(lctx);
-       UNUSED(actx);
+       isc_result_t result = ISC_R_SUCCESS;
+       cfg_parser_t *parser = NULL;
+       cfg_obj_t *param_obj = NULL;
+       isc_buffer_t b;
 
-       return (ISC_R_SUCCESS);
+       CHECK(cfg_parser_create(mctx, lctx, &parser));
+
+       isc_buffer_constinit(&b, parameters, strlen(parameters));
+       isc_buffer_add(&b, strlen(parameters));
+       CHECK(cfg_parse_buffer(parser, &b, cfg_file, cfg_line,
+                              &cfg_type_parameters, 0, &param_obj));
+
+       CHECK(check_syntax(param_obj, cfg, mctx, lctx, actx));
+
+ cleanup:
+       if (param_obj != NULL) {
+               cfg_obj_destroy(parser, &param_obj);
+       }
+       if (parser != NULL) {
+               cfg_parser_destroy(&parser);
+       }
+       return (result);
 }
 
 /*
diff --git a/bin/tests/system/dns64/conf/bad1.conf b/bin/tests/system/dns64/conf/bad1.conf
new file mode 100644 (file)
index 0000000..1a21f57
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 ::/0 { };
+};
diff --git a/bin/tests/system/dns64/conf/bad2.conf b/bin/tests/system/dns64/conf/bad2.conf
new file mode 100644 (file)
index 0000000..667b140
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 ::/96 { suffix ::1; };
+};
diff --git a/bin/tests/system/dns64/conf/bad3.conf b/bin/tests/system/dns64/conf/bad3.conf
new file mode 100644 (file)
index 0000000..ac1fa3e
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 ::/96 { suffix 127.0.0.1; };
+};
diff --git a/bin/tests/system/dns64/conf/bad4.conf b/bin/tests/system/dns64/conf/bad4.conf
new file mode 100644 (file)
index 0000000..78944f8
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 ::/129 { };
+};
diff --git a/bin/tests/system/dns64/conf/bad5.conf b/bin/tests/system/dns64/conf/bad5.conf
new file mode 100644 (file)
index 0000000..78944f8
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 ::/129 { };
+};
diff --git a/bin/tests/system/dns64/conf/bad6.conf b/bin/tests/system/dns64/conf/bad6.conf
new file mode 100644 (file)
index 0000000..4a2472b
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 :: { };
+};
diff --git a/bin/tests/system/dns64/conf/bad7.conf b/bin/tests/system/dns64/conf/bad7.conf
new file mode 100644 (file)
index 0000000..f5cd89b
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 FC36:EAFE:F993::/64 {
+               exclude { bogusacl; };
+       };
+};
diff --git a/bin/tests/system/dns64/conf/bad8.conf b/bin/tests/system/dns64/conf/bad8.conf
new file mode 100644 (file)
index 0000000..9a04c54
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 FC36:EAFE:F993::/64 {
+               clients { bogusacl; };
+       };
+};
diff --git a/bin/tests/system/dns64/conf/bad9.conf b/bin/tests/system/dns64/conf/bad9.conf
new file mode 100644 (file)
index 0000000..4340004
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+plugin query "../../../plugins/lib/dns64.so" {
+       dns64 FC36:EAFE:F993::/64 {
+               mapped { bogusacl; };
+       };
+};
diff --git a/bin/tests/system/dns64/conf/good1.conf b/bin/tests/system/dns64/conf/good1.conf
new file mode 100644 (file)
index 0000000..2e4a518
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+acl rfc1918 { 10/8; 192.168/16; 172.16/12; };
+plugin query "../../../plugins/lib/dns64.so" {
+       /* Well Known Prefix */
+       dns64 64:FF9B::/96 {
+               clients { any; };
+               mapped { !rfc1918; any; };
+               exclude { ::ffff:0:0/96; };
+       };
+};
diff --git a/bin/tests/system/dns64/conf/good2.conf b/bin/tests/system/dns64/conf/good2.conf
new file mode 100644 (file)
index 0000000..cd95145
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+acl rfc1918 { 10/8; 192.168/16; 172.16/12; };
+plugin query "../../../plugins/lib/dns64.so" {
+       /* Well Known Prefix */
+       dns64 64:FF9B::/96 {
+               mapped { !rfc1918; any; };
+               exclude { ::ffff:0:0/96; };
+       };
+};
diff --git a/bin/tests/system/dns64/conf/good3.conf b/bin/tests/system/dns64/conf/good3.conf
new file mode 100644 (file)
index 0000000..bcb2249
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+acl rfc1918 { 10/8; 192.168/16; 172.16/12; };
+plugin query "../../../plugins/lib/dns64.so" {
+       /* Well Known Prefix */
+       dns64 64:FF9B::/96 {
+               clients { any; };
+               exclude { ::ffff:0:0/96; };
+       };
+};
diff --git a/bin/tests/system/dns64/conf/good4.conf b/bin/tests/system/dns64/conf/good4.conf
new file mode 100644 (file)
index 0000000..778f63e
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+acl rfc1918 { 10/8; 192.168/16; 172.16/12; };
+plugin query "../../../plugins/lib/dns64.so" {
+       /* Well Known Prefix */
+       dns64 64:FF9B::/96 {
+               clients { any; };
+               mapped { !rfc1918; any; };
+       };
+};
diff --git a/bin/tests/system/dns64/conf/good5.conf b/bin/tests/system/dns64/conf/good5.conf
new file mode 100644 (file)
index 0000000..c4c84f2
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+acl rfc1918 { 10/8; 192.168/16; 172.16/12; };
+plugin query "../../../plugins/lib/dns64.so" {
+       /* Well Known Prefix */
+       dns64 64:FF9B::/96 { };
+};
index bdc6103275687248bc1ccf3f49dc1ef4a6d72c10..488302b034765e59da46081e00f3bf51ccec0ea0 100644 (file)
@@ -19,6 +19,26 @@ rm -f dig.out.*
 
 DIGOPTS="+tcp +noadd +nosea +nostat +nocmd -p ${PORT}"
 
+for conf in conf/good*.conf
+do
+       n=`expr $n + 1`
+       echo_i "checking that $conf is accepted ($n)"
+       ret=0
+       $CHECKCONF "$conf" || ret=1
+       if [ $ret != 0 ]; then echo_i "failed"; fi
+       status=`expr $status + $ret`
+done
+
+for conf in conf/bad*.conf
+do
+       n=`expr $n + 1`
+       echo_i "checking that $conf is rejected ($n)"
+       ret=0
+       $CHECKCONF "$conf" >/dev/null && ret=1
+       if [ $ret != 0 ]; then echo_i "failed"; fi
+       status=`expr $status + $ret`
+done
+
 # Check the example. domain
 
 echo_i "checking non-excluded AAAA lookup works ($n)"