]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - config/unbound/unbound-dhcp-leases-bridge
core141: fix remove of go8.3.0 directory
[people/pmueller/ipfire-2.x.git] / config / unbound / unbound-dhcp-leases-bridge
index 54cd8135ba9fea2192b03a8266b0b61402f3bf1f..e3da4860bd1718b835d7a53d9be6b89222f36fef 100644 (file)
@@ -25,9 +25,12 @@ import daemon
 import ipaddress
 import logging
 import logging.handlers
+import os
 import re
 import signal
+import stat
 import subprocess
+import tempfile
 
 import inotify.adapters
 
@@ -151,7 +154,7 @@ class UnboundDHCPLeasesBridge(object):
                                line = line.rstrip()
 
                                try:
-                                       enabled, ipaddr, hostname, domainname = line.split(",")
+                                       enabled, ipaddr, hostname, domainname, generateptr = line.split(",")
                                except:
                                        log.warning("Could not parse line: %s" % line)
                                        continue
@@ -519,11 +522,18 @@ class UnboundConfigWriter(object):
                                self._cached_leases.append(l)
 
        def write_dhcp_leases(self, leases):
-               with open(self.path, "w") as f:
+               with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
+                       filename = f.name
+
                        for l in leases:
                                for rr in l.rrset:
                                        f.write("local-data: \"%s\"\n" % " ".join(rr))
 
+                       # Make file readable for everyone
+                       os.fchmod(f.fileno(), stat.S_IRUSR|stat.S_IWUSR|stat.S_IRGRP|stat.S_IROTH)
+
+               os.rename(filename, self.path)
+
        def _control(self, *args):
                command = ["unbound-control"]
                command.extend(args)