From f71d213e0c6433327c04daa52d1f8b72147e0045 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Wed, 1 Nov 2017 21:50:31 +0100
Subject: [PATCH 2/3] Remove new-zones-directory option in favor of
 databases-directory.

---
 bin/named/server.c                       |  5 -----
 bin/tests/system/addzone/ns2/named3.conf |  2 +-
 bin/tests/system/addzone/tests.sh        |  6 +++---
 doc/arm/Bv9ARM-book.xml                  | 12 ------------
 lib/dns/include/dns/view.h               | 14 --------------
 lib/dns/view.c                           | 32 ++------------------------------
 lib/isccfg/namedconf.c                   |  1 -
 7 files changed, 6 insertions(+), 66 deletions(-)

diff --git a/bin/named/server.c b/bin/named/server.c
index 9379e93..bd6476b 100644
--- a/bin/named/server.c
+++ b/bin/named/server.c
@@ -7044,7 +7044,6 @@ setup_newzones(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
 	const cfg_obj_t *maps[4];
 	const cfg_obj_t *options = NULL, *voptions = NULL;
 	const cfg_obj_t *nz = NULL;
-	const char *dir = NULL;
 	const cfg_obj_t *obj = NULL;
 	int i = 0;
 	isc_uint64_t mapsize = 0ULL;
@@ -7064,10 +7063,6 @@ setup_newzones(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
 	result = named_config_get(maps, "allow-new-zones", &nz);
 	if (result == ISC_R_SUCCESS)
 		allow = cfg_obj_asboolean(nz);
-	CHECK(directory_fromconfig(maps, "new-zones-directory", &dir));
-	if (!dir)
-		dir = dns_view_getdbdir(view);
-	dns_view_setnewzonedir(view, dir);
 
 #ifdef HAVE_LMDB
 	result = named_config_get(maps, "lmdb-mapsize", &obj);
diff --git a/bin/tests/system/addzone/ns2/named3.conf b/bin/tests/system/addzone/ns2/named3.conf
index 2bb92f5..1961a9a 100644
--- a/bin/tests/system/addzone/ns2/named3.conf
+++ b/bin/tests/system/addzone/ns2/named3.conf
@@ -16,7 +16,7 @@ options {
 	listen-on { 10.53.0.2; 10.53.0.4; 10.53.0.5; };
 	listen-on-v6 { none; };
 	recursion no;
-	new-zones-directory "new-zones";
+	databases-directory "new-zones";
 };
 
 view internal {
diff --git a/bin/tests/system/addzone/tests.sh b/bin/tests/system/addzone/tests.sh
index fe14f9e..0ef38f1 100755
--- a/bin/tests/system/addzone/tests.sh
+++ b/bin/tests/system/addzone/tests.sh
@@ -583,7 +583,7 @@ n=`expr $n + 1`
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
-echo "I:reconfiguring server with multiple views and new-zones-directory"
+echo "I:reconfiguring server with multiple views and databases-directory"
 rm -f ns2/named.conf
 cp -f ns2/named3.conf ns2/named.conf
 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig 2>&1 | sed 's/^/I:ns2 /'
@@ -629,10 +629,10 @@ if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
 if [ -n "$NZD" ]; then
-    echo "I:checking NZD file was created in new-zones-directory ($n)"
+    echo "I:checking NZD file was created in databases-directory ($n)"
     expect=ns2/new-zones/directory.nzd
 else
-    echo "I:checking NZF file was created in new-zones-directory ($n)"
+    echo "I:checking NZF file was created in databases-directory ($n)"
     expect=ns2/new-zones/directory.nzf
 fi
 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 sync 'added.example IN directory' 2>&1 | sed 's/^/I:ns2 /'
diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml
index 3fbc77b..8e40e1d 100644
--- a/doc/arm/Bv9ARM-book.xml
+++ b/doc/arm/Bv9ARM-book.xml
@@ -4262,7 +4262,6 @@ badresp:1,adberr:0,findfail:0,valfail:0]
   [ <command>geoip-directory</command> <replaceable>path_name</replaceable> ; ]
   [ <command>key-directory</command> <replaceable>path_name</replaceable> ; ]
   [ <command>managed-keys-directory</command> <replaceable>path_name</replaceable> ; ]
-  [ <command>new-zones-directory</command> <replaceable>path_name</replaceable> ; ]
   [ <command>databases-directory</command> <replaceable>path_name</replaceable> ; ]
   [ <command>named-xfer</command> <replaceable>path_name</replaceable> ; ]
   [ <command>tkey-gssapi-keytab</command> <replaceable>path_name</replaceable> ; ]
@@ -4982,17 +4981,6 @@ badresp:1,adberr:0,findfail:0,valfail:0]
 	  </varlistentry>
 
 	  <varlistentry>
-	    <term><command>new-zones-directory</command></term>
-	    <listitem>
-	      <para>
-		Specifies the directory in which to store the configuration
-		parameters for zones added via <command>rndc addzone</command>.
-		By default, this is the working directory.
-	      </para>
-	    </listitem>
-	  </varlistentry>
-
-	  <varlistentry>
 	    <term><command>databases-directory</command></term>
 	    <listitem>
 	      <para>
diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h
index bbc4c1a..18e8e3e 100644
--- a/lib/dns/include/dns/view.h
+++ b/lib/dns/include/dns/view.h
@@ -214,7 +214,6 @@ struct dns_view {
 	 * XXX: This should be a pointer to an opaque type that
 	 * named implements.
 	 */
-	char *				new_zone_dir;
 	char *				new_zone_file;
 	char *				new_zone_db;
 	void *				new_zone_dbenv;
@@ -1247,19 +1246,6 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
  */
 
 void
-dns_view_setnewzonedir(dns_view_t *view, const char *dir);
-const char *
-dns_view_getnewzonedir(dns_view_t *view);
-/*%<
- * Set/get the path to the directory in which NZF or NZD files should
- * be stored. If the path was previously set to a non-NULL value,
- * the previous value is freed.
- *
- * Requires:
- * \li 'view' is valid.
- */
-
-void
 dns_view_restorekeyring(dns_view_t *view);
 
 isc_result_t
diff --git a/lib/dns/view.c b/lib/dns/view.c
index 08d3ac0..a693aa1 100644
--- a/lib/dns/view.c
+++ b/lib/dns/view.c
@@ -232,7 +232,6 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
 	view->requireservercookie = ISC_FALSE;
 	view->synthfromdnssec = ISC_TRUE;
 	view->trust_anchor_telemetry = ISC_TRUE;
-	view->new_zone_dir = NULL;
 	view->new_zone_file = NULL;
 	view->new_zone_db = NULL;
 	view->new_zone_dbenv = NULL;
@@ -506,10 +505,6 @@ destroy(dns_view_t *view) {
 		isc_mem_free(view->mctx, view->new_zone_file);
 		view->new_zone_file = NULL;
 	}
-	if (view->new_zone_dir != NULL) {
-		isc_mem_free(view->mctx, view->new_zone_dir);
-		view->new_zone_dir = NULL;
-	}
 #ifdef HAVE_LMDB
 	if (view->new_zone_dbenv != NULL)
 		mdb_env_close((MDB_env *) view->new_zone_dbenv);
@@ -2075,7 +2070,7 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
 		return (ISC_R_SUCCESS);
 	}
 
-	CHECK(nz_legacy(view->new_zone_dir, view->name, "nzf",
+	CHECK(nz_legacy(view->db_dir, view->name, "nzf",
 			buffer, sizeof(buffer)));
 
 	view->new_zone_file = isc_mem_strdup(view->mctx, buffer);
@@ -2084,7 +2079,7 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
 	}
 
 #ifdef HAVE_LMDB
-	CHECK(nz_legacy(view->new_zone_dir, view->name, "nzd",
+	CHECK(nz_legacy(view->db_dir, view->name, "nzd",
 			buffer, sizeof(buffer)));
 
 	view->new_zone_db = isc_mem_strdup(view->mctx, buffer);
@@ -2152,29 +2147,6 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
 	return (result);
 }
 
-void
-dns_view_setnewzonedir(dns_view_t *view, const char *dir) {
-	REQUIRE(DNS_VIEW_VALID(view));
-
-	if (view->new_zone_dir != NULL) {
-		isc_mem_free(view->mctx, view->new_zone_dir);
-		view->new_zone_dir = NULL;
-	}
-
-	if (dir == NULL) {
-		return;
-	}
-
-	view->new_zone_dir = isc_mem_strdup(view->mctx, dir);
-}
-
-const char *
-dns_view_getnewzonedir(dns_view_t *view) {
-	REQUIRE(DNS_VIEW_VALID(view));
-
-	return (view->new_zone_dir);
-}
-
 isc_result_t
 dns_view_searchdlz(dns_view_t *view, const dns_name_t *name,
 		   unsigned int minlabels, dns_clientinfomethods_t *methods,
diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c
index 51f7180..f5d0ba0 100644
--- a/lib/isccfg/namedconf.c
+++ b/lib/isccfg/namedconf.c
@@ -1930,7 +1930,6 @@ view_clauses[] = {
 	{ "min-roots", &cfg_type_uint32, CFG_CLAUSEFLAG_NOTIMP },
 	{ "minimal-any", &cfg_type_boolean, 0 },
 	{ "minimal-responses", &cfg_type_minimal, 0 },
-	{ "new-zones-directory", &cfg_type_qstring, 0 },
 	{ "no-case-compress", &cfg_type_bracketed_aml, 0 },
 	{ "nocookie-udp-size", &cfg_type_uint32, 0 },
 	{ "nosit-udp-size", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE },
-- 
2.9.5

