s4-dns: don't leave behind a tmp file
authorAndrew Tridgell <tridge@samba.org>
Thu, 11 Feb 2010 09:49:29 +0000 (20:49 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 11 Feb 2010 10:04:16 +0000 (21:04 +1100)
If the dns update file doesn't need updating we need to delete the tmp
file

source4/dsdb/dns/dns_update.c

index 90ada8810e25f3b7d3d251a04f0f598a8c74ac5e..13f37e3c6b1e6e869a62654e4a85934c0e92dd5b 100644 (file)
@@ -82,6 +82,7 @@ static void dnsupdate_rebuild(struct dnsupdate_service *service)
                return;
        }
 
+       unlink(tmp_path);
        fd = open(tmp_path, O_CREAT|O_TRUNC|O_WRONLY, 0444);
        if (fd == -1) {
                DEBUG(1,(__location__ ": Unable to open %s - %s\n", tmp_path, strerror(errno)));
@@ -106,6 +107,7 @@ static void dnsupdate_rebuild(struct dnsupdate_service *service)
        close(fd);
 
        if (file_compare(tmp_path, path) == true) {
+               unlink(tmp_path);
                talloc_free(tmp_ctx);
                return;
        }