Close FILEs before overwriting NZF file (#38332)

Based on a patch sent in by Tony Finch <dot@dotat.at>.

(cherry picked from commit 1721fb782c)

Conflicts:
	CHANGES
	bin/named/server.c
This commit is contained in:
Mukund Sivaraman
2015-01-16 15:41:15 +05:30
parent a36c06520a
commit ece19205b7
2 changed files with 17 additions and 3 deletions
+4
View File
@@ -1,3 +1,7 @@
4035. [bug] Close temporary and NZF FILE pointers before moving
the former into the latter's place, as required on
Windows. [RT #38332]
4032. [bug] Built-in "empty" zones did not correctly inherit the
"allow-transfer" ACL from the options or view.
[RT #38310]
+13 -3
View File
@@ -8581,6 +8581,16 @@ ns_server_del_zone(ns_server_t *server, char *args, isc_buffer_t *text) {
result = isc_stdio_read(buf, 1, 1024, ifp, &n);
}
/*
* Close files before overwriting the nzfile
* with the temporary file as it's necessary on
* some platforms (win32).
*/
(void) isc_stdio_close(ifp);
ifp = NULL;
(void) isc_stdio_close(ofp);
ofp = NULL;
/* Move temporary into place */
CHECK(isc_file_rename(tmpname, view->new_zone_file));
} else {
@@ -8611,12 +8621,12 @@ ns_server_del_zone(ns_server_t *server, char *args, isc_buffer_t *text) {
putnull(text);
if (ifp != NULL)
isc_stdio_close(ifp);
if (ofp != NULL) {
if (ofp != NULL)
isc_stdio_close(ofp);
if (tmpname != NULL) {
isc_file_remove(tmpname);
}
if (tmpname != NULL)
isc_mem_free(server->mctx, tmpname);
}
if (zone != NULL)
dns_zone_detach(&zone);