diff --git a/dnssec-trigger-0.12-nm-script.patch b/dnssec-trigger-0.12-nm-script.patch index 7b5a146..5149bdb 100644 --- a/dnssec-trigger-0.12-nm-script.patch +++ b/dnssec-trigger-0.12-nm-script.patch @@ -1,19 +1,17 @@ diff --git a/dnssec-trigger-script.in b/dnssec-trigger-script.in -index b572dd1..a275806 100644 +index b572dd1..32d7749 100644 --- a/dnssec-trigger-script.in +++ b/dnssec-trigger-script.in -@@ -6,17 +6,17 @@ +@@ -6,7 +6,7 @@ """ from gi.repository import NMClient -import os, sys, shutil, subprocess -+import os, sys, shutil, glob, subprocess ++import os, sys, fcntl, shutil, glob, subprocess import logging, logging.handlers import socket, struct -+import lockfile - - DEVNULL = open("/dev/null", "wb") +@@ -15,8 +15,7 @@ DEVNULL = open("/dev/null", "wb") log = logging.getLogger() log.setLevel(logging.INFO) log.addHandler(logging.handlers.SysLogHandler()) @@ -23,7 +21,32 @@ index b572dd1..a275806 100644 # NetworkManager reportedly doesn't pass the PATH environment variable. os.environ['PATH'] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -@@ -53,18 +53,17 @@ class ConnectionList: +@@ -24,6 +23,24 @@ os.environ['PATH'] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/b + class UserError(Exception): + pass + ++class Lock: ++ """Lock used to serialize the script""" ++ ++ path = "/var/run/dnssec-trigger/lock" ++ ++ def __init__(self): ++ # We don't use os.makedirs(..., exist_ok=True) to ensure Python 2 compatibility ++ dirname = os.path.dirname(self.path) ++ if not os.path.exists(dirname): ++ os.makedirs(dirname) ++ self.lock = open(self.path, "w") ++ ++ def __enter__(self): ++ fcntl.lockf(self.lock, fcntl.LOCK_EX) ++ ++ def __exit__(self, t, v, tb): ++ fcntl.lockf(self.lock, fcntl.LOCK_UN) ++ + class Config: + """Global configuration options""" + +@@ -53,18 +70,17 @@ class ConnectionList: nm_connections = None @@ -46,7 +69,7 @@ index b572dd1..a275806 100644 return "".format(list(self), **vars(self)) def __iter__(self): -@@ -190,7 +189,7 @@ class UnboundZoneConfig: +@@ -190,10 +206,10 @@ class UnboundZoneConfig: if fields.pop(0) in ('forward', 'forward:'): fields.pop(0) secure = False @@ -54,8 +77,12 @@ index b572dd1..a275806 100644 + if fields and fields[0] == '+i': secure = True fields.pop(0) - self.cache[name] = set(fields[3:]), secure -@@ -255,7 +254,7 @@ class Store: +- self.cache[name] = set(fields[3:]), secure ++ self.cache[name] = set(fields), secure + log.debug(self) + + def __repr__(self): +@@ -255,7 +271,7 @@ class Store: line = line.strip() if line: self.cache.add(line) @@ -64,7 +91,7 @@ index b572dd1..a275806 100644 pass log.debug(self) -@@ -277,10 +276,16 @@ class Store: +@@ -277,10 +293,16 @@ class Store: log.debug(self) def update(self, zones): @@ -84,7 +111,7 @@ index b572dd1..a275806 100644 def remove(self, zone): """Remove zone from the cache.""" -@@ -309,7 +314,7 @@ class GlobalForwarders: +@@ -309,7 +331,7 @@ class GlobalForwarders: line = line.strip() if line: self.cache.add(line) @@ -93,7 +120,7 @@ index b572dd1..a275806 100644 pass class Application: -@@ -328,32 +333,40 @@ class Application: +@@ -328,32 +350,40 @@ class Application: except AttributeError: self.usage() self.config = Config() @@ -125,7 +152,7 @@ index b572dd1..a275806 100644 def run(self): - log.debug("Running: {}".format(self.method.__name__)) - self.method() -+ with lockfile.FileLock("/var/run/dnssec-trigger/dnssec-trigger"): ++ with Lock(): + log.debug("Running: {}".format(self.method.__name__)) + self.method() @@ -139,7 +166,7 @@ index b572dd1..a275806 100644 def run_cleanup(self): """Clean up after dnssec-trigger.""" -@@ -361,6 +374,18 @@ class Application: +@@ -361,6 +391,18 @@ class Application: stored_zones = Store('zones') unbound_zones = UnboundZoneConfig() @@ -158,7 +185,7 @@ index b572dd1..a275806 100644 log.debug("clearing unbound configuration") for zone in stored_zones: unbound_zones.remove(zone) -@@ -370,11 +395,14 @@ class Application: +@@ -370,11 +412,14 @@ class Application: log.debug("recovering /etc/resolv.conf") subprocess.check_call(["chattr", "-i", "/etc/resolv.conf"]) if not self.nm_handles_resolv_conf(): @@ -175,7 +202,7 @@ index b572dd1..a275806 100644 else: subprocess.check_call(["/etc/init.d/NetworkManager", "restart"]) -@@ -387,7 +415,7 @@ class Application: +@@ -387,7 +432,7 @@ class Application: subprocess.check_call(["dnssec-trigger-control", "status"], stdout=DEVNULL, stderr=DEVNULL) @@ -184,7 +211,7 @@ index b572dd1..a275806 100644 servers = Store('servers') if servers.update(sum((connection.servers for connection in default_connections), [])): -@@ -399,7 +427,7 @@ class Application: +@@ -399,7 +444,7 @@ class Application: def run_update_connection_zones(self): """Configures forward zones in the unbound using unbound-control.""" diff --git a/dnssec-trigger.spec b/dnssec-trigger.spec index bb06a37..889b378 100644 --- a/dnssec-trigger.spec +++ b/dnssec-trigger.spec @@ -3,7 +3,7 @@ Summary: NetworkManager plugin to update/reconfigure DNSSEC resolving Name: dnssec-trigger Version: 0.12 -Release: 13%{?dist} +Release: 14%{?dist} License: BSD Url: http://www.nlnetlabs.nl/downloads/dnssec-trigger/ Source0: http://www.nlnetlabs.nl/downloads/dnssec-trigger/%{name}-%{version}.tar.gz @@ -30,7 +30,7 @@ Patch2: dnssec-trigger-0.12-nm-script.patch Patch3: dnssec-trigger-0.12-service.patch Requires(postun): initscripts -Requires: ldns >= 1.6.10, NetworkManager-glib, unbound, xdg-utils, python-lockfile +Requires: ldns >= 1.6.10, NetworkManager-glib, unbound, xdg-utils # Require a version of NetworkManager that doesn't forget to issue dhcp-change # # https://bugzilla.redhat.com/show_bug.cgi?id=1112248 @@ -145,6 +145,10 @@ fi %systemd_postun_with_restart %{name}d.service %changelog +* Thu Aug 14 2014 Pavel Šimerda - 0.12-14 +- Resolves: #1125261 - dnssec-trigger-script: use fcntl.flock instead of + lockfile + * Mon Aug 11 2014 Tomas Hozza - 0.12-13 - One Fedora fallback server changed IP address (#1125440)