rpms/dhcp/devel README.dhclient.d, NONE, 1.1 dhclient-script, 1.4, 1.5 dhcp.spec, 1.239, 1.240

David Cantrell dcantrel at fedoraproject.org
Wed Feb 18 04:13:30 UTC 2009


Author: dcantrel

Update of /cvs/pkgs/rpms/dhcp/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv28829

Modified Files:
	dhclient-script dhcp.spec 
Added Files:
	README.dhclient.d 
Log Message:
* Mon Feb 16 2009 David Cantrell <dcantrell at redhat.com> - 12:4.1.0-6
- Enable dhcpv6 support (#480798)
- Fix config file migration in scriptlets (#480543)
- Allow dhclient-script expansion with /etc/dhcp/dhclient.d/*.sh scripts



--- NEW FILE README.dhclient.d ---
The /etc/dhcp/dhclient.d directory allows other packages and system
administrators to create application-specific option handlers for dhclient.

When dhclient is run, any option listed in the dhcp-options(5) man page can
be requested.  dhclient-script does not handle every option available
because doing so would make the script unmaintainable as the components
using those options might change over time.  The knowledge of how to handle
those options should be under the responsibility of the package maintainer
for that component (e.g., NTP options belong in a handler in the ntp
package).

To make maintenance easier, application specific DHCP options can be handled
by creating a script with two functions and placing it in /etc/dhcp/dhclient.d

The script must follow a specific form:

(1) The script must be named NAME.sh.  NAME can be anything, but it makes
    sense to name it for the service it handles.  e.g., ntp.sh

(2) The script must provide a NAME_config() function to read the options and
    do whatever it takes to put those options in place.

(3) The script must provide a NAME_restore() function to restore original
    configuration state when dhclient stops.

(4) The script must be 'chmod +x' or dhclient-script will ignore it.

The scripts execute in the same environment as dhclient-script.  That means
all of the functions and variables available to it are available to your
NAME.sh script.  Things of note:

    ${SAVEDIR} is where original configuration files are saved.  Save your
    original configuration files here before you take the DHCP provided
    values and generate new files.

    Variables set in /etc/sysconfig/network, /etc/sysconfig/networking/network,
    and /etc/sysconfig/network-scripts/ifcfg-$interface are available to
    you.

See the scripts in /etc/dhcp/dhclient.d for examples.

NOTE:  Do not use functions defined in /sbin/dhclient-script.  Consider
dhclient-script a black box.  This script may change over time, so the
dhclient.d scripts should not be using functions defined in it.

-- 
David Cantrell <dcantrell at redhat.com>


Index: dhclient-script
===================================================================
RCS file: /cvs/pkgs/rpms/dhcp/devel/dhclient-script,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- dhclient-script	4 Dec 2008 22:08:05 -0000	1.4
+++ dhclient-script	18 Feb 2009 04:12:59 -0000	1.5
@@ -330,48 +330,6 @@
         hostname ${new_host_name}
     fi
 
-    if [ ! "${PEERNIS}" = "no" ]; then
-        if [ -n "${new_nis_domain}" ]; then
-            domainname "${new_nis_domain}"
-            save_previous /etc/yp.conf
-            let contents=0
-            echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
-
-            if [ -n "${new_nis_servers}" ]; then
-                for i in ${new_nis_servers} ; do
-                    echo "domain ${new_nis_domain} server ${i}" >> /etc/yp.conf
-                    let contents=contents+1
-                done
-            else
-                echo "domain ${new_nis_domain} broadcast" >> /etc/yp.conf
-                let contents=contents+1
-            fi
-
-            if [ ${contents} -gt 0 ]; then
-                if [ -x /etc/rc.d/init.d/ypbind ] &&
-                   [ -r /var/run/ypbind.pid ]; then
-                    service ypbind restart >/dev/null 2>&1
-                fi
-            fi
-        elif [ -n "${new_nis_servers}" ]; then
-            save_previous /etc/yp.conf
-            echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
-            let contents=0
-
-            for i in ${new_nis_servers} ; do
-                echo "ypserver ${i}" >> /etc/yp.conf
-                let contents=contents+1
-            done
-
-            if [ $contents -gt 0 ]; then
-                if [ -x /etc/rc.d/init.d/ypbind ] &&
-                   [ -r /var/run/ypbind.pid ]; then
-                    service ypbind restart >/dev/null 2>&1
-                fi
-            fi
-        fi
-    fi
-
     if [ -n "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" ] &&
        [[ "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ]]; then
         if [ -n "${new_time_offset}" ]; then
@@ -396,20 +354,15 @@
         fi
     fi
 
-    if [ ! "${PEERNTP}" = "no" ] &&
-       [ -n "${new_ntp_servers}" ] && [ -e /etc/ntp.conf ]; then
-        save_previous /etc/ntp.conf
-        egrep -v '^server .*  # added by /sbin/dhclient-script$'< ${SAVEDIR}/ntp.conf.predhclient.${interface} > /etc/ntp.conf
-        restorecon /etc/ntp.conf >/dev/null 2>&1
-
-        for s in ${new_ntp_servers} ; do
-            echo "server ${s}  # added by /sbin/dhclient-script" >> /etc/ntp.conf
+    # execute any additional client side configuration scripts we have
+    if [ -d /etc/dhcp/dhclient.d ]; then
+        for f in /etc/dhcp/dhclient.d/*.sh ; do
+            if [ -x ${f} ]; then
+                subsystem="$(basename ${f} .sh)"
+                . ${f}
+                \${subsystem}_config
+            fi
         done
-
-        diff -q /etc/ntp.conf ${SAVEDIR}/ntp.conf.predhclient.${interface} >/dev/null 2>&1
-        if [ $? -eq 1 ]; then
-            service ntpd condrestart >/dev/null 2>&1
-        fi
     fi
 }
 


Index: dhcp.spec
===================================================================
RCS file: /cvs/pkgs/rpms/dhcp/devel/dhcp.spec,v
retrieving revision 1.239
retrieving revision 1.240
diff -u -r1.239 -r1.240
--- dhcp.spec	15 Jan 2009 20:28:23 -0000	1.239
+++ dhcp.spec	18 Feb 2009 04:12:59 -0000	1.240
@@ -1,18 +1,10 @@
 # vendor string (e.g., Fedora, EL)
 %define vvendor Fedora
 
-# Make it easy for package rebuilders to enable DHCPv6 support
-%define dhcpv6opt --disable-dhcpv6
-
-%define with_DHCPv6 %{?_with_DHCPv6: 1} %{?!_with_DHCPv6: 0}
-%if %{with_DHCPv6}
-%define dhcpv6opt --enable-dhcpv6
-%endif
-
 Summary:  Dynamic host configuration protocol software
 Name:     dhcp
 Version:  4.1.0
-Release:  5%{?dist}
+Release:  6%{?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.
@@ -30,6 +22,7 @@
 Source8:  dhclient-script
 Source9:  dhcp.schema
 Source10: get-ldap-patch.sh
+Source11: README.dhclient.d
 
 Patch0:   %{name}-4.1.0-errwarn-message.patch
 Patch1:   %{name}-4.1.0-ldap-configuration.patch
@@ -59,6 +52,7 @@
 BuildRequires: openldap-devel
 
 Requires(post): chkconfig
+Requires(post): coreutils
 Requires(preun): chkconfig
 Requires(preun): initscripts
 Requires(postun): initscripts
@@ -79,6 +73,7 @@
 Summary: Provides the dhclient ISC DHCP client daemon and dhclient-script
 Group: System Environment/Base
 Requires: initscripts >= 6.75
+Requires(post): coreutils
 Obsoletes: dhcpcd <= 1.3.22pl1-7
 Provides: dhcpcd = 1.3.22pl1-8
 
@@ -189,6 +184,7 @@
 
 # Copy in the Fedora/RHEL dhclient script
 %{__install} -p -m 0755 %{SOURCE8} client/scripts/linux
+%{__install} -p -m 0644 %{SOURCE11} .
 
 # Ensure we don't pick up Perl as a dependency from the scripts and modules
 # in the contrib directory (we copy this to /usr/share/doc in the final
@@ -244,11 +240,15 @@
 %build
 CFLAGS="%{optflags} -fPIC -D_GNU_SOURCE -DLDAP_CONFIGURATION -DUSE_SSL" \
 %configure \
-    %{dhcpv6opt} \
+    --enable-dhcpv6 \
     --with-srv-lease-file=%{_localstatedir}/lib/dhcpd/dhcpd.leases \
+    --with-srv6-lease-file=%{_localstatedir}/lib/dhcpd/dhcpd6.leases \
     --with-cli-lease-file=%{_localstatedir}/lib/dhclient/dhclient.leases \
+    --with-cli6-lease-file=%{_localstatedir}/lib/dhclient/dhclient6.leases \
     --with-srv-pid-file=%{_localstatedir}/run/dhcpd.pid \
+    --with-srv6-pid-file=%{_localstatedir}/run/dhcpd6.pid \
     --with-cli-pid-file=%{_localstatedir}/run/dhclient.pid \
+    --with-cli6-pid-file=%{_localstatedir}/run/dhclient6.pid \
     --with-relay-pid-file=%{_localstatedir}/run/dhcrelay.pid
 %{__make} %{?_smp_mflags}
 
@@ -273,6 +273,7 @@
 # Start empty lease databases
 %{__mkdir} -p %{buildroot}%{_localstatedir}/lib/dhcpd/
 touch %{buildroot}%{_localstatedir}/lib/dhcpd/dhcpd.leases
+touch %{buildroot}%{_localstatedir}/lib/dhcpd/dhcpd6.leases
 %{__mkdir} -p %{buildroot}%{_localstatedir}/lib/dhclient/
 
 # Create default sysconfig files for dhcpd and dhcrelay
@@ -314,9 +315,8 @@
 %{__rm} -rf %{buildroot}
 
 %post
-if [ -f /etc/dhcpd.conf -a ! -f /etc/dhcp/dhcpd.conf ]; then
+if [ -f /etc/dhcpd.conf ]; then
     /bin/cp -a /etc/dhcpd.conf /etc/dhcp/dhcpd.conf >/dev/null 2>&1
-    /bin/rm -f /etc/dhcpd.conf >/dev/null 2>&1
 fi
 
 /sbin/chkconfig --add dhcpd
@@ -329,7 +329,13 @@
         cf="$(/bin/basename ${etcfile})"
         if [ ! -f /etc/dhcp/${cf} ]; then
             /bin/cp -a "${etcfile}" /etc/dhcp
-            /bin/rm -f "${etcfile}"
+            if [ ! -f "${etcfile}.rpmsave" ]; then
+                /bin/mv -f "${etcfile}" "${etcfile}.rpmsave"
+            elif [ ! -f "${etcfile}.rpmsave.$$" ]; then
+                /bin/mv -f "${etcfile}" "${etcfile}.rpmsave.$$"
+            else
+                /bin/mv -f "${etcfile}" "${etcfile}.rpmsave.$(date +%s)"
+            fi
         fi
     done || :
 fi || :
@@ -363,6 +369,7 @@
 %dir %{_localstatedir}/lib/dhcpd
 %dir %{_sysconfdir}/dhcp
 %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/dhcpd/dhcpd.leases
+%verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/dhcpd/dhcpd6.leases
 %config(noreplace) %{_sysconfdir}/sysconfig/dhcpd
 %config(noreplace) %{_sysconfdir}/sysconfig/dhcrelay
 %config(noreplace) %{_sysconfdir}/dhcp/dhcpd.conf
@@ -382,7 +389,7 @@
 
 %files -n dhclient
 %defattr(-,root,root,-)
-%doc dhclient.conf.sample
+%doc dhclient.conf.sample README.dhclient.d
 %dir %{_sysconfdir}/dhcp
 %dir %{_sysconfdir}/dhcp/dhclient.d
 %dir %{_localstatedir}/lib/dhclient
@@ -407,6 +414,11 @@
 %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
 
 %changelog
+* Mon Feb 16 2009 David Cantrell <dcantrell at redhat.com> - 12:4.1.0-6
+- Enable dhcpv6 support (#480798)
+- Fix config file migration in scriptlets (#480543)
+- Allow dhclient-script expansion with /etc/dhcp/dhclient.d/*.sh scripts
+
 * Thu Jan 15 2009 Tomas Mraz <tmraz at redhat.com> - 12:4.1.0-5
 - rebuild with new openssl
 




More information about the fedora-extras-commits mailing list