diff -Nru networkd-dispatcher-1.7/debian/changelog networkd-dispatcher-1.7/debian/changelog --- networkd-dispatcher-1.7/debian/changelog 2018-06-19 10:03:47.000000000 +0000 +++ networkd-dispatcher-1.7/debian/changelog 2018-10-15 12:12:24.000000000 +0000 @@ -1,3 +1,14 @@ +networkd-dispatcher (1.7-0ubuntu3.3) bionic; urgency=medium + + * Allow overriding /usr/lib scripts in /etc/networkd-dispatcher. + Replaces our patch to use /usr/lib/networkd-dispatcher with the + solution contributed upstream that has a search path with both + /usr/lib/ and /etc locations. + (LP: #1797884) + * Create directories for scripts in /etc + + -- Julian Andres Klode Mon, 15 Oct 2018 14:12:24 +0200 + networkd-dispatcher (1.7-0ubuntu3.2) bionic; urgency=medium * Revert "Cherry-pick upstream fix to start before systemd-networkd" diff -Nru networkd-dispatcher-1.7/debian/networkd-dispatcher.dirs networkd-dispatcher-1.7/debian/networkd-dispatcher.dirs --- networkd-dispatcher-1.7/debian/networkd-dispatcher.dirs 2018-06-19 10:03:47.000000000 +0000 +++ networkd-dispatcher-1.7/debian/networkd-dispatcher.dirs 2018-10-15 12:12:24.000000000 +0000 @@ -2,3 +2,7 @@ usr/lib/networkd-dispatcher/no-carrier.d usr/lib/networkd-dispatcher/off.d usr/lib/networkd-dispatcher/routable.d +etc/networkd-dispatcher/dormant.d +etc/networkd-dispatcher/no-carrier.d +etc/networkd-dispatcher/off.d +etc/networkd-dispatcher/routable.d diff -Nru networkd-dispatcher-1.7/debian/patches/0002-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch networkd-dispatcher-1.7/debian/patches/0002-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch --- networkd-dispatcher-1.7/debian/patches/0002-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch 1970-01-01 00:00:00.000000000 +0000 +++ networkd-dispatcher-1.7/debian/patches/0002-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch 2018-10-15 12:12:24.000000000 +0000 @@ -0,0 +1,20 @@ +From: Julian Andres Klode +Date: Tue, 19 Jun 2018 11:13:18 +0200 +Subject: networkd-dispatcher.conf: Run startup triggers by default + +Origin: vendor, Ubuntu +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1772137 +Forwarded: not-needed +--- + networkd-dispatcher.conf | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/networkd-dispatcher.conf b/networkd-dispatcher.conf +index efed53c..bc9854c 100644 +--- a/networkd-dispatcher.conf ++++ b/networkd-dispatcher.conf +@@ -1,3 +1,3 @@ + # Specify command line options here. This config file is used + # by the included systemd service file. +-networkd_dispatcher_args="" ++networkd_dispatcher_args="--run-startup-triggers" diff -Nru networkd-dispatcher-1.7/debian/patches/0002-Use-usr-lib-networkd-dispatcher-instead-of-etc-n.-d.patch networkd-dispatcher-1.7/debian/patches/0002-Use-usr-lib-networkd-dispatcher-instead-of-etc-n.-d.patch --- networkd-dispatcher-1.7/debian/patches/0002-Use-usr-lib-networkd-dispatcher-instead-of-etc-n.-d.patch 2018-06-19 10:03:47.000000000 +0000 +++ networkd-dispatcher-1.7/debian/patches/0002-Use-usr-lib-networkd-dispatcher-instead-of-etc-n.-d.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -From: Julian Andres Klode -Date: Thu, 19 Apr 2018 08:25:42 +0200 -Subject: Use /usr/lib/networkd-dispatcher instead of /etc/n..-d... - ---- - README.md | 6 +++--- - networkd-dispatcher | 2 +- - networkd-dispatcher.txt | 4 ++-- - 3 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/README.md b/README.md -index da37a17..3cadd6c 100644 ---- a/README.md -+++ b/README.md -@@ -10,7 +10,7 @@ The daemon listens for signals from systemd-networkd over dbus, so it should be - - The deamon expects that scripts are 1) executable and 2) owned by root (gid = uid = 0), and will not execute scripts that are otherwise. - --Scripts can be installed into these directories under ```/etc/networkd-dispatcher```: -+Scripts can be installed into these directories under ```/usr/lib/networkd-dispatcher```: - - ``` - routable.d/ -@@ -61,7 +61,7 @@ optional arguments: - -h, --help show this help message and exit - -S SCRIPT_DIR, --script-dir SCRIPT_DIR - Location under which to look for scripts [default: -- /etc/networkd-dispatcher] -+ /usr/lib/networkd-dispatcher] - -T, --run-startup-triggers - Generate events reflecting preexisting state and - behavior on startup [default: False] -@@ -103,7 +103,7 @@ Copy networkd-dispatcher to /usr/bin. - - Create the appropriate directory structure: - --```$ sudo mkdir -p /etc/networkd-dispatcher/{routable,dormant,no-carrier,off}.d``` -+```$ sudo mkdir -p /usr/lib/networkd-dispatcher/{routable,dormant,no-carrier,off}.d``` - - Install networkd-dispatcher.conf to /etc/default as 'networkd-dispatcher'. - -diff --git a/networkd-dispatcher b/networkd-dispatcher -index 990e3e8..90ddd24 100755 ---- a/networkd-dispatcher -+++ b/networkd-dispatcher -@@ -40,7 +40,7 @@ def resolve_path(cmdname): - - # Constants - NETWORKCTL = resolve_path('networkctl') --DEFAULT_SCRIPT_DIR = '/etc/networkd-dispatcher' -+DEFAULT_SCRIPT_DIR = '/usr/lib/networkd-dispatcher' - - # Supported wireless tools - IWCONFIG = resolve_path('iwconfig') -diff --git a/networkd-dispatcher.txt b/networkd-dispatcher.txt -index e21d2fe..5e32d72 100644 ---- a/networkd-dispatcher.txt -+++ b/networkd-dispatcher.txt -@@ -37,7 +37,7 @@ OPTIONS - - *-S, --script-dir='SCRIPT_DIR'*:: - Location under which to look for scripts. Defaults to -- /etc/networkd-dispatcher. -+ /usr/lib/networkd-dispatcher. - - *-T, --run-startup-triggers*:: - Generate events reflecting preexisting state and behavior on startup. This can -@@ -61,7 +61,7 @@ environment file for additional daemon arguments. - - The scripts to be run on network changes are in subdirectories 'routable.d/', - 'dormant.d/', 'no-carrier.d/', 'off.d/' inside 'SCRIPT_DIR'. The default value --for 'SCRIPT_DIR' is '/etc/networkd-dispatcher'. -+for 'SCRIPT_DIR' is '/usr/lib/networkd-dispatcher'. - - RESOURCES - --------- diff -Nru networkd-dispatcher-1.7/debian/patches/0003-Allow-usr-lib-networkd-dispatcher-scripts-with-etc-o.patch networkd-dispatcher-1.7/debian/patches/0003-Allow-usr-lib-networkd-dispatcher-scripts-with-etc-o.patch --- networkd-dispatcher-1.7/debian/patches/0003-Allow-usr-lib-networkd-dispatcher-scripts-with-etc-o.patch 1970-01-01 00:00:00.000000000 +0000 +++ networkd-dispatcher-1.7/debian/patches/0003-Allow-usr-lib-networkd-dispatcher-scripts-with-etc-o.patch 2018-10-15 12:12:24.000000000 +0000 @@ -0,0 +1,156 @@ +From: Julian Andres Klode +Date: Thu, 13 Sep 2018 10:21:21 +0200 +Subject: Allow /usr/lib/networkd-dispatcher scripts with /etc overrides + +Make --script-dir take a colon-separated lists of directories, +like $PATH, and implement lookup so that scripts in earlier +directories override those with the same name in later +directories. + +This modifies scripts_in_path() to take the subdirectory as +a second argument, so it can join it with each path component, +rather than just with the last directory in the path. + +Fixes #39 + +Origin: upstream, https://gitlab.com/craftyguy/networkd-dispatcher/commit/036563ee0ff00ea70c52e98ddfd24cb496c2d1e0 +--- + README.md | 4 ++-- + networkd-dispatcher | 59 ++++++++++++++++++++++++++++++------------------- + networkd-dispatcher.txt | 9 +++++--- + 3 files changed, 44 insertions(+), 28 deletions(-) + +diff --git a/README.md b/README.md +index da37a17..a153595 100644 +--- a/README.md ++++ b/README.md +@@ -10,7 +10,7 @@ The daemon listens for signals from systemd-networkd over dbus, so it should be + + The deamon expects that scripts are 1) executable and 2) owned by root (gid = uid = 0), and will not execute scripts that are otherwise. + +-Scripts can be installed into these directories under ```/etc/networkd-dispatcher```: ++Scripts can be installed into these directories under ```/usr/lib/networkd-dispatcher``` for system packages, and ```/etc/networkd-dispatcher``` for local overrides: + + ``` + routable.d/ +@@ -61,7 +61,7 @@ optional arguments: + -h, --help show this help message and exit + -S SCRIPT_DIR, --script-dir SCRIPT_DIR + Location under which to look for scripts [default: +- /etc/networkd-dispatcher] ++ /etc/networkd-dispatcher:/usr/lib/networkd-dispatcher] + -T, --run-startup-triggers + Generate events reflecting preexisting state and + behavior on startup [default: False] +diff --git a/networkd-dispatcher b/networkd-dispatcher +index 990e3e8..715f980 100755 +--- a/networkd-dispatcher ++++ b/networkd-dispatcher +@@ -40,7 +40,7 @@ def resolve_path(cmdname): + + # Constants + NETWORKCTL = resolve_path('networkctl') +-DEFAULT_SCRIPT_DIR = '/etc/networkd-dispatcher' ++DEFAULT_SCRIPT_DIR = '/etc/networkd-dispatcher:/usr/lib/networkd-dispatcher' + + # Supported wireless tools + IWCONFIG = resolve_path('iwconfig') +@@ -141,28 +141,41 @@ def iwconfig_get_ssid(iface_name): + return unquote(essid) + + +-def scripts_in_path(path): +- """Given a directory name, return a sorted list of executables +- contained therein""" ++def scripts_in_path(path, subdir): ++ """Given directory names in PATH notation (separated by :), and a ++ subdirectory name, return a sorted list of executables ++ contained in that subdirectory, such that executables in earlier ++ path components override those with the same name in later path ++ components.""" + script_list = [] +- if not os.path.exists(path): +- logger.debug("Path %r does not exist; skipping", path) +- return [] +- for filename in os.listdir(path): +- pathname = os.path.join(path, filename) +- if os.path.isfile(pathname): +- entry = os.stat(pathname) +- # Make sure script can be executed +- if not stat.S_IXUSR & entry.st_mode: +- logger.error("Unable to execute script, check file mode: %s", +- pathname) +- # Make sure script is owned by root +- elif entry.st_uid != 0 or entry.st_gid != 0: +- logger.error("Unable to execute script, check file perms: %s", +- pathname) +- else: +- script_list.append(pathname) +- return sorted(script_list) ++ base_filenames = set() ++ for one_path in path.split(":"): ++ one_path = os.path.join(one_path, subdir) ++ if not os.path.exists(one_path): ++ logger.debug("Path %r does not exist; skipping", one_path) ++ continue ++ base_filenames.update(os.listdir(one_path)) ++ ++ for filename in sorted(base_filenames): ++ for one_path in path.split(":"): ++ pathname = os.path.join(one_path, subdir, filename) ++ logger.debug("Checking if %s exists as %s", filename, pathname) ++ ++ if os.path.isfile(pathname): ++ entry = os.stat(pathname) ++ # Make sure script can be executed ++ if not stat.S_IXUSR & entry.st_mode: ++ logger.error("Unable to execute script, check file mode: %s", ++ pathname) ++ # Make sure script is owned by root ++ elif entry.st_uid != 0 or entry.st_gid != 0: ++ logger.error("Unable to execute script, check file perms: %s", ++ pathname) ++ else: ++ script_list.append(pathname) ++ break ++ ++ return script_list + + + def parse_address_strings(addrs): +@@ -246,7 +259,7 @@ class Dispatcher(object): + + def get_scripts_list(self, state): + """Return scripts for the given state""" +- return scripts_in_path(self.script_dir + "/" + state + ".d") ++ return scripts_in_path(self.script_dir, state + ".d") + + def _handle_one_state(self, iface_name, state, state_type, force=False): + """Process a single state change""" +diff --git a/networkd-dispatcher.txt b/networkd-dispatcher.txt +index e21d2fe..b1b3c7b 100644 +--- a/networkd-dispatcher.txt ++++ b/networkd-dispatcher.txt +@@ -36,8 +36,11 @@ OPTIONS + Print command-line syntax and program options to stdout. + + *-S, --script-dir='SCRIPT_DIR'*:: +- Location under which to look for scripts. Defaults to +- /etc/networkd-dispatcher. ++ Location under which to look for scripts. Like the 'PATH' environment ++ variable, this may contain multiple directories separated by : and ++ in case multiple directories have scripts with the same name, the ++ earliest directory wins. Defaults to ++ /etc/networkd-dispatcher:/usr/lib/networkd-dispatcher. + + *-T, --run-startup-triggers*:: + Generate events reflecting preexisting state and behavior on startup. This can +@@ -61,7 +64,7 @@ environment file for additional daemon arguments. + + The scripts to be run on network changes are in subdirectories 'routable.d/', + 'dormant.d/', 'no-carrier.d/', 'off.d/' inside 'SCRIPT_DIR'. The default value +-for 'SCRIPT_DIR' is '/etc/networkd-dispatcher'. ++for 'SCRIPT_DIR' is '/etc/networkd-dispatcher:/usr/lib/networkd-dispatcher'. + + RESOURCES + --------- diff -Nru networkd-dispatcher-1.7/debian/patches/0003-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch networkd-dispatcher-1.7/debian/patches/0003-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch --- networkd-dispatcher-1.7/debian/patches/0003-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch 2018-06-19 10:03:47.000000000 +0000 +++ networkd-dispatcher-1.7/debian/patches/0003-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -From: Julian Andres Klode -Date: Tue, 19 Jun 2018 11:13:18 +0200 -Subject: networkd-dispatcher.conf: Run startup triggers by default - -Origin: vendor, Ubuntu -Bug-Ubuntu: https://bugs.launchpad.net/bugs/1772137 -Forwarded: not-needed ---- - networkd-dispatcher.conf | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/networkd-dispatcher.conf b/networkd-dispatcher.conf -index efed53c..bc9854c 100644 ---- a/networkd-dispatcher.conf -+++ b/networkd-dispatcher.conf -@@ -1,3 +1,3 @@ - # Specify command line options here. This config file is used - # by the included systemd service file. --networkd_dispatcher_args="" -+networkd_dispatcher_args="--run-startup-triggers" diff -Nru networkd-dispatcher-1.7/debian/patches/series networkd-dispatcher-1.7/debian/patches/series --- networkd-dispatcher-1.7/debian/patches/series 2018-06-19 10:03:47.000000000 +0000 +++ networkd-dispatcher-1.7/debian/patches/series 2018-10-15 12:12:24.000000000 +0000 @@ -1,3 +1,3 @@ 0001-Patch-etc-conf.d-p.conf-to-etc-default-p.patch -0002-Use-usr-lib-networkd-dispatcher-instead-of-etc-n.-d.patch -0003-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch +0002-networkd-dispatcher.conf-Run-startup-triggers-by-def.patch +0003-Allow-usr-lib-networkd-dispatcher-scripts-with-etc-o.patch