- Include contrib/ subdirectory in /usr/share/doc (#230476)
- Added back Requires for perl since dhcpd-conf-to-ldap needs it (#225691) - Put copies of dhcp-options and dhcp-eval man pages in the dhcp and dhclient packages rather than having the elaborate symlink collection - Explicitly name man pages in the %files listings - Use the %{_sysconfdir} and %{_initrddir} macros (#225691) - Use macros for commands in %build and %install - Split README.ldap, draft-ietf-dhc-ldap-schema-01.txt, and dhcpd-conf-to-ldap.pl out of the LDAP patch - Split linux.dbus-example script out of the extended new option info patch - Remove unnecessary changes from the Makefile patch
This commit is contained in:
parent
8cb20bf3c8
commit
0f9f19ccd5
157
README.ldap
Normal file
157
README.ldap
Normal file
@ -0,0 +1,157 @@
|
||||
LDAP Support in DHCP
|
||||
Brian Masney <masneyb@ntelos.net>
|
||||
Last updated 8/16/2002
|
||||
|
||||
This document describes setting up the DHCP server to read it's configuration
|
||||
from LDAP. This work is based on the IETF document
|
||||
draft-ietf-dhc-ldap-schema-01.txt included in the doc directory. For the latest
|
||||
version of this document, please see http://home.ntelos.net/~masneyb.
|
||||
|
||||
First question on most people's mind is "Why do I want to store my
|
||||
configuration in LDAP?" If you run a small DHCP server, and the configuration
|
||||
on it rarely changes, then you won't need to store your configuration in LDAP.
|
||||
But, if you have several DHCP servers, and you want an easy way to manage your
|
||||
configuration, this can be a solution.
|
||||
|
||||
The first step will be to setup your LDAP server. I am using OpenLDAP from
|
||||
www.openldap.org. Building and installing OpenLDAP is beyond the scope of this
|
||||
document. There is plenty of documentation out there about this. Once you have
|
||||
OpenLDAP installed, you will have to edit your slapd.conf file. I added the
|
||||
following 2 lines to my configuration file:
|
||||
|
||||
include /etc/ldap/schema/dhcp.schema
|
||||
index dhcpHWAddress eq
|
||||
index dhcpClassData eq
|
||||
|
||||
The first line tells it to include the dhcp schema file. You will find this
|
||||
file under the contrib directory in this distribution. You will need to copy
|
||||
this file to where your other schema files are (maybe
|
||||
/usr/local/openldap/etc/openldap/schema/). The second line sets up
|
||||
an index for the dhcpHWAddress parameter. The third parameter is for reading
|
||||
subclasses from LDAP every time a DHCP request comes in. Make sure you run the
|
||||
slapindex command and restart slapd to have these changes to into effect.
|
||||
|
||||
Now that you have LDAP setup, you should be able to use gq (http://biot.com/gq/)
|
||||
to verify that the dhcp schema file is loaded into LDAP. Pull up gq, and click
|
||||
on the Schema tab. Go under objectClasses, and you should see at least the
|
||||
following object classes listed: dhcpClass, dhcpGroup, dhcpHost, dhcpOptions,
|
||||
dhcpPool, dhcpServer, dhcpService, dhcpSharedNetwork, dhcpSubClass, and
|
||||
dhcpSubnet. If you do not see these, you need to check over your LDAP
|
||||
configuration before you go any further.
|
||||
|
||||
You should be ready to build DHCP. Edit the includes/site.h file and uncomment
|
||||
the #define LDAP_CONFIGURATION. Now run configure in the base source directory.
|
||||
Edit the work.os/server/Makefile and add -lldap to the LIBS= line. (replace os
|
||||
with your operating system, linux-2.2 on my machine). You should be able to
|
||||
type make to build your DHCP server.
|
||||
|
||||
Once you have DHCP installed, you will need to setup your initial plaintext
|
||||
config file. In my /etc/dhcpd.conf file, I have:
|
||||
|
||||
ldap-server "localhost";
|
||||
ldap-port 389;
|
||||
ldap-username "cn=DHCP User, dc=ntelos, dc=net";
|
||||
ldap-password "blah";
|
||||
ldap-base-dn "dc=ntelos, dc=net";
|
||||
ldap-method dynamic;
|
||||
|
||||
All of these parameters should be self explanatory except for the ldap-method.
|
||||
You can set this to static or dynamic. If you set it to static, the
|
||||
configuration is read once on startup, and LDAP isn't used anymore. But, if you
|
||||
set this to dynamic, the configuration is read once on startup, and the
|
||||
hosts that are stored in LDAP are looked up every time a DHCP request comes in.
|
||||
|
||||
The next step is to set up your LDAP tree. Here is an example config that will
|
||||
give a 10.100.0.x address to machines that have a host entry in LDAP.
|
||||
Otherwise, it will give a 10.200.0.x address to them. (NOTE: replace
|
||||
dc=ntelos, dc=net with your base dn). If you would like to convert your
|
||||
existing dhcpd.conf file to LDIF format, there is a script
|
||||
contrib/dhcpd-conf-to-ldap.pl that will convert it for you.
|
||||
|
||||
# You must specify the server's host name in LDAP that you are going to run
|
||||
# DHCP on and point it to which config tree you want to use. Whenever DHCP
|
||||
# first starts up, it will do a search for this entry to find out which
|
||||
# config to use
|
||||
dn: cn=brian.ntelos.net, dc=ntelos, dc=net
|
||||
objectClass: top
|
||||
objectClass: dhcpServer
|
||||
cn: brian.ntelos.net
|
||||
dhcpServiceDN: cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
|
||||
# Here is the config tree that brian.ntelos.net points to.
|
||||
dn: cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: DHCP Service Config
|
||||
objectClass: top
|
||||
objectClass: dhcpService
|
||||
dhcpPrimaryDN: dc=ntelos, dc=net
|
||||
dhcpStatements: ddns-update-style ad-hoc
|
||||
dhcpStatements: default-lease-time 600
|
||||
dhcpStatements: max-lease-time 7200
|
||||
|
||||
# Set up a shared network segment
|
||||
dn: cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: WV
|
||||
objectClass: top
|
||||
objectClass: dhcpSharedNetwork
|
||||
|
||||
# Set up a subnet declaration with a pool statement. Also note that we have
|
||||
# a dhcpOptions object with this entry
|
||||
dn: cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: 10.100.0.0
|
||||
objectClass: top
|
||||
objectClass: dhcpSubnet
|
||||
objectClass: dhcpOptions
|
||||
dhcpOption: domain-name-servers 10.100.0.2
|
||||
dhcpOption: routers 10.100.0.1
|
||||
dhcpOption: subnet-mask 255.255.255.0
|
||||
dhcpOption: broadcast-address 10.100.0.255
|
||||
dhcpNetMask: 24
|
||||
|
||||
# Set up a pool for this subnet. Only known hosts will get these IPs
|
||||
dn: cn=Known Pool, cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: Known Pool
|
||||
objectClass: top
|
||||
objectClass: dhcpPool
|
||||
dhcpRange: 10.100.0.3 10.100.0.254
|
||||
dhcpPermitList: deny unknown-clients
|
||||
|
||||
# Set up another subnet declaration with a pool statement
|
||||
dn: cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: 10.200.0.0
|
||||
objectClass: top
|
||||
objectClass: dhcpSubnet
|
||||
objectClass: dhcpOptions
|
||||
dhcpOption: domain-name-servers 10.200.0.2
|
||||
dhcpOption: routers 10.200.0.1
|
||||
dhcpOption: subnet-mask 255.255.255.0
|
||||
dhcpOption: broadcast-address 10.200.0.255
|
||||
dhcpNetMask: 24
|
||||
|
||||
# Set up a pool for this subnet. Only unknown hosts will get these IPs
|
||||
dn: cn=Known Pool, cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: Known Pool
|
||||
objectClass: top
|
||||
objectClass: dhcpPool
|
||||
dhcpRange: 10.200.0.3 10.200.0.254
|
||||
dhcpPermitList: deny known clients
|
||||
|
||||
# Set aside a group for all of our known MAC addresses
|
||||
dn: cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
objectClass: top
|
||||
objectClass: dhcpGroup
|
||||
cn: Customers
|
||||
|
||||
# Host entry for my laptop
|
||||
dn: cn=brianlaptop, cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
objectClass: top
|
||||
objectClass: dhcpHost
|
||||
cn: brianlaptop
|
||||
dhcpHWAddress: ethernet 00:00:00:00:00:00
|
||||
|
||||
You can use the command slapadd to load all of these entries into your LDAP
|
||||
server. After you load this, you should be able to start up DHCP. If you run
|
||||
into problems reading the configuration, try running dhcpd with the -d flag.
|
||||
If you still have problems, edit the site.conf file in the DHCP source and
|
||||
add the line: COPTS= -DDEBUG_LDAP and recompile DHCP. (make sure you run make
|
||||
clean and rerun configure before you rebuild).
|
||||
|
@ -1,103 +1,3 @@
|
||||
--- dhcp-3.0.5/client/Makefile.dist.Makefile 2004-06-10 13:59:11.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/Makefile.dist 2006-11-10 11:10:13.000000000 -0500
|
||||
@@ -128,6 +128,6 @@
|
||||
|
||||
|
||||
dhclient: $(OBJS) $(DHCPLIB)
|
||||
- $(CC) $(LFLAGS) -o $(PROG) $(OBJS) $(DHCPLIB) $(LIBS)
|
||||
+ $(CC) $(LFLAGS) -pie $(RPM_OPT_FLAGS) -Wl,-z,relro,-z,now,-z,noexecstack,-z,nodlopen -o $(PROG) $(OBJS) $(DHCPLIB) $(LIBS)
|
||||
|
||||
# Dependencies (semi-automatically-generated)
|
||||
--- dhcp-3.0.5/dhcpctl/Makefile.dist.Makefile 2005-03-03 11:55:23.000000000 -0500
|
||||
+++ dhcp-3.0.5/dhcpctl/Makefile.dist 2006-11-10 11:11:16.000000000 -0500
|
||||
@@ -37,10 +37,10 @@
|
||||
all: libdhcpctl.a omshell cltest $(CATMANPAGES)
|
||||
|
||||
omshell: omshell.o $(DHCPCTLLIBS)
|
||||
- $(CC) $(DEBUG) $(LFLAGS) -o omshell omshell.o $(DHCPCTLLIBS) $(LIBS)
|
||||
+ $(CC) $(DEBUG) $(LFLAGS) -pie $(RPM_OPT_FLAGS) -Wl,-z,relro,-z,now,-z,noexecstack,-z,nodlopen -o omshell omshell.o $(DHCPCTLLIBS) $(LIBS)
|
||||
|
||||
cltest: cltest.o $(DHCPCTLLIBS)
|
||||
- $(CC) $(DEBUG) $(LFLAGS) -o cltest cltest.o $(DHCPCTLLIBS) $(LIBS)
|
||||
+ $(CC) $(DEBUG) $(LFLAGS) -pie $(RPM_OPT_FLAGS) -Wl,-z,relro,-z,now,-z,noexecstack,-z,nodlopen -o cltest cltest.o $(DHCPCTLLIBS) $(LIBS)
|
||||
|
||||
libdhcpctl.a: $(OBJ)
|
||||
rm -f libdhcpctl.a
|
||||
--- dhcp-3.0.5/dst/Makefile.dist.Makefile 2004-06-10 13:59:28.000000000 -0400
|
||||
+++ dhcp-3.0.5/dst/Makefile.dist 2006-11-10 11:11:42.000000000 -0500
|
||||
@@ -30,7 +30,12 @@
|
||||
|
||||
all: libdst.a
|
||||
|
||||
-install:
|
||||
+install: all
|
||||
+ if [ ! -d $(DESTDIR)$(LIBDIR) ]; then \
|
||||
+ mkdir $(DESTDIR)$(LIBDIR); chmod 755 $(DESTDIR)$(LIBDIR); \
|
||||
+ fi
|
||||
+ $(INSTALL) libdst.a $(DESTDIR)$(LIBDIR)
|
||||
+ $(CHMOD) 644 $(DESTDIR)$(LIBDIR)/libdst.a
|
||||
|
||||
libdst.a: $(OBJ)
|
||||
rm -f dst.a
|
||||
--- dhcp-3.0.5/minires/Makefile.dist.Makefile 2004-06-10 13:59:40.000000000 -0400
|
||||
+++ dhcp-3.0.5/minires/Makefile.dist 2006-11-10 11:14:00.000000000 -0500
|
||||
@@ -21,9 +21,6 @@
|
||||
# <info@isc.org>
|
||||
# http://www.isc.org/
|
||||
|
||||
-CATMANPAGES = dhcpctl.cat3
|
||||
-SEDMANPAGES = dhcpctl.man3
|
||||
-MAN = dhcpctl.3
|
||||
SRC = res_mkupdate.c res_init.c res_update.c res_send.c res_comp.c \
|
||||
res_sendsigned.c res_findzonecut.c res_query.c res_mkquery.c \
|
||||
ns_date.c ns_parse.c ns_sign.c ns_name.c ns_samedomain.c ns_verify.c
|
||||
@@ -50,24 +47,17 @@
|
||||
-rm -f $(OBJ) libres.a
|
||||
|
||||
realclean: clean
|
||||
- -rm -f *~ $(CATMANPAGES) $(SEDMANPAGES)
|
||||
+ -rm -f *~
|
||||
|
||||
distclean: realclean
|
||||
-rm -f Makefile
|
||||
|
||||
links:
|
||||
- @for foo in $(SRC) $(MAN) $(HDRS); do \
|
||||
+ @for foo in $(SRC) $(HDRS); do \
|
||||
if [ ! -b $$foo ]; then \
|
||||
rm -f $$foo; \
|
||||
fi; \
|
||||
ln -s $(TOP)/minires/$$foo $$foo; \
|
||||
done
|
||||
|
||||
-dhcpctl.cat3: dhcpctl.man3
|
||||
- nroff -man dhcpctl.man3 >dhcpctl.cat3
|
||||
-
|
||||
-dhcpctl.man3: dhcpctl.3
|
||||
- sed -e "s#ETCDIR#$(ETC)#g" -e "s#DBDIR#$(VARDB)#g" \
|
||||
- -e "s#RUNDIR#$(VARRUN)#g" < dhcpctl.3 >dhcpctl.man3
|
||||
-
|
||||
# Dependencies (semi-automatically-generated)
|
||||
--- dhcp-3.0.5/relay/Makefile.dist.Makefile 2004-06-10 13:59:50.000000000 -0400
|
||||
+++ dhcp-3.0.5/relay/Makefile.dist 2006-11-10 11:13:30.000000000 -0500
|
||||
@@ -83,6 +83,6 @@
|
||||
-e "s#RUNDIR#$(VARRUN)#" < dhcrelay.8 >dhcrelay.man8
|
||||
|
||||
dhcrelay: dhcrelay.o $(DHCPLIB)
|
||||
- $(CC) $(LFLAGS) -o $(PROG) dhcrelay.o $(DHCPLIB) $(LIBS)
|
||||
+ $(CC) $(LFLAGS) -pie $(RPM_OPT_FLAGS) -Wl,-z,relro,-z,now,-z,nodlopen,-z,noexecstack -o $(PROG) dhcrelay.o $(DHCPLIB) $(LIBS)
|
||||
|
||||
# Dependencies (semi-automatically-generated)
|
||||
--- dhcp-3.0.5/server/Makefile.dist.Makefile 2004-06-10 13:59:50.000000000 -0400
|
||||
+++ dhcp-3.0.5/server/Makefile.dist 2006-11-10 11:14:27.000000000 -0500
|
||||
@@ -103,6 +103,6 @@
|
||||
-e "s#RUNDIR#$(VARRUN)#g" < dhcpd.leases.5 >dhcpd.leases.man5
|
||||
|
||||
dhcpd: $(OBJS) $(COBJ) $(DHCPLIB)
|
||||
- $(CC) $(LFLAGS) -o dhcpd $(OBJS) $(DHCPLIB) $(LIBS)
|
||||
+ $(CC) $(LFLAGS) -pie $(RPM_OPT_FLAGS) -Wl,-z,relro,-z,now,-z,noexecstack,-z,nodlopen -o dhcpd $(OBJS) $(DHCPLIB) $(LIBS)
|
||||
|
||||
# Dependencies (semi-automatically-generated)
|
||||
--- dhcp-3.0.5/Makefile.Makefile 2004-06-10 13:59:10.000000000 -0400
|
||||
+++ dhcp-3.0.5/Makefile 2006-11-10 11:09:32.000000000 -0500
|
||||
@@ -33,7 +33,7 @@
|
||||
|
@ -1,231 +1,5 @@
|
||||
--- dhcp-3.0.5/client/scripts/linux.dbus-example.enoi 2006-11-13 12:59:34.000000000 -0500
|
||||
+++ dhcp-3.0.5/client/scripts/linux.dbus-example 2006-11-13 12:59:26.000000000 -0500
|
||||
@@ -0,0 +1,223 @@
|
||||
+#!/bin/bash
|
||||
+# dhclient-script for Linux. Dan Halbert, March, 1997.
|
||||
+# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
|
||||
+# No guarantees about this. I'm a novice at the details of Linux
|
||||
+# networking.
|
||||
+
|
||||
+# Notes:
|
||||
+
|
||||
+# 0. This script is based on the netbsd script supplied with dhcp-970306.
|
||||
+
|
||||
+# 1. ifconfig down apparently deletes all relevant routes and flushes
|
||||
+# the arp cache, so this doesn't need to be done explicitly.
|
||||
+
|
||||
+# 2. The alias address handling here has not been tested AT ALL.
|
||||
+# I'm just going by the doc of modern Linux ip aliasing, which uses
|
||||
+# notations like eth0:0, eth0:1, for each alias.
|
||||
+
|
||||
+# 3. I have to calculate the network address, and calculate the broadcast
|
||||
+# address if it is not supplied. This might be much more easily done
|
||||
+# by the dhclient C code, and passed on.
|
||||
+
|
||||
+# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
|
||||
+# of the $1 in its args.
|
||||
+
|
||||
+if [ -n "${dhc_dbus}" ]; then
|
||||
+ /bin/dbus-send \
|
||||
+ --system --dest=com.redhat.dhcp --type=method_call \
|
||||
+ /com/redhat/dhcp/$interface com.redhat.dhcp.set \
|
||||
+ 'string:'"`env | /bin/egrep -v '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`";
|
||||
+ if (( ( dhc_dbus & 31 ) == 31 )); then
|
||||
+ exit 0;
|
||||
+ fi;
|
||||
+fi;
|
||||
+
|
||||
+make_resolv_conf() {
|
||||
+ if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
|
||||
+ echo search $new_domain_name >/etc/resolv.conf
|
||||
+ chmod 644 /etc/resolv.conf
|
||||
+ for nameserver in $new_domain_name_servers; do
|
||||
+ echo nameserver $nameserver >>/etc/resolv.conf
|
||||
+ done
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
+# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
|
||||
+exit_with_hooks() {
|
||||
+ exit_status=$1
|
||||
+ if [ -f /etc/dhclient-exit-hooks ]; then
|
||||
+ . /etc/dhclient-exit-hooks
|
||||
+ fi
|
||||
+# probably should do something with exit status of the local script
|
||||
+ exit $exit_status
|
||||
+}
|
||||
+
|
||||
+# Invoke the local dhcp client enter hooks, if they exist.
|
||||
+if [ -f /etc/dhclient-enter-hooks ]; then
|
||||
+ exit_status=0
|
||||
+ . /etc/dhclient-enter-hooks
|
||||
+ # allow the local script to abort processing of this state
|
||||
+ # local script must set exit_status variable to nonzero.
|
||||
+ if [ $exit_status -ne 0 ]; then
|
||||
+ exit $exit_status
|
||||
+ fi
|
||||
+fi
|
||||
+
|
||||
+release=`uname -r`
|
||||
+release=`expr $release : '\(.*\)\..*'`
|
||||
+relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
|
||||
+relmajor=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
|
||||
+
|
||||
+if [ x$new_broadcast_address != x ]; then
|
||||
+ new_broadcast_arg="broadcast $new_broadcast_address"
|
||||
+fi
|
||||
+if [ x$old_broadcast_address != x ]; then
|
||||
+ old_broadcast_arg="broadcast $old_broadcast_address"
|
||||
+fi
|
||||
+if [ x$new_subnet_mask != x ]; then
|
||||
+ new_subnet_arg="netmask $new_subnet_mask"
|
||||
+fi
|
||||
+if [ x$old_subnet_mask != x ]; then
|
||||
+ old_subnet_arg="netmask $old_subnet_mask"
|
||||
+fi
|
||||
+if [ x$alias_subnet_mask != x ]; then
|
||||
+ alias_subnet_arg="netmask $alias_subnet_mask"
|
||||
+fi
|
||||
+
|
||||
+if [ x$reason = xMEDIUM ]; then
|
||||
+ # Linux doesn't do mediums (ok, ok, media).
|
||||
+ exit_with_hooks 0
|
||||
+fi
|
||||
+
|
||||
+if [ x$reason = xPREINIT ]; then
|
||||
+ if [ x$alias_ip_address != x ]; then
|
||||
+ # Bring down alias interface. Its routes will disappear too.
|
||||
+ ifconfig $interface:0- inet 0
|
||||
+ fi
|
||||
+ if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] )
|
||||
+ then
|
||||
+ ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
|
||||
+ broadcast 255.255.255.255 up
|
||||
+ # Add route to make broadcast work. Do not omit netmask.
|
||||
+ route add default dev $interface netmask 0.0.0.0
|
||||
+ else
|
||||
+ ifconfig $interface 0 up
|
||||
+ fi
|
||||
+
|
||||
+ # We need to give the kernel some time to get the interface up.
|
||||
+ sleep 1
|
||||
+
|
||||
+ exit_with_hooks 0
|
||||
+fi
|
||||
+
|
||||
+if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
|
||||
+ exit_with_hooks 0
|
||||
+fi
|
||||
+
|
||||
+if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
||||
+ [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
|
||||
+ current_hostname=`hostname`
|
||||
+ if [ x$current_hostname = x ] || \
|
||||
+ [ x$current_hostname = x$old_host_name ]; then
|
||||
+ if [ x$current_hostname = x ] || \
|
||||
+ [ x$new_host_name != x$old_host_name ]; then
|
||||
+ hostname $new_host_name
|
||||
+ fi
|
||||
+ fi
|
||||
+
|
||||
+ if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
+ if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
|
||||
+ [ x$alias_ip_address != x$old_ip_address ]; then
|
||||
+ # Possible new alias. Remove old alias.
|
||||
+ ifconfig $interface:0- inet 0
|
||||
+ fi
|
||||
+ if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
|
||||
+ # IP address changed. Bringing down the interface will delete all routes,
|
||||
+ # and clear the ARP cache.
|
||||
+ ifconfig $interface inet 0 down
|
||||
+
|
||||
+ fi
|
||||
+ fi
|
||||
+ if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
|
||||
+ [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
|
||||
+ if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
+ ifconfig $interface inet $new_ip_address $new_subnet_arg \
|
||||
+ $new_broadcast_arg
|
||||
+ fi
|
||||
+ if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 4 ) != 4 )); then
|
||||
+ # Add a network route to the computed network address.
|
||||
+ if [ $relmajor -lt 2 ] || \
|
||||
+ ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
|
||||
+ route add -net $new_network_number $new_subnet_arg dev $interface
|
||||
+ fi
|
||||
+ for router in $new_routers; do
|
||||
+ route add default gw $router
|
||||
+ done
|
||||
+ fi
|
||||
+ fi
|
||||
+ if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
+ if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
|
||||
+ then
|
||||
+ ifconfig $interface:0- inet 0
|
||||
+ ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
+ route add -host $alias_ip_address $interface:0
|
||||
+ fi
|
||||
+ fi
|
||||
+ if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 1 ) != 1 )); then
|
||||
+ make_resolv_conf
|
||||
+ fi
|
||||
+ exit_with_hooks 0
|
||||
+fi
|
||||
+
|
||||
+if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
+if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|
||||
+ || [ x$reason = xSTOP ]; then
|
||||
+ if [ x$alias_ip_address != x ]; then
|
||||
+ # Turn off alias interface.
|
||||
+ ifconfig $interface:0- inet 0
|
||||
+ fi
|
||||
+ if [ x$old_ip_address != x ]; then
|
||||
+ # Shut down interface, which will delete routes and clear arp cache.
|
||||
+ ifconfig $interface inet 0 down
|
||||
+ fi
|
||||
+ if [ x$alias_ip_address != x ]; then
|
||||
+ ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
+ route add -host $alias_ip_address $interface:0
|
||||
+ fi
|
||||
+ exit_with_hooks 0
|
||||
+fi
|
||||
+fi
|
||||
+
|
||||
+if [ x$reason = xTIMEOUT ]; then
|
||||
+ if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
+ if [ x$alias_ip_address != x ]; then
|
||||
+ ifconfig $interface:0- inet 0
|
||||
+ fi
|
||||
+ ifconfig $interface inet $new_ip_address $new_subnet_arg \
|
||||
+ $new_broadcast_arg
|
||||
+ fi
|
||||
+ set $new_routers
|
||||
+ ############## what is -w in ping?
|
||||
+ if ping -q -c 1 $1; then
|
||||
+ if [ x$new_ip_address != x$alias_ip_address ] && \
|
||||
+ [ x$alias_ip_address != x ]; then
|
||||
+ ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
+ route add -host $alias_ip_address dev $interface:0
|
||||
+ fi
|
||||
+ if [ $relmajor -lt 2 ] || \
|
||||
+ ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
|
||||
+ route add -net $new_network_number
|
||||
+ fi
|
||||
+ for router in $new_routers; do
|
||||
+ route add default gw $router
|
||||
+ done
|
||||
+ make_resolv_conf
|
||||
+ exit_with_hooks 0
|
||||
+ fi
|
||||
+ if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
+ ifconfig $interface inet 0 down
|
||||
+ fi
|
||||
+ exit_with_hooks 1
|
||||
+fi
|
||||
+
|
||||
+exit_with_hooks 0
|
||||
--- dhcp-3.0.5/client/dhclient.c.enoi 2006-08-22 11:13:57.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2006-11-13 12:44:11.000000000 -0500
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2007-03-04 15:19:43.000000000 -0500
|
||||
@@ -74,6 +74,9 @@
|
||||
int onetry=0;
|
||||
int quiet=0;
|
||||
@ -336,7 +110,7 @@
|
||||
++i;
|
||||
} while (i != 2);
|
||||
--- dhcp-3.0.5/client/dhclient.8.enoi 2005-09-14 12:03:33.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.8 2006-11-13 12:42:28.000000000 -0500
|
||||
+++ dhcp-3.0.5/client/dhclient.8 2007-03-04 15:19:43.000000000 -0500
|
||||
@@ -82,6 +82,9 @@
|
||||
.B -w
|
||||
]
|
||||
@ -360,7 +134,7 @@
|
||||
The syntax of the dhclient.conf(5) file is discussed separately.
|
||||
.SH OMAPI
|
||||
--- dhcp-3.0.5/common/parse.c.enoi 2006-02-22 17:43:27.000000000 -0500
|
||||
+++ dhcp-3.0.5/common/parse.c 2006-11-13 12:42:28.000000000 -0500
|
||||
+++ dhcp-3.0.5/common/parse.c 2007-03-04 15:19:43.000000000 -0500
|
||||
@@ -1271,6 +1271,10 @@
|
||||
option_hash_add (option -> universe -> hash,
|
||||
(const char *)option -> name,
|
||||
@ -373,7 +147,7 @@
|
||||
}
|
||||
|
||||
--- dhcp-3.0.5/common/tables.c.enoi 2006-02-22 17:43:27.000000000 -0500
|
||||
+++ dhcp-3.0.5/common/tables.c 2006-11-13 12:42:28.000000000 -0500
|
||||
+++ dhcp-3.0.5/common/tables.c 2007-03-04 15:19:43.000000000 -0500
|
||||
@@ -1250,3 +1250,35 @@
|
||||
fqdn_universe.name, 0,
|
||||
&fqdn_universe, MDL);
|
||||
@ -411,7 +185,7 @@
|
||||
+}
|
||||
+#endif
|
||||
--- dhcp-3.0.5/includes/dhcpd.h.enoi 2006-05-17 16:16:59.000000000 -0400
|
||||
+++ dhcp-3.0.5/includes/dhcpd.h 2006-11-13 12:42:28.000000000 -0500
|
||||
+++ dhcp-3.0.5/includes/dhcpd.h 2007-03-04 15:19:43.000000000 -0500
|
||||
@@ -1811,6 +1811,13 @@
|
||||
void initialize_common_option_spaces PROTO ((void));
|
||||
struct universe *config_universe;
|
||||
|
File diff suppressed because it is too large
Load Diff
138
dhcp.spec
138
dhcp.spec
@ -3,12 +3,14 @@
|
||||
%define bigptrs -DPTRSIZE_64BIT
|
||||
%endif
|
||||
|
||||
# The workdir is used in the build system for ISC dhcp, we set it to this
|
||||
# value to avoid any problems guessing what it might be during installation.
|
||||
%define workdir work.linux-2.2
|
||||
|
||||
Summary: DHCP (Dynamic Host Configuration Protocol) server and relay agent
|
||||
Name: dhcp
|
||||
Version: 3.0.5
|
||||
Release: 23%{?dist}
|
||||
Release: 24%{?dist}
|
||||
Epoch: 12
|
||||
License: ISC
|
||||
Group: System Environment/Daemons
|
||||
@ -19,6 +21,10 @@ Source2: dhcpd.init
|
||||
Source3: dhcrelay.init
|
||||
Source4: dhcpd.conf
|
||||
Source5: libdhcp4client.pc
|
||||
Source6: README.ldap
|
||||
Source7: draft-ietf-dhc-ldap-schema-01.txt
|
||||
Source8: dhcpd-conf-to-ldap.pl
|
||||
Source9: linux.dbus-example
|
||||
|
||||
Patch0: dhcp-3.0.5-extended-new-option-info.patch
|
||||
Patch1: dhcp-3.0.5-Makefile.patch
|
||||
@ -35,11 +41,13 @@ Patch11: dhcp-3.0.5-timeouts.patch
|
||||
Patch12: dhcp-3.0.5-fix-warnings.patch
|
||||
Patch13: dhcp-3.0.5-xen-checksum.patch
|
||||
Patch14: dhcp-3.0.5-ldap-configuration.patch
|
||||
Patch15: dhcp-3.0.5-no-win32.patch
|
||||
|
||||
# adds libdhcp4client to the ISC code base
|
||||
Patch50: dhcp-3.0.5-libdhcp4client.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
Requires: perl
|
||||
Requires(post): chkconfig, coreutils
|
||||
Requires(preun): chkconfig
|
||||
Requires(postun): coreutils
|
||||
@ -150,12 +158,28 @@ client library .
|
||||
# Add support for dhcpd.conf data in LDAP
|
||||
%patch14 -p1 -b .ldapconf
|
||||
|
||||
# The contrib/ms2isc/Registry.pm file requires Win32API::Registry, which is
|
||||
# not part of Fedora by default. We comment out this use line in the script
|
||||
# so that RPM doesn't automatically add perl(Win32API::Registry) dependency.
|
||||
# The patch puts a comment in the script telling the user which perl module
|
||||
# should be installed to use the Registry.pm contrib file.
|
||||
%patch15 -p1 -b .no-win32
|
||||
|
||||
# Add the libdhcp4client target (library version of dhclient)
|
||||
%patch50 -p1 -b .libdhcp4client
|
||||
|
||||
# Copy in documentation and example scripts for LDAP patch to dhcpd
|
||||
%{__cp} -p %SOURCE6 .
|
||||
%{__cp} -p %SOURCE7 doc
|
||||
%{__cp} -p %SOURCE8 contrib
|
||||
|
||||
# Copy in example dhclient script for use with D-BUS (requires extended
|
||||
# new option info patch too)
|
||||
%{__cp} -p %SOURCE9 client/scripts
|
||||
|
||||
%build
|
||||
cp %SOURCE1 .
|
||||
cat <<EOF >site.conf
|
||||
%{__cp} %SOURCE1 .
|
||||
%{__cat} <<EOF > site.conf
|
||||
VARDB=%{_localstatedir}/lib/dhcpd
|
||||
ADMMANDIR=%{_mandir}/man8
|
||||
FFMANDIR=%{_mandir}/man5
|
||||
@ -164,12 +188,15 @@ USRMANDIR=%{_mandir}/man1
|
||||
LIBDIR=%{_libdir}
|
||||
INCDIR=%{_includedir}
|
||||
EOF
|
||||
cat <<EOF >>includes/site.h
|
||||
%{__cat} <<EOF >> includes/site.h
|
||||
#define _PATH_DHCPD_DB "%{_localstatedir}/lib/dhcpd/dhcpd.leases"
|
||||
#define _PATH_DHCLIENT_DB "%{_localstatedir}/lib/dhclient/dhclient.leases"
|
||||
EOF
|
||||
|
||||
# Enable extended option info patch
|
||||
# Enable extended option info patch (-DEXTENDED_NEW_OPTION_INFO)
|
||||
# Use -fvisibility=hidden for libdhcp4client. The way that library is
|
||||
# constructed, we need to follow the hide-by-default/expose-what-we-need
|
||||
# plan for the library API.
|
||||
COPTS="-fPIC -Werror -Dlint -DEXTENDED_NEW_OPTION_INFO -fvisibility=hidden"
|
||||
|
||||
# DO NOT use the %%configure macro because this configure script is not autognu
|
||||
@ -177,61 +204,55 @@ CC="%{__cc}" ./configure \
|
||||
--copts "$RPM_OPT_FLAGS $COPTS %{?bigptrs}" \
|
||||
--work-dir %{workdir}
|
||||
|
||||
sed 's/@DHCP_VERSION@/'%{version}'/' < %SOURCE5 > libdhcp4client.pc
|
||||
%{__sed} 's/@DHCP_VERSION@/'%{version}'/' < %SOURCE5 > libdhcp4client.pc
|
||||
%{__make} %{?_smp_mflags} CC="%{__cc}"
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
mkdir -p %{buildroot}/etc/sysconfig
|
||||
%{__rm} -rf %{buildroot}
|
||||
%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
|
||||
|
||||
make install DESTDIR=%{buildroot}
|
||||
%{__make} install DESTDIR=%{buildroot}
|
||||
|
||||
install -p -m 0755 contrib/dhcpd-conf-to-ldap.pl %{buildroot}/usr/bin/dhcpd-conf-to-ldap
|
||||
%{__install} -p -m 0755 contrib/dhcpd-conf-to-ldap.pl %{buildroot}/usr/bin/dhcpd-conf-to-ldap
|
||||
|
||||
mkdir -p %{buildroot}/etc/rc.d/init.d
|
||||
install -p -m 0755 %SOURCE2 %{buildroot}/etc/rc.d/init.d/dhcpd
|
||||
%{__mkdir} -p %{buildroot}%{_initrddir}
|
||||
%{__install} -p -m 0755 %SOURCE2 %{buildroot}%{_initrddir}/dhcpd
|
||||
|
||||
touch %{buildroot}%{_localstatedir}/lib/dhcpd/dhcpd.leases
|
||||
mkdir -p %{buildroot}%{_localstatedir}/lib/dhclient/
|
||||
cat <<EOF > %{buildroot}/etc/sysconfig/dhcpd
|
||||
%{__mkdir} -p %{buildroot}%{_localstatedir}/lib/dhclient/
|
||||
%{__cat} <<EOF > %{buildroot}%{_sysconfdir}/sysconfig/dhcpd
|
||||
# Command line options here
|
||||
DHCPDARGS=
|
||||
EOF
|
||||
|
||||
install -p -m 0755 %SOURCE3 %{buildroot}/etc/rc.d/init.d/dhcrelay
|
||||
%{__install} -p -m 0755 %SOURCE3 %{buildroot}%{_initrddir}/dhcrelay
|
||||
|
||||
cat <<EOF > %{buildroot}/etc/sysconfig/dhcrelay
|
||||
%{__cat} <<EOF > %{buildroot}%{_sysconfdir}/sysconfig/dhcrelay
|
||||
# Command line options here
|
||||
INTERFACES=""
|
||||
DHCPSERVERS=""
|
||||
EOF
|
||||
|
||||
# Copy sample dhclient.conf file into position
|
||||
cp -p client/dhclient.conf dhclient.conf.sample
|
||||
chmod 755 %{buildroot}/sbin/dhclient-script
|
||||
|
||||
# Create per-package copies of dhcp-options and dhcp-eval common man-pages:
|
||||
cp -fp %{buildroot}%{_mandir}/man5/dhcp-options.5 %{buildroot}%{_mandir}/man5/dhcpd-options.5
|
||||
cp -fp %{buildroot}%{_mandir}/man5/dhcp-options.5 %{buildroot}%{_mandir}/man5/dhclient-options.5
|
||||
cp -fp %{buildroot}%{_mandir}/man5/dhcp-eval.5 %{buildroot}%{_mandir}/man5/dhcpd-eval.5
|
||||
cp -fp %{buildroot}%{_mandir}/man5/dhcp-eval.5 %{buildroot}%{_mandir}/man5/dhclient-eval.5
|
||||
%{__cp} -p client/dhclient.conf dhclient.conf.sample
|
||||
%{__chmod} 0755 %{buildroot}/sbin/dhclient-script
|
||||
|
||||
# Install default (empty) dhcpd.conf:
|
||||
cp -fp %SOURCE4 %{buildroot}/etc
|
||||
%{__cp} -fp %SOURCE4 %{buildroot}%{_sysconfdir}
|
||||
|
||||
install -p -m 0644 -D libdhcp4client.pc %{buildroot}%{_libdir}/pkgconfig/libdhcp4client.pc
|
||||
%{__install} -p -m 0644 -D libdhcp4client.pc %{buildroot}%{_libdir}/pkgconfig/libdhcp4client.pc
|
||||
|
||||
# Sources files can't be symlinks for debuginfo package generation
|
||||
find %{workdir} -type l |
|
||||
while read f; do
|
||||
rm -f linkderef
|
||||
cp $f linkderef
|
||||
rm -f $f
|
||||
mv linkderef $f
|
||||
%{__rm} -f linkderef
|
||||
%{__cp} $f linkderef
|
||||
%{__rm} -f $f
|
||||
%{__mv} linkderef $f
|
||||
done
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
%{__rm} -rf %{buildroot}
|
||||
|
||||
%post
|
||||
/sbin/chkconfig --add dhcpd
|
||||
@ -261,27 +282,25 @@ exit 0
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc README README.ldap RELNOTES dhcpd.conf.sample doc/IANA-arp-parameters
|
||||
%doc doc/IANA-arp-parameters doc/api+protocol doc/*.txt
|
||||
%doc doc/IANA-arp-parameters doc/api+protocol doc/*.txt contrib
|
||||
%dir %{_localstatedir}/lib/dhcpd
|
||||
%verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/dhcpd/dhcpd.leases
|
||||
%config(noreplace) /etc/sysconfig/dhcpd
|
||||
%config(noreplace) /etc/sysconfig/dhcrelay
|
||||
%config(noreplace) /etc/dhcpd.conf
|
||||
/etc/rc.d/init.d/dhcpd
|
||||
/etc/rc.d/init.d/dhcrelay
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/dhcpd
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/dhcrelay
|
||||
%config(noreplace) %{_sysconfdir}/dhcpd.conf
|
||||
%{_initrddir}/dhcpd
|
||||
%{_initrddir}/dhcrelay
|
||||
%{_bindir}/omshell
|
||||
%{_bindir}/dhcpd-conf-to-ldap
|
||||
%{_sbindir}/dhcpd
|
||||
%{_sbindir}/dhcrelay
|
||||
%{_mandir}/man1/omshell.1*
|
||||
%{_mandir}/man5/dhcpd.conf.5*
|
||||
%{_mandir}/man5/dhcpd.leases.5*
|
||||
%{_mandir}/man8/dhcpd.8*
|
||||
%{_mandir}/man8/dhcrelay.8*
|
||||
%{_mandir}/man5/dhcpd-options.5*
|
||||
%{_mandir}/man5/dhcpd-eval.5*
|
||||
%ghost %{_mandir}/man5/dhcp-options.5.gz
|
||||
%ghost %{_mandir}/man5/dhcp-eval.5.gz
|
||||
%{_mandir}/man1/omshell.1.gz
|
||||
%{_mandir}/man5/dhcpd.conf.5.gz
|
||||
%{_mandir}/man5/dhcpd.leases.5.gz
|
||||
%{_mandir}/man8/dhcpd.8.gz
|
||||
%{_mandir}/man8/dhcrelay.8.gz
|
||||
%{_mandir}/man5/dhcp-options.5.gz
|
||||
%{_mandir}/man5/dhcp-eval.5.gz
|
||||
|
||||
%files -n dhclient
|
||||
%defattr(-,root,root,-)
|
||||
@ -289,14 +308,12 @@ exit 0
|
||||
%dir %{_localstatedir}/lib/dhclient
|
||||
/sbin/dhclient
|
||||
/sbin/dhclient-script
|
||||
%{_mandir}/man5/dhclient.conf.5*
|
||||
%{_mandir}/man5/dhclient.leases.5*
|
||||
%{_mandir}/man8/dhclient.8*
|
||||
%{_mandir}/man8/dhclient-script.8*
|
||||
%{_mandir}/man5/dhclient-options.5*
|
||||
%{_mandir}/man5/dhclient-eval.5*
|
||||
%ghost %{_mandir}/man5/dhcp-options.5.gz
|
||||
%ghost %{_mandir}/man5/dhcp-eval.5.gz
|
||||
%{_mandir}/man5/dhclient.conf.5.gz
|
||||
%{_mandir}/man5/dhclient.leases.5.gz
|
||||
%{_mandir}/man8/dhclient.8.gz
|
||||
%{_mandir}/man8/dhclient-script.8.gz
|
||||
%{_mandir}/man5/dhcp-options.5.gz
|
||||
%{_mandir}/man5/dhcp-eval.5.gz
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root,-)
|
||||
@ -318,6 +335,19 @@ exit 0
|
||||
%{_libdir}/libdhcp4client.so
|
||||
|
||||
%changelog
|
||||
* Thu Mar 01 2007 David Cantrell <dcantrell@redhat.com> - 12:3.0.5-24
|
||||
- Include contrib/ subdirectory in /usr/share/doc (#230476)
|
||||
- Added back Requires for perl since dhcpd-conf-to-ldap needs it (#225691)
|
||||
- Put copies of dhcp-options and dhcp-eval man pages in the dhcp and
|
||||
dhclient packages rather than having the elaborate symlink collection
|
||||
- Explicitly name man pages in the %%files listings
|
||||
- Use the %%{_sysconfdir} and %%{_initrddir} macros (#225691)
|
||||
- Use macros for commands in %%build and %%install
|
||||
- Split README.ldap, draft-ietf-dhc-ldap-schema-01.txt, and
|
||||
dhcpd-conf-to-ldap.pl out of the LDAP patch
|
||||
- Split linux.dbus-example script out of the extended new option info patch
|
||||
- Remove unnecessary changes from the Makefile patch
|
||||
|
||||
* Wed Feb 28 2007 David Cantrell <dcantrell@redhat.com> - 12:3.0.5-23
|
||||
- Update Xen partial checksums patch
|
||||
- Remove perl Requires (#225691)
|
||||
|
1089
draft-ietf-dhc-ldap-schema-01.txt
Normal file
1089
draft-ietf-dhc-ldap-schema-01.txt
Normal file
File diff suppressed because it is too large
Load Diff
223
linux.dbus-example
Executable file
223
linux.dbus-example
Executable file
@ -0,0 +1,223 @@
|
||||
#!/bin/bash
|
||||
# dhclient-script for Linux. Dan Halbert, March, 1997.
|
||||
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
|
||||
# No guarantees about this. I'm a novice at the details of Linux
|
||||
# networking.
|
||||
|
||||
# Notes:
|
||||
|
||||
# 0. This script is based on the netbsd script supplied with dhcp-970306.
|
||||
|
||||
# 1. ifconfig down apparently deletes all relevant routes and flushes
|
||||
# the arp cache, so this doesn't need to be done explicitly.
|
||||
|
||||
# 2. The alias address handling here has not been tested AT ALL.
|
||||
# I'm just going by the doc of modern Linux ip aliasing, which uses
|
||||
# notations like eth0:0, eth0:1, for each alias.
|
||||
|
||||
# 3. I have to calculate the network address, and calculate the broadcast
|
||||
# address if it is not supplied. This might be much more easily done
|
||||
# by the dhclient C code, and passed on.
|
||||
|
||||
# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
|
||||
# of the $1 in its args.
|
||||
|
||||
if [ -n "${dhc_dbus}" ]; then
|
||||
/bin/dbus-send \
|
||||
--system --dest=com.redhat.dhcp --type=method_call \
|
||||
/com/redhat/dhcp/$interface com.redhat.dhcp.set \
|
||||
'string:'"`env | /bin/egrep -v '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`";
|
||||
if (( ( dhc_dbus & 31 ) == 31 )); then
|
||||
exit 0;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
make_resolv_conf() {
|
||||
if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
|
||||
echo search $new_domain_name >/etc/resolv.conf
|
||||
chmod 644 /etc/resolv.conf
|
||||
for nameserver in $new_domain_name_servers; do
|
||||
echo nameserver $nameserver >>/etc/resolv.conf
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
|
||||
exit_with_hooks() {
|
||||
exit_status=$1
|
||||
if [ -f /etc/dhclient-exit-hooks ]; then
|
||||
. /etc/dhclient-exit-hooks
|
||||
fi
|
||||
# probably should do something with exit status of the local script
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
# Invoke the local dhcp client enter hooks, if they exist.
|
||||
if [ -f /etc/dhclient-enter-hooks ]; then
|
||||
exit_status=0
|
||||
. /etc/dhclient-enter-hooks
|
||||
# allow the local script to abort processing of this state
|
||||
# local script must set exit_status variable to nonzero.
|
||||
if [ $exit_status -ne 0 ]; then
|
||||
exit $exit_status
|
||||
fi
|
||||
fi
|
||||
|
||||
release=`uname -r`
|
||||
release=`expr $release : '\(.*\)\..*'`
|
||||
relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
|
||||
relmajor=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
|
||||
|
||||
if [ x$new_broadcast_address != x ]; then
|
||||
new_broadcast_arg="broadcast $new_broadcast_address"
|
||||
fi
|
||||
if [ x$old_broadcast_address != x ]; then
|
||||
old_broadcast_arg="broadcast $old_broadcast_address"
|
||||
fi
|
||||
if [ x$new_subnet_mask != x ]; then
|
||||
new_subnet_arg="netmask $new_subnet_mask"
|
||||
fi
|
||||
if [ x$old_subnet_mask != x ]; then
|
||||
old_subnet_arg="netmask $old_subnet_mask"
|
||||
fi
|
||||
if [ x$alias_subnet_mask != x ]; then
|
||||
alias_subnet_arg="netmask $alias_subnet_mask"
|
||||
fi
|
||||
|
||||
if [ x$reason = xMEDIUM ]; then
|
||||
# Linux doesn't do mediums (ok, ok, media).
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
if [ x$reason = xPREINIT ]; then
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
# Bring down alias interface. Its routes will disappear too.
|
||||
ifconfig $interface:0- inet 0
|
||||
fi
|
||||
if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] )
|
||||
then
|
||||
ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
|
||||
broadcast 255.255.255.255 up
|
||||
# Add route to make broadcast work. Do not omit netmask.
|
||||
route add default dev $interface netmask 0.0.0.0
|
||||
else
|
||||
ifconfig $interface 0 up
|
||||
fi
|
||||
|
||||
# We need to give the kernel some time to get the interface up.
|
||||
sleep 1
|
||||
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
||||
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
|
||||
current_hostname=`hostname`
|
||||
if [ x$current_hostname = x ] || \
|
||||
[ x$current_hostname = x$old_host_name ]; then
|
||||
if [ x$current_hostname = x ] || \
|
||||
[ x$new_host_name != x$old_host_name ]; then
|
||||
hostname $new_host_name
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
|
||||
[ x$alias_ip_address != x$old_ip_address ]; then
|
||||
# Possible new alias. Remove old alias.
|
||||
ifconfig $interface:0- inet 0
|
||||
fi
|
||||
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
|
||||
# IP address changed. Bringing down the interface will delete all routes,
|
||||
# and clear the ARP cache.
|
||||
ifconfig $interface inet 0 down
|
||||
|
||||
fi
|
||||
fi
|
||||
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
|
||||
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
ifconfig $interface inet $new_ip_address $new_subnet_arg \
|
||||
$new_broadcast_arg
|
||||
fi
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 4 ) != 4 )); then
|
||||
# Add a network route to the computed network address.
|
||||
if [ $relmajor -lt 2 ] || \
|
||||
( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
|
||||
route add -net $new_network_number $new_subnet_arg dev $interface
|
||||
fi
|
||||
for router in $new_routers; do
|
||||
route add default gw $router
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
|
||||
then
|
||||
ifconfig $interface:0- inet 0
|
||||
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
route add -host $alias_ip_address $interface:0
|
||||
fi
|
||||
fi
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 1 ) != 1 )); then
|
||||
make_resolv_conf
|
||||
fi
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|
||||
|| [ x$reason = xSTOP ]; then
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
# Turn off alias interface.
|
||||
ifconfig $interface:0- inet 0
|
||||
fi
|
||||
if [ x$old_ip_address != x ]; then
|
||||
# Shut down interface, which will delete routes and clear arp cache.
|
||||
ifconfig $interface inet 0 down
|
||||
fi
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
route add -host $alias_ip_address $interface:0
|
||||
fi
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ x$reason = xTIMEOUT ]; then
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
ifconfig $interface:0- inet 0
|
||||
fi
|
||||
ifconfig $interface inet $new_ip_address $new_subnet_arg \
|
||||
$new_broadcast_arg
|
||||
fi
|
||||
set $new_routers
|
||||
############## what is -w in ping?
|
||||
if ping -q -c 1 $1; then
|
||||
if [ x$new_ip_address != x$alias_ip_address ] && \
|
||||
[ x$alias_ip_address != x ]; then
|
||||
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
route add -host $alias_ip_address dev $interface:0
|
||||
fi
|
||||
if [ $relmajor -lt 2 ] || \
|
||||
( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
|
||||
route add -net $new_network_number
|
||||
fi
|
||||
for router in $new_routers; do
|
||||
route add default gw $router
|
||||
done
|
||||
make_resolv_conf
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
ifconfig $interface inet 0 down
|
||||
fi
|
||||
exit_with_hooks 1
|
||||
fi
|
||||
|
||||
exit_with_hooks 0
|
Loading…
Reference in New Issue
Block a user