[dhcp] Fix NM dispatcher script for dhcpd to support arbitrary interface names

Jiří Popelka jpopelka at fedoraproject.org
Wed Apr 27 15:22:08 UTC 2011


commit cc2eb946a13e8679ead7d72a6b7123a32e753158
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Wed Apr 27 17:17:31 2011 +0200

    Fix NM dispatcher script for dhcpd to support arbitrary interface names

 12-dhcpd  |   32 +++++++++++++++++++++-----------
 dhcp.spec |    5 ++++-
 2 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/12-dhcpd b/12-dhcpd
index fad6f4b..e72e8cd 100644
--- a/12-dhcpd
+++ b/12-dhcpd
@@ -5,17 +5,27 @@ export LC_ALL=C
 
 # restart dhcpd whenever $1 interface is brought up by NM (rhbz #565921)
 if [ "$2" = "up" ]; then
-	# exit if the service is not configured to be started in the current runlevel
-	/bin/systemctl is-enabled dhcpd.service || exit 0
+    # exit if the service is not configured to be started in the current runlevel
+    /bin/systemctl is-enabled dhcpd.service || exit 0
 
-	# exit if dhcpd is not defined to listen on $1
-	# i.e. if there are interfaces defined in DHCPDARGS and $1 is not among them
-	if [ -n "${DHCPDARGS}" ] &&
-	   [[ "${DHCPDARGS}" == *eth* ]] &&
-	   [[ "${DHCPDARGS}" != *$1* ]]; then
-		exit 0
-	fi
+    ifaces=""                # interfaces defined in DHCPDARGS
+    net=$(ls /sys/class/net) # all interfaces on system
 
-	# restart service
-	/bin/systemctl restart dhcpd.service || :
+    if [ -n "${DHCPDARGS}" ]; then
+        for iface in ${net}; do
+            for arg in ${DHCPDARGS}; do
+                [ $arg == $iface ] && ifaces="$ifaces $iface"
+            done
+        done
+    fi
+
+    # exit if dhcpd is not defined to listen on $1
+    # i.e. if there are interfaces defined in DHCPDARGS and $1 is not among them
+    if [ -n "${ifaces}" ] &&
+       [[ "${ifaces}" != *$1* ]]; then
+          exit 0
+    fi
+
+    # restart service
+    /bin/systemctl restart dhcpd.service || :
 fi
diff --git a/dhcp.spec b/dhcp.spec
index 0b0702f..fcd814d 100644
--- a/dhcp.spec
+++ b/dhcp.spec
@@ -16,7 +16,7 @@
 Summary:  Dynamic host configuration protocol software
 Name:     dhcp
 Version:  4.2.1
-Release:  5.%{patchver}%{?dist}
+Release:  6.%{patchver}%{?dist}
 # NEVER CHANGE THE EPOCH on this package.  The previous maintainer (prior to
 # dcantrell maintaining the package) made incorrect use of the epoch and
 # that's why it is at 12 now.  It should have never been used, but it was.
@@ -634,6 +634,9 @@ fi
 %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
 
 %changelog
+* Wed Apr 27 2011 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.1-6.P1
+- Fix NetworkManager dispatcher script for dhcpd to support arbitrary interface names
+
 * Wed Apr 06 2011 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.1-5.P1
 - Better fix for CVE-2011-0997: making domain-name check more lenient (#694005)
 


More information about the scm-commits mailing list