- Add /usr/lib[64]/pm-utils/sleep.d/56dhclient to handle suspend and resume

with active dhclient leases (#479639)
This commit is contained in:
David Cantrell 2009-08-06 21:45:18 +00:00
parent 441afc0d96
commit 348ee0ebdc
2 changed files with 72 additions and 1 deletions

61
56dhclient Executable file
View File

@ -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

View File

@ -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.
@ -29,6 +29,7 @@ Source3: dhcrelay.init
Source4: dhclient-script
Source5: README.dhclient.d
Source6: 10-dhclient
Source7: 56dhclient
Patch0: %{name}-4.1.0-errwarn-message.patch
Patch1: %{name}-4.1.0-memory.patch
@ -350,6 +351,10 @@ EOF
%{__mkdir} -p %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d
%{__install} -p -m 0755 %{SOURCE6} %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.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}
@ -446,6 +451,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
@ -465,6 +471,10 @@ fi
%attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
%changelog
* Thu Aug 06 2009 David Cantrell <dcantrell@redhat.com> - 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 <dcantrell@redhat.com> - 12:4.1.0p1-1
- Upgrade to dhcp-4.1.0p1, which is the official upstream release to fix
CVE-2009-0692