diff --git a/56dhclient b/56dhclient new file mode 100755 index 0000000..b1c1c67 --- /dev/null +++ b/56dhclient @@ -0,0 +1,61 @@ +#!/bin/sh +# If we are running dhclient, shutdown running instances cleanly and +# bring them back up on resume. + +. "${PM_FUNCTIONS}" + +PM_DHCLIENT_RUNDIR="${PM_UTILS_RUNDIR}/network" +PM_DHCLIENT_SUSPEND="${PM_DHCLIENT_RUNDIR}/dhclient.suspend" + +suspend_dhclient() { + [ ! -d /etc/sysconfig/network-scripts ] && return + [ ! -x /sbin/ifdown ] && return + + [ ! -d ${PM_DHCLIENT_RUNDIR} ] && /bin/mkdir -p ${PM_DHCLIENT_RUNDIR} + [ -f ${PM_DHCLIENT_SUSPEND} ] && /bin/rm -f ${PM_DHCLIENT_SUSPEND} + + cd /etc/sysconfig/network-scripts + for ifcfg in ifcfg-* ; do + # Clear relevant parameters set by previous interface + # (lo doesn't set them) + NM_CONTROLLED= + BOOTPROTO= + + . ./${ifcfg} + + if [ "${NM_CONTROLLED}" = "no" ] || [ "${NM_CONTROLLED}" = "n" ] || [ "${NM_CONTROLLED}" = "false" ]; then + if [ "${BOOTPROTO}" = "bootp" ] || [ "${BOOTPROTO}" = "dhcp" ] || [ -z "${BOOTPROTO}" ]; then + # device is not NetworkManager controlled and uses dhcp, + # now see if it's actually up at the moment + /sbin/ip link show ${DEVICE} | /bin/grep -qE "state (UP|UNKNOWN)" >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "${DEVICE}" >> ${PM_DHCLIENT_SUSPEND} + /sbin/ifdown ${DEVICE} + fi + fi + fi + done +} + +resume_dhclient() { + [ ! -f ${PM_DHCLIENT_SUSPEND} ] && return + [ ! -x /sbin/ifup ] && return + + cd /etc/sysconfig/network-scripts + while read device ; do + /sbin/ifup ${DEVICE} + done < ${PM_DHCLIENT_SUSPEND} + + /bin/rm -f ${PM_DHCLIENT_SUSPEND} +} + +case "$1" in + hibernate|suspend) + suspend_dhclient + ;; + thaw|resume) + resume_dhclient + ;; + *) exit $NA + ;; +esac diff --git a/dhcp.spec b/dhcp.spec index 726c1a0..47b746a 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -13,7 +13,7 @@ Summary: Dynamic host configuration protocol software Name: dhcp Version: %{basever}p1 -Release: 1%{?dist} +Release: 2%{?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. @@ -28,6 +28,7 @@ Source2: dhcpd.init Source3: dhcrelay.init Source4: dhclient-script Source5: README.dhclient.d +Source6: 56dhclient Patch0: %{name}-4.1.0-errwarn-message.patch Patch1: %{name}-4.1.0-memory.patch @@ -340,6 +341,10 @@ EOF # Install empty directory for dhclient.d scripts %{__mkdir} -p %{buildroot}%{dhcpconfdir}/dhclient.d +# Install pm-utils script to handle suspend/resume and dhclient leases +%{__mkdir} -p %{buildroot}%{_libdir}/pm-utils/sleep.d +%{__install} -p -m 0755 %{SOURCE6} %{buildroot}%{_libdir}/pm-utils/sleep.d + %clean %{__rm} -rf %{buildroot} @@ -433,6 +438,7 @@ fi %dir %{_localstatedir}/lib/dhclient /sbin/dhclient /sbin/dhclient-script +%{_libdir}/pm-utils %attr(0644,root,root) %{_mandir}/man5/dhclient.conf.5.gz %attr(0644,root,root) %{_mandir}/man5/dhclient.leases.5.gz %attr(0644,root,root) %{_mandir}/man8/dhclient.8.gz @@ -452,6 +458,10 @@ fi %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz %changelog +* Thu Aug 06 2009 David Cantrell - 12:4.1.0p1-2 +- Add /usr/lib[64]/pm-utils/sleep.d/56dhclient to handle suspend and + resume with active dhclient leases (#479639) + * Wed Aug 05 2009 David Cantrell - 12:4.1.0p1-1 - Upgrade to dhcp-4.1.0p1, which is the official upstream release to fix CVE-2009-0692