diff options
author | 2012-10-30 18:39:43 +0000 | |
---|---|---|
committer | 2012-10-30 18:39:43 +0000 | |
commit | c78c685e6cd7c1ced4fbcd21ebe7e0185e667cb8 (patch) | |
tree | 20e65e2fdeca5c05f91830f4f1a9d508f1af9daf | |
parent | introduce specialized register read and write functions (diff) | |
download | wireguard-openbsd-c78c685e6cd7c1ced4fbcd21ebe7e0185e667cb8.tar.xz wireguard-openbsd-c78c685e6cd7c1ced4fbcd21ebe7e0185e667cb8.zip |
Nuke dhclient-script and dhclient.conf 'script' directive. Do all
interface and route configuration via ioctl's and routing sockets.
This will break configurations using local enhancements of
dhclient-script, which will now require alternate arrangements.
Committing early to allow time to identify and develop required
alternatives.
Several proddings by deraadt@.
34 files changed, 678 insertions, 715 deletions
diff --git a/distrib/alpha/bsd.rd/list.local b/distrib/alpha/bsd.rd/list.local index 4b4082bad2e..8ac70a75532 100644 --- a/distrib/alpha/bsd.rd/list.local +++ b/distrib/alpha/bsd.rd/list.local @@ -12,8 +12,5 @@ LINK instbin sbin/bioctl COPY ${DESTDIR}/etc/firmware/kue etc/firmware/kue COPY ${DESTDIR}/etc/firmware/3c990 etc/firmware/3c990 -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script -SPECIAL chmod 755 sbin/dhclient-script - HASH var/hash TZ diff --git a/distrib/amd64/ramdisk_cd/list.local b/distrib/amd64/ramdisk_cd/list.local index 6d27bea458f..ea8d11aa142 100644 --- a/distrib/amd64/ramdisk_cd/list.local +++ b/distrib/amd64/ramdisk_cd/list.local @@ -1,4 +1,4 @@ -# $OpenBSD: list.local,v 1.21 2012/10/15 17:21:04 deraadt Exp $ +# $OpenBSD: list.local,v 1.22 2012/10/30 18:39:43 krw Exp $ # add local links; use bin/sh since instbin has already been unlinked LINK instbin bin/sha256 @@ -32,9 +32,5 @@ COPY ${DESTDIR}/etc/firmware/run-rt3071 etc/firmware/run-rt3071 COPY ${DESTDIR}/etc/firmware/zd1211 etc/firmware/zd1211 COPY ${DESTDIR}/etc/firmware/zd1211b etc/firmware/zd1211b -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script -SPECIAL chmod 755 sbin/dhclient-script - HASH var/hash TZ diff --git a/distrib/armish/ramdisk/list b/distrib/armish/ramdisk/list index 3049e446428..b927557bc9c 100644 --- a/distrib/armish/ramdisk/list +++ b/distrib/armish/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.14 2010/10/18 04:07:50 deraadt Exp $ +# $OpenBSD: list,v 1.15 2012/10/30 18:39:43 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -75,16 +75,13 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/distrib/beagle/ramdisk/list b/distrib/beagle/ramdisk/list index 1b5bce22c41..8944639c061 100644 --- a/distrib/beagle/ramdisk/list +++ b/distrib/beagle/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.1 2011/03/14 16:40:23 drahn Exp $ +# $OpenBSD: list,v 1.2 2012/10/30 18:39:43 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -75,16 +75,13 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/distrib/hp300/ramdisk/list b/distrib/hp300/ramdisk/list index d7e5c14547b..5fa264b91c3 100644 --- a/distrib/hp300/ramdisk/list +++ b/distrib/hp300/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.57 2012/10/16 16:15:58 deraadt Exp $ +# $OpenBSD: list,v 1.58 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -77,15 +77,12 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb,hp2392,hpansi,hpsub,hpex,hp700-wy,hp70092 usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash diff --git a/distrib/hppa/list b/distrib/hppa/list index 4cb5a8e288b..ac992711bf0 100644 --- a/distrib/hppa/list +++ b/distrib/hppa/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.18 2012/10/16 16:59:02 deraadt Exp $ +# $OpenBSD: list,v 1.19 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -58,9 +58,6 @@ SPECIAL pwd_mkdb -p -d etc master.passwd; rm etc/master.passwd COPY ${CURDIR}/../../miniroot/protocols etc/protocols COPY ${CURDIR}/../../miniroot/services etc/services -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # for disklabel(8) -B COPY ${DESTDIR}/usr/mdec/sdboot usr/mdec/sdboot @@ -69,7 +66,7 @@ SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade # the hashes of the various install components HASH var/hash diff --git a/distrib/i386/common/list b/distrib/i386/common/list index 911dfc3a184..635246cfa27 100644 --- a/distrib/i386/common/list +++ b/distrib/i386/common/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.27 2012/10/15 17:21:03 deraadt Exp $ +# $OpenBSD: list,v 1.28 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -71,13 +71,10 @@ SYMLINK /tmp/fstab.shadow etc/fstab SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/../common/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade diff --git a/distrib/landisk/ramdisk/list b/distrib/landisk/ramdisk/list index 960a90ed874..e98bebf2470 100644 --- a/distrib/landisk/ramdisk/list +++ b/distrib/landisk/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.22 2012/10/17 02:36:16 deraadt Exp $ +# $OpenBSD: list,v 1.23 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -104,16 +104,13 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/distrib/loongson/ramdisk/list b/distrib/loongson/ramdisk/list index 4f1dc9a546e..c962adcd6f2 100644 --- a/distrib/loongson/ramdisk/list +++ b/distrib/loongson/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.8 2012/10/15 16:15:34 deraadt Exp $ +# $OpenBSD: list,v 1.9 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -101,16 +101,13 @@ COPY ${DESTDIR}/etc/firmware/ral-rt2561 etc/firmware/ral-rt2561 COPY ${DESTDIR}/etc/firmware/ral-rt2561s etc/firmware/ral-rt2561s COPY ${DESTDIR}/etc/firmware/ral-rt2661 etc/firmware/ral-rt2661 -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/distrib/luna88k/ramdisk/list b/distrib/luna88k/ramdisk/list index b01e9dc0754..8f58da19929 100644 --- a/distrib/luna88k/ramdisk/list +++ b/distrib/luna88k/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.16 2010/10/18 04:07:50 deraadt Exp $ +# $OpenBSD: list,v 1.17 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -68,9 +68,6 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md @@ -78,6 +75,6 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash diff --git a/distrib/macppc/ramdisk/list b/distrib/macppc/ramdisk/list index 24a444ed8b9..c34f53de447 100644 --- a/distrib/macppc/ramdisk/list +++ b/distrib/macppc/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.44 2012/10/15 02:27:23 deraadt Exp $ +# $OpenBSD: list,v 1.45 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -86,16 +86,13 @@ COPY ${DESTDIR}/etc/firmware/rum-rt2573 etc/firmware/rum-rt2573 COPY ${DESTDIR}/etc/firmware/run-rt2870 etc/firmware/run-rt2870 COPY ${DESTDIR}/etc/firmware/run-rt3071 etc/firmware/run-rt3071 -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/distrib/mvme68k/ramdisk/list b/distrib/mvme68k/ramdisk/list index 1bb5f2b29eb..90881066496 100644 --- a/distrib/mvme68k/ramdisk/list +++ b/distrib/mvme68k/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.41 2012/10/17 03:05:09 deraadt Exp $ +# $OpenBSD: list,v 1.42 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -68,9 +68,6 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md @@ -78,6 +75,6 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash diff --git a/distrib/mvme88k/ramdisk/list b/distrib/mvme88k/ramdisk/list index c03cb27fde2..e3b0501ec66 100644 --- a/distrib/mvme88k/ramdisk/list +++ b/distrib/mvme88k/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.39 2012/10/17 03:05:11 deraadt Exp $ +# $OpenBSD: list,v 1.40 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -68,9 +68,6 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md @@ -78,6 +75,6 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash diff --git a/distrib/palm/ramdisk/list b/distrib/palm/ramdisk/list index 290bf8a89ed..a0eb4a855d4 100644 --- a/distrib/palm/ramdisk/list +++ b/distrib/palm/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.4 2010/10/18 04:07:51 deraadt Exp $ +# $OpenBSD: list,v 1.5 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -75,16 +75,13 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/distrib/ramdisk/list b/distrib/ramdisk/list index d9c4d00783a..41d7ac53e3c 100644 --- a/distrib/ramdisk/list +++ b/distrib/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.39 2010/10/18 04:07:51 deraadt Exp $ +# $OpenBSD: list,v 1.40 2012/10/30 18:39:44 krw Exp $ # $NetBSD: list,v 1.4.4.1 1996/06/20 20:30:26 pk Exp $ SRCDIRS distrib/special @@ -59,15 +59,12 @@ SPECIAL pwd_mkdb -p -d etc master.passwd; rm etc/master.passwd COPY ${CURDIR}/../miniroot/protocols etc/protocols COPY ${CURDIR}/../miniroot/services etc/services -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation scripts SCRIPT ${CURDIR}/../miniroot/dot.profile .profile SCRIPT ${CURDIR}/../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../miniroot/install.sh install SCRIPT ${CURDIR}/../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/distrib/sgi/ramdisk/list b/distrib/sgi/ramdisk/list index 44140e243ae..fe043a409aa 100644 --- a/distrib/sgi/ramdisk/list +++ b/distrib/sgi/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.33 2012/10/18 16:57:31 deraadt Exp $ +# $OpenBSD: list,v 1.34 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -82,16 +82,13 @@ COPY ${DESTDIR}/etc/firmware/bnx-rv2p etc/firmware/bnx-rv2p COPY ${DESTDIR}/etc/firmware/bnx-xi-rv2p etc/firmware/bnx-xi-rv2p COPY ${DESTDIR}/etc/firmware/bnx-xi90-rv2p etc/firmware/bnx-xi90-rv2p -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash bsd.IP22 bsd.IP27 bsd.IP28 bsd.IP30 bsd.mp.IP30 bsd.IP32 TZ diff --git a/distrib/socppc/ramdisk/list b/distrib/socppc/ramdisk/list index 0f38ffb6ecc..627ebd7d5fe 100644 --- a/distrib/socppc/ramdisk/list +++ b/distrib/socppc/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.14 2012/10/16 23:07:20 deraadt Exp $ +# $OpenBSD: list,v 1.15 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -97,16 +97,13 @@ COPY ${DESTDIR}/etc/firmware/atu-rfmd2958-int etc/firmware/atu-rfmd2958-int COPY ${DESTDIR}/etc/firmware/atu-rfmd2958smc-ext etc/firmware/atu-rfmd2958smc-ext COPY ${DESTDIR}/etc/firmware/atu-rfmd2958smc-int etc/firmware/atu-rfmd2958smc-int -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/distrib/sparc64/bsd.rd/list b/distrib/sparc64/bsd.rd/list index bfa678d46e4..88dad28129b 100644 --- a/distrib/sparc64/bsd.rd/list +++ b/distrib/sparc64/bsd.rd/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.39 2012/10/21 17:46:33 deraadt Exp $ +# $OpenBSD: list,v 1.40 2012/10/30 18:39:44 krw Exp $ # $NetBSD: list,v 1.4.4.1 1996/06/20 20:30:26 pk Exp $ SRCDIRS distrib/special @@ -72,16 +72,13 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb,sun usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation scripts SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/../common/install.md install.md SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade COPY ${DESTDIR}/etc/firmware/bnx-b06 etc/firmware/bnx-b06 COPY ${DESTDIR}/etc/firmware/bnx-b09 etc/firmware/bnx-b09 diff --git a/distrib/special/dhclient/Makefile b/distrib/special/dhclient/Makefile index cfa1590f79f..eee5c976f06 100644 --- a/distrib/special/dhclient/Makefile +++ b/distrib/special/dhclient/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.10 2009/10/28 07:36:49 deraadt Exp $ +# $OpenBSD: Makefile,v 1.11 2012/10/30 18:39:44 krw Exp $ .include <bsd.own.mk> @@ -7,8 +7,8 @@ CLIENT_PATH='"PATH=/usr/bin:/usr/sbin:/bin:/sbin"' CPPFLAGS+= -I${.CURDIR}/../../../sbin/dhclient SRCS= dhclient.c clparse.c dispatch.c bpf.c options.c \ - conflex.c errwarn.c inet.c packet.c convert.c tables.c parse.c \ - privsep.c + conflex.c errwarn.c inet.c kroute.c packet.c convert.c \ + tables.c parse.c privsep.c PROG= dhclient .include <bsd.prog.mk> diff --git a/distrib/zaurus/ramdisk/list b/distrib/zaurus/ramdisk/list index db869e6f362..5571fd5cf1d 100644 --- a/distrib/zaurus/ramdisk/list +++ b/distrib/zaurus/ramdisk/list @@ -1,4 +1,4 @@ -# $OpenBSD: list,v 1.18 2010/10/18 04:08:32 deraadt Exp $ +# $OpenBSD: list,v 1.19 2012/10/30 18:39:44 krw Exp $ SRCDIRS distrib/special SRCDIRS bin sbin usr.bin usr.sbin @@ -76,16 +76,13 @@ SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf SYMLINK /tmp/hosts etc/hosts TERMCAP vt100,vt220,dumb usr/share/misc/termcap -# dhcp things -SCRIPT ${DESTDIR}/sbin/dhclient-script sbin/dhclient-script - # and the installation tools SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile SCRIPT ${CURDIR}/install.md install.md SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub -SPECIAL chmod 755 install upgrade sbin/dhclient-script +SPECIAL chmod 755 install upgrade HASH var/hash TZ diff --git a/sbin/dhclient/Makefile b/sbin/dhclient/Makefile index e7f3792d1f6..a053d3f2c65 100644 --- a/sbin/dhclient/Makefile +++ b/sbin/dhclient/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2005/07/17 19:33:55 krw Exp $ +# $OpenBSD: Makefile,v 1.13 2012/10/30 18:39:44 krw Exp $ # # Copyright (c) 1996, 1997 The Internet Software Consortium. # All rights reserved. @@ -34,15 +34,11 @@ SRCS= dhclient.c clparse.c dispatch.c bpf.c options.c \ conflex.c errwarn.c inet.c packet.c convert.c tables.c \ - parse.c privsep.c + parse.c privsep.c kroute.c PROG= dhclient -MAN= dhclient.8 dhclient.conf.5 dhclient.leases.5 dhclient-script.8 +MAN= dhclient.8 dhclient.conf.5 dhclient.leases.5 CFLAGS+=-Wall -beforeinstall: - ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/dhclient-script ${DESTDIR}/sbin/dhclient-script - .include <bsd.prog.mk> diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 877c4330008..72a1cd9065c 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.41 2012/10/27 23:08:53 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.42 2012/10/30 18:39:44 krw Exp $ */ /* Parser for dhclient config and lease files... */ @@ -66,7 +66,6 @@ read_client_conf(void) config->backoff_cutoff = 15; config->initial_interval = 3; config->bootp_policy = ACCEPT; - config->script_name = _PATH_DHCLIENT_SCRIPT; config->requested_options [config->requested_option_count++] = DHO_SUBNET_MASK; config->requested_options @@ -145,7 +144,6 @@ read_client_leases(void) * TOK_REBOOT number | * TOK_BACKOFF_CUTOFF number | * TOK_INITIAL_INTERVAL number | - * TOK_SCRIPT string | * interface-declaration | * TOK_LEASE client-lease-statement | * TOK_ALIAS client-lease-statement | @@ -222,9 +220,6 @@ parse_client_statement(FILE *cfile) case TOK_INITIAL_INTERVAL: parse_lease_time(cfile, &config->initial_interval); return; - case TOK_SCRIPT: - config->script_name = parse_string(cfile); - return; case TOK_INTERFACE: parse_interface_declaration(cfile); return; diff --git a/sbin/dhclient/conflex.c b/sbin/dhclient/conflex.c index ec60dbb9516..2aead95e75c 100644 --- a/sbin/dhclient/conflex.c +++ b/sbin/dhclient/conflex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conflex.c,v 1.15 2012/08/22 00:14:42 tedu Exp $ */ +/* $OpenBSD: conflex.c,v 1.16 2012/10/30 18:39:44 krw Exp $ */ /* Lexical scanner for dhclient config file... */ @@ -353,7 +353,6 @@ static const struct keywords { { "request", TOK_REQUEST }, { "require", TOK_REQUIRE }, { "retry", TOK_RETRY }, - { "script", TOK_SCRIPT }, { "select-timeout", TOK_SELECT_TIMEOUT }, { "send", TOK_SEND }, { "server-name", TOK_SERVER_NAME }, diff --git a/sbin/dhclient/dhclient.8 b/sbin/dhclient/dhclient.8 index f3de9fe4019..c8915018a8e 100644 --- a/sbin/dhclient/dhclient.8 +++ b/sbin/dhclient/dhclient.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhclient.8,v 1.8 2011/03/02 07:44:42 jmc Exp $ +.\" $OpenBSD: dhclient.8,v 1.9 2012/10/30 18:39:44 krw Exp $ .\" .\" Copyright (c) 1997 The Internet Software Consortium. .\" All rights reserved. @@ -35,7 +35,7 @@ .\" Enterprises. To learn more about the Internet Software Consortium, .\" see ``http://www.isc.org/isc''. To learn more about Vixie .\" Enterprises, see ``http://www.vix.com''. -.Dd $Mdocdate: March 2 2011 $ +.Dd $Mdocdate: October 30 2012 $ .Dt DHCLIENT 8 .Os .Sh NAME @@ -166,7 +166,6 @@ database of acquired leases .Xr bpf 4 , .Xr dhclient.conf 5 , .Xr dhclient.leases 5 , -.Xr dhclient-script 8 , .Xr dhcp 8 , .Xr dhcpd 8 , .Xr dhcrelay 8 diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 9ce6f69e391..b80b7a2e091 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.158 2012/10/27 23:08:53 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.159 2012/10/30 18:39:44 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -77,6 +77,9 @@ int unknown_ok = 1; int routefd = -1; struct iaddr iaddr_broadcast = { 4, { 255, 255, 255, 255 } }; +struct iaddr iaddr_deleting; +struct iaddr iaddr_adding; + struct in_addr inaddr_any; struct sockaddr_in sockaddr_broadcast; @@ -91,14 +94,16 @@ int check_option(struct client_lease *l, int option); int ipv4addrs(char * buf); int res_hnok(const char *dn); char *option_as_string(unsigned int code, unsigned char *data, int len); -int fork_privchld(int, int); +pid_t fork_privchld(int, int); void get_ifname(char *, char *); +void new_resolv_conf(char *, char *, char *); +struct client_lease *apply_defaults(struct client_lease *); +struct client_lease *clone_lease(struct client_lease *); #define ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) #define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) -time_t scripttime; static FILE *leaseFile; int @@ -160,7 +165,6 @@ routehandler(void) struct if_msghdr *ifm; struct ifa_msghdr *ifam; struct if_announcemsghdr *ifan; - struct client_lease *l; struct sockaddr *sa; struct iaddr a; ssize_t n; @@ -177,6 +181,7 @@ routehandler(void) switch (rtm->rtm_type) { case RTM_NEWADDR: + case RTM_DELADDR: ifam = (struct ifa_msghdr *)rtm; if (ifam->ifam_index != ifi->index) break; @@ -196,31 +201,27 @@ routehandler(void) if (addr_eq(a, defaddr)) break; - /* state_panic() can try unexpired existing leases */ - if (client->active && addr_eq(a, client->active->address)) - break; - for (l = client->leases; l != NULL; l = l->next) - if (addr_eq(a, l->address)) + /* + * If we are in the process of binding a new lease, ignore + * messages generated by that process. + */ + if (rtm->rtm_type == RTM_NEWADDR) { + if (addr_eq(a, iaddr_adding)) { + iaddr_adding = defaddr; break; - if (l != NULL) - /* new addr is the one we set */ - break; - - snprintf(buf, sizeof(buf), "%s: %s", - "new address not one we set", piaddr(a)); - errmsg = buf; - goto die; - case RTM_DELADDR: - ifam = (struct ifa_msghdr *)rtm; - if (ifam->ifam_index != ifi->index) - break; - if (findproto((char *)ifam + ifam->ifam_hdrlen, - ifam->ifam_addrs) != AF_INET) - break; - /* XXX check addrs like RTM_NEWADDR instead of this? */ - if (scripttime == 0 || time(NULL) < scripttime + 10) - break; - errmsg = "interface address deleted"; + } + snprintf(buf, sizeof(buf), "%s: %s", + "new address not one we set", piaddr(a)); + errmsg = "interface address added"; + } else { + if (addr_eq(a, iaddr_deleting)) { + iaddr_deleting = defaddr; + break; + } + snprintf(buf, sizeof(buf), "%s: %s", + "new address not one we set", piaddr(a)); + errmsg = "interface address deleted"; + } goto die; case RTM_IFINFO: ifm = (struct if_msghdr *)rtm; @@ -260,8 +261,7 @@ routehandler(void) return; die: - script_init("FAIL"); - script_go(); + flush_routes_and_arp_cache(ifi->name, ifi->rdomain); error("routehandler: %s", errmsg); } @@ -390,6 +390,9 @@ main(int argc, char *argv[]) if (setsockopt(routefd, PF_ROUTE, ROUTE_MSGFILTER, &rtfilter, sizeof(rtfilter)) == -1) error("setsockopt(ROUTE_MSGFILTER): %m"); + if (setsockopt(routefd, AF_ROUTE, ROUTE_TABLEFILTER, &ifi->rdomain, + sizeof(ifi->rdomain)) == -1) + error("setsockopt(ROUTE_TABLEFILTER): %m"); /* set up the interface */ discover_interface(); @@ -656,14 +659,50 @@ dhcpack(struct iaddr client_addr, struct option_data *options) void bind_lease(void) { - /* Run the client script with the new parameters. */ - script_init((client->state == S_REQUESTING ? "BOUND" : - (client->state == S_RENEWING ? "RENEW" : - (client->state == S_REBOOTING ? "REBOOT" : "REBIND")))); - if (client->active && client->state != S_REBOOTING) - script_write_params("old_", client->active); - script_write_params("new_", client->new); - script_go(); + struct iaddr gateway; + struct option_data *options; + struct client_lease *lease; + in_addr_t *mask = NULL; + char *domainname, *nameservers; + + if (client->active) { + delete_old_address(ifi->name, ifi->rdomain, + client->active->address); + } + + flush_routes_and_arp_cache(ifi->name, ifi->rdomain); + + lease = apply_defaults(client->new); + options = lease->options; + + mask = (in_addr_t *)options[DHO_SUBNET_MASK].data; + add_new_address(ifi->name, ifi->rdomain, client->new->address, mask); + if (options[DHO_ROUTERS].len) { + bzero(&gateway, sizeof(gateway)); + /* XXX Only use FIRST router address for now. */ + gateway.len = sizeof(in_addr_t); + bcopy(options[DHO_ROUTERS].data, + gateway.iabuf, sizeof(in_addr_t)); + add_default_route(ifi->name, ifi->rdomain, + client->new->address, gateway); + } + if (options[DHO_DOMAIN_NAME].len) + domainname = strdup(pretty_print_option( + DHO_DOMAIN_NAME, &options[DHO_DOMAIN_NAME], 0)); + else + domainname = strdup(""); + if (options[DHO_DOMAIN_NAME_SERVERS].len) { + nameservers = strdup(pretty_print_option( + DHO_DOMAIN_NAME_SERVERS, + &options[DHO_DOMAIN_NAME_SERVERS], 0)); + } else + nameservers = strdup(""); + + new_resolv_conf(ifi->name, domainname, nameservers); + + free(domainname); + free(nameservers); + free_client_lease(lease); /* Replace the old active lease with the new one. */ if (client->active) @@ -909,8 +948,6 @@ send_discover(void) /* Figure out how long it's been since we started transmitting. */ interval = cur_time - client->first_sending; - /* If we're past the panic timeout, call the script and tell it - we haven't found anything for this interface yet. */ if (interval > config->timeout) { state_panic(); return; @@ -965,8 +1002,7 @@ send_discover(void) /* * state_panic gets called if we haven't received any offers in a preset * amount of time. When this happens, we try to use existing leases - * that haven't yet expired, and failing that, we call the client script - * and hope it can do something. + * that haven't yet expired. */ void state_panic(void) @@ -988,30 +1024,26 @@ state_panic(void) if (client->active->expiry > cur_time) { note("Trying recorded lease %s", piaddr(client->active->address)); - /* Run the client script with the existing - parameters. */ - script_init("TIMEOUT"); - script_write_params("new_", client->active); - - /* If the old lease is still good and doesn't - yet need renewal, go into BOUND state and - timeout at the renewal time. */ - if (!script_go()) { - if (cur_time < client->active->renewal) { - client->state = S_BOUND; - note("bound: renewal in %lld seconds.", - (long long)(client->active->renewal - - cur_time)); - set_timeout(client->active->renewal, - state_bound); - } else { - client->state = S_BOUND; - note("bound: immediate renewal."); - state_bound(); - } - go_daemon(); - return; + + /* + * If the old lease is still good and doesn't + * yet need renewal, go into BOUND state and + * timeout at the renewal time. + */ + if (cur_time < client->active->renewal) { + client->state = S_BOUND; + note("bound: renewal in %lld seconds.", + (long long)(client->active->renewal + - cur_time)); + set_timeout(client->active->renewal, + state_bound); + } else { + client->state = S_BOUND; + note("bound: immediate renewal."); + state_bound(); } + go_daemon(); + return; } /* If there are no other leases, give up. */ @@ -1041,12 +1073,10 @@ activate_next: loop = client->active; } - /* No leases were available, or what was available didn't work, so - tell the shell script that we failed to allocate an address, - and try again later. */ + /* + * No leases were available, or what was available didn't work + */ note("No working leases in persistent database - sleeping."); - script_init("FAIL"); - script_go(); client->state = S_INIT; set_timeout_interval(config->retry_interval, state_init); go_daemon(); @@ -1088,11 +1118,10 @@ send_request(void) to the INIT state. */ if (client->state != S_REQUESTING && cur_time > client->active->expiry) { - /* Run the client script with the new parameters. */ - script_init("EXPIRE"); - script_write_params("old_", client->active); - script_go(); - + if (client->active) { + delete_old_address(ifi->name, ifi->rdomain, + client->active->address); + } client->state = S_INIT; state_init(); return; @@ -1449,358 +1478,6 @@ write_client_lease(struct client_lease *lease) } void -script_init(char *reason) -{ - size_t len; - struct imsg_hdr hdr; - struct buf *buf; - - hdr.code = IMSG_SCRIPT_INIT; - hdr.len = sizeof(struct imsg_hdr) + sizeof(size_t) + strlen(reason); - - buf = buf_open(hdr.len); - - buf_add(buf, &hdr, sizeof(hdr)); - len = strlen(reason); - buf_add(buf, &len, sizeof(len)); - buf_add(buf, reason, len); - - buf_close(privfd, buf); -} - -void -priv_script_init(char *reason) -{ - char *rdomain; - - client->scriptEnvsize = 100; - if (client->scriptEnv == NULL) - client->scriptEnv = - calloc(client->scriptEnvsize, sizeof(char *)); - if (client->scriptEnv == NULL) - error("script_init: no memory for environment"); - - client->scriptEnv[0] = strdup(CLIENT_PATH); - if (client->scriptEnv[0] == NULL) - error("script_init: no memory for environment"); - - client->scriptEnv[1] = NULL; - - script_set_env("", "interface", ifi->name); - - if (asprintf(&rdomain, "-T %d", ifi->rdomain) == -1) - error("script_init: no memory for environment"); - - script_set_env("", "rdomain", rdomain); - free(rdomain); - - script_set_env("", "reason", reason); -} - -void -priv_script_write_params(char *prefix, struct client_lease *lease) -{ - char buf[256]; - struct option_data o; - int i; - - script_set_env(prefix, "ip_address", piaddr(lease->address)); - - if (lease->options[DHO_SUBNET_MASK].len && - (lease->options[DHO_SUBNET_MASK].len < - sizeof(lease->address.iabuf))) { - struct iaddr netmask, subnet, broadcast; - - memcpy(netmask.iabuf, lease->options[DHO_SUBNET_MASK].data, - lease->options[DHO_SUBNET_MASK].len); - netmask.len = lease->options[DHO_SUBNET_MASK].len; - - subnet = subnet_number(lease->address, netmask); - if (subnet.len) { - script_set_env(prefix, "network_number", - piaddr(subnet)); - if (!lease->options[DHO_BROADCAST_ADDRESS].len) { - broadcast = broadcast_addr(subnet, netmask); - if (broadcast.len) - script_set_env(prefix, - "broadcast_address", - piaddr(broadcast)); - } - } - } - - if (lease->filename) - script_set_env(prefix, "filename", lease->filename); - if (lease->server_name) - script_set_env(prefix, "server_name", - lease->server_name); - - for (i = 0; i < 256; i++) { - if (!dhcp_option_ev_name(buf, sizeof(buf), &dhcp_options[i])) - continue; - - switch (config->default_actions[i]) { - case ACTION_IGNORE: - break; - - case ACTION_DEFAULT: - if (lease->options[i].len) - script_set_env(prefix, buf, - pretty_print_option(i, &lease->options[i], - 0)); - else if (config->defaults[i].len) - script_set_env(prefix, buf, - pretty_print_option(i, &config->defaults[i], - 0)); - break; - - case ACTION_SUPERSEDE: - if (config->defaults[i].len) - script_set_env(prefix, buf, - pretty_print_option(i, &config->defaults[i], - 0)); - break; - - case ACTION_PREPEND: - o.len = config->defaults[i].len + lease->options[i].len; - if (o.len > 0) { - o.data = calloc(1, o.len); - if (o.data == NULL) - error("no space to prepend '%s' to %s", - config->defaults[i].data, - dhcp_options[i].name); - memcpy(o.data, config->defaults[i].data, - config->defaults[i].len); - memcpy(o.data + config->defaults[i].len, - lease->options[i].data, - lease->options[i].len); - script_set_env(prefix, buf, - pretty_print_option(i, &o, 0)); - free(o.data); - } - break; - - case ACTION_APPEND: - o.len = config->defaults[i].len + lease->options[i].len; - if (o.len > 0) { - o.data = calloc(1, o.len); - if (o.data == NULL) - error("no space to append '%s' to %s", - config->defaults[i].data, - dhcp_options[i].name); - memcpy(o.data, lease->options[i].data, - lease->options[i].len); - memcpy(o.data + lease->options[i].len, - config->defaults[i].data, - config->defaults[i].len); - script_set_env(prefix, buf, - pretty_print_option(i, &o, 0)); - free(o.data); - } - break; - } - } - - snprintf(buf, sizeof(buf), "%d", (int)lease->expiry); - script_set_env(prefix, "expiry", buf); -} - -void -script_write_params(char *prefix, struct client_lease *lease) -{ - size_t fn_len = 0, sn_len = 0, pr_len = 0; - struct imsg_hdr hdr; - struct buf *buf; - int i; - - if (lease->filename != NULL) - fn_len = strlen(lease->filename); - if (lease->server_name != NULL) - sn_len = strlen(lease->server_name); - if (prefix != NULL) - pr_len = strlen(prefix); - - hdr.code = IMSG_SCRIPT_WRITE_PARAMS; - hdr.len = sizeof(hdr) + sizeof(struct client_lease) + - sizeof(size_t) + fn_len + sizeof(size_t) + sn_len + - sizeof(size_t) + pr_len; - - for (i = 0; i < 256; i++) - hdr.len += sizeof(int) + lease->options[i].len; - - scripttime = time(NULL); - - buf = buf_open(hdr.len); - - buf_add(buf, &hdr, sizeof(hdr)); - buf_add(buf, lease, sizeof(struct client_lease)); - buf_add(buf, &fn_len, sizeof(fn_len)); - buf_add(buf, lease->filename, fn_len); - buf_add(buf, &sn_len, sizeof(sn_len)); - buf_add(buf, lease->server_name, sn_len); - buf_add(buf, &pr_len, sizeof(pr_len)); - buf_add(buf, prefix, pr_len); - - for (i = 0; i < 256; i++) { - buf_add(buf, &lease->options[i].len, - sizeof(lease->options[i].len)); - buf_add(buf, lease->options[i].data, - lease->options[i].len); - } - - buf_close(privfd, buf); -} - -int -script_go(void) -{ - struct imsg_hdr hdr; - struct buf *buf; - int ret; - - scripttime = time(NULL); - - hdr.code = IMSG_SCRIPT_GO; - hdr.len = sizeof(struct imsg_hdr); - - buf = buf_open(hdr.len); - - buf_add(buf, &hdr, sizeof(hdr)); - buf_close(privfd, buf); - - bzero(&hdr, sizeof(hdr)); - buf_read(privfd, &hdr, sizeof(hdr)); - if (hdr.code != IMSG_SCRIPT_GO_RET) - error("unexpected msg type %u", hdr.code); - if (hdr.len != sizeof(hdr) + sizeof(int)) - error("received corrupted message"); - buf_read(privfd, &ret, sizeof(ret)); - - return (ret); -} - -int -priv_script_go(void) -{ - char *scriptName, *argv[2], **envp; - int pid, wpid, wstatus; - - scripttime = time(NULL); - - scriptName = config->script_name; - envp = client->scriptEnv; - - argv[0] = scriptName; - argv[1] = NULL; - - pid = fork(); - if (pid < 0) { - error("fork: %m"); - wstatus = 0; - } else if (pid) { - do { - wpid = wait(&wstatus); - } while (wpid != pid && wpid > 0); - if (wpid < 0) { - error("wait: %m"); - wstatus = 0; - } - } else { - execve(scriptName, argv, envp); - error("execve (%s, ...): %m", scriptName); - } - - script_flush_env(); - - return (WEXITSTATUS(wstatus)); -} - -void -script_set_env(const char *prefix, const char *name, const char *value) -{ - int i, j, namelen; - - namelen = strlen(name); - - for (i = 0; client->scriptEnv[i]; i++) - if (strncmp(client->scriptEnv[i], name, namelen) == 0 && - client->scriptEnv[i][namelen] == '=') - break; - - if (client->scriptEnv[i]) - /* Reuse the slot. */ - free(client->scriptEnv[i]); - else { - /* New variable. Expand if necessary. */ - if (i >= client->scriptEnvsize - 1) { - char **newscriptEnv; - int newscriptEnvsize = client->scriptEnvsize + 50; - - newscriptEnv = realloc(client->scriptEnv, - newscriptEnvsize); - if (newscriptEnv == NULL) { - free(client->scriptEnv); - client->scriptEnv = NULL; - client->scriptEnvsize = 0; - error("script_set_env: no memory for variable"); - } - client->scriptEnv = newscriptEnv; - client->scriptEnvsize = newscriptEnvsize; - } - /* need to set the NULL pointer at end of array beyond - the new slot. */ - client->scriptEnv[i + 1] = NULL; - } - /* Allocate space and format the variable in the appropriate slot. */ - client->scriptEnv[i] = malloc(strlen(prefix) + strlen(name) + 1 + - strlen(value) + 1); - if (client->scriptEnv[i] == NULL) - error("script_set_env: no memory for variable assignment"); - - /* No `` or $() command substitution allowed in environment values! */ - for (j = 0; j < strlen(value); j++) - switch (value[j]) { - case '`': - case '$': - error("illegal character (%c) in value '%s'", value[j], - value); - /* not reached */ - } - snprintf(client->scriptEnv[i], strlen(prefix) + strlen(name) + - 1 + strlen(value) + 1, "%s%s=%s", prefix, name, value); -} - -void -script_flush_env(void) -{ - int i; - - for (i = 0; client->scriptEnv[i]; i++) { - free(client->scriptEnv[i]); - client->scriptEnv[i] = NULL; - } - client->scriptEnvsize = 0; -} - -int -dhcp_option_ev_name(char *buf, size_t buflen, const struct option *option) -{ - int i; - - for (i = 0; option->name[i]; i++) { - if (i + 1 == buflen) - return 0; - if (option->name[i] == '-') - buf[i] = '_'; - else - buf[i] = option->name[i]; - } - - buf[i] = 0; - return 1; -} - -void go_daemon(void) { static int state = 0; @@ -2109,3 +1786,205 @@ get_ifname(char *ifname, char *arg) } else if (strlcpy(ifi->name, arg, IFNAMSIZ) >= IFNAMSIZ) error("Interface name too long"); } + +/* + * Update resolv.conf. + */ + +void +new_resolv_conf(char *ifname, char *domainname, char *nameservers) +{ + size_t len; + struct imsg_hdr hdr; + struct buf *buf; + char *contents, *p; + + contents = calloc(1, 2048); + + /* Build string of contents of new resolv.conf. */ + if (domainname && strlen(domainname)) { + strlcat(contents, "search ", 2048); + strlcat(contents, domainname, 2048); + strlcat(contents, "\n", 2048); + } + + for (p = strsep(&nameservers, " "); p != NULL; + p = strsep(&nameservers, " ")) { + strlcat(contents, "nameserver ", 2048); + strlcat(contents, p, 2038); + strlcat(contents, "\n", 2048); + } + + hdr.code = IMSG_NEW_RESOLV_CONF; + hdr.len = sizeof(hdr) + + sizeof(len) + strlen(ifname) + + sizeof(len) + strlen(contents); + + buf = buf_open(hdr.len); + buf_add(buf, &hdr, sizeof(hdr)); + + len = strlen(ifname); + buf_add(buf, &len, sizeof(len)); + buf_add(buf, ifname, len); + + len = strlen(contents); + buf_add(buf, &len, sizeof(len)); + buf_add(buf, contents, len); + + buf_close(privfd, buf); + + free(contents); +} + +void +priv_new_resolv_conf(char *ifname, char *contents) +{ + ssize_t n; + int conffd, tailfd, tailn; + char *buf; + + conffd = open("/etc/resolv.conf", + O_WRONLY | O_CREAT | O_TRUNC | O_SYNC | O_EXLOCK, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (conffd == -1) { + note("Couldn't open resolv.conf: %m"); + return; + } + + n = write(conffd, contents, strlen(contents)); + if (n == -1) + note("Couldn't write contents to resolv.conf: %m"); + else if (n == 0) + note("Couldn't write contents to resolv.conf"); + else if (n < strlen(contents)) + note("Short contents write to resolv.conf (%zd vs %zd)", n, + strlen(contents)); + + tailfd = open("/etc/resolv.conf.tail", O_RDONLY); + + tailn = 0; + buf = calloc(1, 2048); + + if (tailfd == -1) + note("Couldn't open resolv.conf.tail: %m"); + else { + tailn = read(tailfd, buf, 2047); + close(tailfd); + if (tailn == -1) + note("Couldn't read resolv.conf.tail: %m"); + else if (tailn == 0) + note("Got no data from resolv.conf.tail"); + else { + n = write(conffd, buf, strlen(buf)); + if (n == -1) + note("Couldn't write tail to resolv.conf: %m"); + else if (n == 0) + note("Couldn't write tail to resolv.conf"); + else if (n < strlen(buf)) + note("Short tail write to resolv.conf " + "(%zd vs %zd)", n, strlen(buf)); + } + free(buf); + } + + if (strlen(contents) == 0 && tailn == 0) { + note("No contents for resolv.conf"); + return; + } + + fchmod(conffd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + fchown(conffd, 0, 0); /* root:wheel */ + + close(conffd); +} + +struct client_lease * +apply_defaults(struct client_lease *lease) +{ + struct client_lease *newlease; + int i; + + newlease = clone_lease(lease); + + for (i = 0; i < 256; i++) { + if (newlease->options[i].len == 0) + continue; + + switch (config->default_actions[i]) { + case ACTION_IGNORE: + free(newlease->options[i].data); + newlease->options[i].data = NULL; + newlease->options[i].len = 0; + break; + + case ACTION_SUPERSEDE: + free(newlease->options[i].data); + newlease->options[i].len = config->defaults[i].len; + newlease->options[i].data = calloc(1, + config->defaults[i].len); + memcpy(newlease->options[i].data, + config->defaults[i].data, config->defaults[i].len); + break; + + case ACTION_PREPEND: + free(newlease->options[i].data); + newlease->options[i].len = config->defaults[i].len + + lease->options[i].len; + newlease->options[i].data = calloc(1, + newlease->options[i].len); + memcpy(newlease->options[i].data, + config->defaults[i].data, config->defaults[i].len); + memcpy(newlease->options[i].data + + config->defaults[i].len, lease->options[i].data, + lease->options[i].len); + break; + + case ACTION_APPEND: + free(newlease->options[i].data); + newlease->options[i].len = config->defaults[i].len + + lease->options[i].len; + newlease->options[i].data = calloc(1, + newlease->options[i].len); + memcpy(newlease->options[i].data, + lease->options[i].data, lease->options[i].len); + memcpy(newlease->options[i].data + + lease->options[i].len, config->defaults[i].data, + config->defaults[i].len); + break; + + default: + break; + } + } + + return (newlease); +} + +struct client_lease * +clone_lease(struct client_lease *oldlease) +{ + struct client_lease *newlease; + int i; + + newlease = calloc(1, sizeof(struct client_lease)); + + newlease->expiry = oldlease->expiry; + newlease->renewal = oldlease->renewal; + newlease->rebind = oldlease->rebind; + newlease->is_static = oldlease->is_static; + newlease->is_bootp = oldlease->is_bootp; + + if (oldlease->server_name) + newlease->server_name = strdup(oldlease->server_name); + if (oldlease->filename) + newlease->filename = strdup(oldlease->filename); + + for (i = 0; i < 256; i++) { + newlease->options[i].len = oldlease->options[i].len; + newlease->options[i].data = calloc(1, newlease->options[i].len); + memcpy(newlease->options[i].data, oldlease->options[i].data, + newlease->options[i].len); + } + + return (newlease); +} diff --git a/sbin/dhclient/dhclient.conf.5 b/sbin/dhclient/dhclient.conf.5 index 980b19c7c48..e3a351db0e8 100644 --- a/sbin/dhclient/dhclient.conf.5 +++ b/sbin/dhclient/dhclient.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhclient.conf.5,v 1.24 2012/10/27 23:08:53 krw Exp $ +.\" $OpenBSD: dhclient.conf.5,v 1.25 2012/10/30 18:39:44 krw Exp $ .\" .\" Copyright (c) 1997 The Internet Software Consortium. .\" All rights reserved. @@ -36,7 +36,7 @@ .\" see ``http://www.isc.org/isc''. To learn more about Vixie .\" Enterprises, see ``http://www.vix.com''. .\" -.Dd $Mdocdate: October 27 2012 $ +.Dd $Mdocdate: October 30 2012 $ .Dt DHCLIENT.CONF 5 .Os .Sh NAME @@ -223,15 +223,7 @@ that will allow it to differentiate between this client and other clients or kinds of clients. .El .Sh OPTION MODIFIERS -Options in the lease can be modified before being passed to the client -configuration script, -.Xr dhclient-script 8 . -.Pp -The default client configuration script -processes only options 1 (subnet -mask), 3 (routers), 6 (domain name servers), and 15 (domain-name). -Use of option modifiers on other options will have no effect unless -the client configuration script is modified. +Options in the lease can be modified before being accepted. .Pp Several option modifiers are available. .Bl -tag -width Ds @@ -346,20 +338,19 @@ The IP address must be specified as a dotted quad (e.g., 12.34.56.78). The .Ic filename statement specifies the name of the boot filename to use. -This is not used by the standard client configuration script, but is -included for completeness. +This is not used by the standard client, but is included for completeness. .It Ic server-name Ar \&"string\&" ; The .Ic server-name statement specifies the name of the boot server name to use. -This is also not used by the standard client configuration script. +This is not used by the standard client, but is included for completeness. .It Ic option Ar option-declaration ; The .Ic option statement is used to specify the value of an option supplied by the server, or, in the case of predefined leases declared in .Nm dhclient.conf , -the value that the user wishes the client configuration script to use if the +the value that the user wishes the client to use if the predefined lease is used. .It Ic renew Ar date ; .It Ic rebind Ar date ; @@ -427,19 +418,6 @@ specified name. Interfaces for which there is no interface declaration will use the parameters declared outside of any interface declaration, or the default settings. -.It Ic script Ar \&"script-name\&" ; -The -.Ic script -statement is used to specify the pathname of the client configuration -script. -This script is used by the DHCP client to set each interface's initial -configuration prior to requesting an address, to test the address once it -has been offered, and to set the interface's final configuration once a -lease has been acquired. -If no lease is acquired, the script is used to test predefined leases, if -any, and also called once if no valid lease can be identified. -For more information, see -.Xr dhclient.leases 5 . .El .Sh EXAMPLES The following configuration file is used on a laptop @@ -465,7 +443,6 @@ interface "ep0" { request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name; require subnet-mask, domain-name-servers; - script "/etc/dhclient-script"; } .Ed .Pp @@ -480,7 +457,6 @@ file \- the defaults are usually fine. .Xr dhcp-options 5 , .Xr dhcpd.conf 5 , .Xr dhclient 8 , -.Xr dhclient-script 8 , .Xr dhcpd 8 .Sh STANDARDS .Rs diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 3e3450a3202..3f92d71582f 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.82 2012/10/27 23:08:53 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.83 2012/10/30 18:39:44 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -147,7 +147,6 @@ struct client_config { time_t select_interval; time_t reboot_timeout; time_t backoff_cutoff; - char *script_name; enum { IGNORE, ACCEPT, PREFER } bootp_policy; struct iaddrlist *reject_list; @@ -167,8 +166,6 @@ struct client_state { struct dhcp_packet packet; int packet_length; struct iaddr requested_address; - char **scriptEnv; - int scriptEnvsize; }; struct interface_info { @@ -190,14 +187,13 @@ struct interface_info { int rdomain; }; -struct timeout { +struct dhcp_timeout { time_t when; void (*func)(void); }; #define _PATH_DHCLIENT_CONF "/etc/dhclient.conf" #define _PATH_DHCLIENT_DB "/var/db/dhclient.leases" -#define _PATH_DHCLIENT_SCRIPT "/sbin/dhclient-script" #define DHCPD_LOG_FACILITY LOG_DAEMON /* External definitions... */ @@ -205,6 +201,9 @@ struct timeout { extern struct interface_info *ifi; extern struct client_state *client; extern struct client_config *config; +extern int privfd; +extern struct iaddr iaddr_deleting; +extern struct iaddr iaddr_adding; /* options.c */ int cons_options(struct option_data *); @@ -253,8 +252,8 @@ void got_one(void); void set_timeout(time_t, void (*)(void)); void set_timeout_interval(time_t, void (*)(void)); void cancel_timeout(void); +void interface_link_forceup(char *); int interface_status(char *); -int interface_link_forceup(char *); int get_rdomain(char *); int subnet_exists(struct client_lease *); @@ -307,22 +306,13 @@ void free_client_lease(struct client_lease *); void rewrite_client_leases(void); void write_client_lease(struct client_lease *); -void priv_script_init(char *); -void priv_script_write_params(char *, struct client_lease *); -int priv_script_go(void); - -void script_init(char *); -void script_write_params(char *, struct client_lease *); -int script_go(void); -void script_set_env(const char *, const char *, const char *); -void script_flush_env(void); -int dhcp_option_ev_name(char *, size_t, const struct option *); - struct client_lease *packet_to_lease(struct iaddr, struct option_data *); void go_daemon(void); void routehandler(void); +void priv_new_resolv_conf(char *, char *); + /* packet.c */ void assemble_hw_header(unsigned char *, int *, struct hardware *); void assemble_udp_ip_header(unsigned char *, int *, u_int32_t, u_int32_t, @@ -343,3 +333,16 @@ void parse_client_lease_declaration(FILE *, struct client_lease *); int parse_option_decl(FILE *, struct option_data *); void parse_string_list(FILE *, struct string_list **, int); void parse_reject_statement(FILE *); + +/* route.c */ +void delete_old_address (char *, int, struct iaddr); +void priv_delete_old_address (char *, int, struct iaddr); + +void add_new_address (char *, int, struct iaddr, in_addr_t *); +void priv_add_new_address (char *, int, struct iaddr, in_addr_t); + +void flush_routes_and_arp_cache(char *, int); +void priv_flush_routes_and_arp_cache(char *, int); + +void add_default_route(char *, int, struct iaddr, struct iaddr); +void priv_add_default_route(char *, int, struct iaddr, struct iaddr); diff --git a/sbin/dhclient/dhctoken.h b/sbin/dhclient/dhctoken.h index 4b27921ce35..6359bbbd14e 100644 --- a/sbin/dhclient/dhctoken.h +++ b/sbin/dhclient/dhctoken.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhctoken.h,v 1.6 2012/08/22 00:14:42 tedu Exp $ */ +/* $OpenBSD: dhctoken.h,v 1.7 2012/10/30 18:39:44 krw Exp $ */ /* Tokens for config file lexer and parser. */ @@ -59,7 +59,6 @@ #define TOK_TIMEOUT 272 #define TOK_RETRY 273 #define TOK_SELECT_TIMEOUT 274 -#define TOK_SCRIPT 275 #define TOK_INTERFACE 276 #define TOK_RENEW 277 #define TOK_REBIND 278 diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 32a28e4e6d1..12cef266123 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.59 2012/10/11 08:05:05 sthen Exp $ */ +/* $OpenBSD: dispatch.c,v 1.60 2012/10/30 18:39:44 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -47,7 +47,7 @@ #include <ifaddrs.h> #include <poll.h> -struct timeout timeout; +struct dhcp_timeout timeout; /* * Use getifaddrs() to get a list of all the attached interfaces. Find @@ -207,7 +207,7 @@ got_one(void) do_packet(result, from.sin_port, ifrom, &hfrom); } -int +void interface_link_forceup(char *ifname) { struct ifreq ifr; @@ -219,21 +219,27 @@ interface_link_forceup(char *ifname) memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) { + note("interface_link_forceup: SIOCGIFFLAGS failed (%m)"); close(sock); - return (-1); + return; } - if ((ifr.ifr_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { - ifr.ifr_flags |= IFF_UP; - if (ioctl(sock, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) { - close(sock); - return (-1); - } + /* Force it down and up so others notice link state change. */ + ifr.ifr_flags &= !IFF_UP; + if (ioctl(sock, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) { + note("interface_link_forceup: SIOCSIFFLAGS DOWN failed (%m)"); + close(sock); + return; + } + + ifr.ifr_flags |= IFF_UP; + if (ioctl(sock, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) { + note("interface_link_forceup: SIOCSIFFLAGS UP failed (%m)"); close(sock); - return (0); + return; } + close(sock); - return (1); } int @@ -320,7 +326,7 @@ int get_rdomain(char *name) { int rv = 0, s; - struct ifreq ifr; + struct ifreq ifr; if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) error("get_rdomain socket: %m"); diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c index 9f755b6ee73..0044fd3f6c5 100644 --- a/sbin/dhclient/privsep.c +++ b/sbin/dhclient/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.16 2011/04/04 11:14:52 krw Exp $ */ +/* $OpenBSD: privsep.c,v 1.17 2012/10/30 18:39:44 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -94,118 +94,290 @@ void dispatch_imsg(int fd) { struct imsg_hdr hdr; - char *reason, *filename, - *servername, *prefix; - size_t reason_len, filename_len, - servername_len, prefix_len, totlen; - struct client_lease lease; - int ret, i, optlen; - struct buf *buf; + in_addr_t *mask; + char *ifname, *contents; + size_t totlen, len; + struct iaddr *addr, *gateway; + int rdomain; buf_read(fd, &hdr, sizeof(hdr)); switch (hdr.code) { - case IMSG_SCRIPT_INIT: - if (hdr.len < sizeof(hdr) + sizeof(size_t)) - error("corrupted message received"); - buf_read(fd, &reason_len, sizeof(reason_len)); - if (hdr.len < reason_len + sizeof(hdr) + sizeof(size_t) || - reason_len == SIZE_T_MAX) - error("corrupted message received"); - if (reason_len > 0) { - if ((reason = calloc(1, reason_len + 1)) == NULL) + case IMSG_DELETE_ADDRESS: + totlen = sizeof(hdr); + ifname = NULL; + addr = NULL; + if (hdr.len < totlen + sizeof(len)) + error("IMSG_DELETE_ADDRESS missing ifname length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_DELETE_ADDRESS invalid ifname length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_DELETE_ADDRESS short ifname"); + if ((ifname = calloc(1, len + 1)) == NULL) error("%m"); - buf_read(fd, reason, reason_len); + buf_read(fd, ifname, len); + totlen += len; } else - reason = NULL; + error("IMSG_DELETE_ADDRESS ifname missing"); - priv_script_init(reason); - free(reason); + if (hdr.len < totlen + sizeof(len)) + error("IMSG_DELETE_ADDRESS missing rdomain length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_DELETE_ADDRESS invalid rdomain length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_DELETE_ADDRESS short rdomain"); + buf_read(fd, &rdomain, len); + totlen += len; + } else + error("IMSG_DELETE_ADDRESS rdomain missing"); + + if (hdr.len < totlen + sizeof(len)) + error("IMSG_DELETE_ADDRESS missing addr length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_DELETE_ADDRESS invalid addr"); + } else if (len == sizeof(*addr)) { + if ((addr = calloc(1, len)) == NULL) + error("%m"); + buf_read(fd, addr, len); + totlen += len; + } else { + error("IMSG_DELETE_ADDRESS addr missing %zu", len); + } + + priv_delete_old_address(ifname, rdomain, *addr); + free(ifname); + free(addr); break; - case IMSG_SCRIPT_WRITE_PARAMS: - bzero(&lease, sizeof lease); - totlen = sizeof(hdr) + sizeof(lease) + sizeof(size_t); - if (hdr.len < totlen) - error("corrupted message received"); - buf_read(fd, &lease, sizeof(lease)); - - buf_read(fd, &filename_len, sizeof(filename_len)); - totlen += filename_len + sizeof(size_t); - if (hdr.len < totlen || filename_len == SIZE_T_MAX) - error("corrupted message received"); - if (filename_len > 0) { - if ((filename = calloc(1, filename_len + 1)) == NULL) + + case IMSG_ADD_ADDRESS: + totlen = sizeof(hdr); + ifname = NULL; + addr = NULL; + mask = NULL; + if (hdr.len < totlen + sizeof(len)) + error("IMSG_ADD_ADDRESS missing ifname length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_ADD_ADDRESS invalid ifname length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_ADD_ADDRESS short ifname"); + if ((ifname = calloc(1, len + 1)) == NULL) error("%m"); - buf_read(fd, filename, filename_len); + buf_read(fd, ifname, len); + totlen += len; + } else + error("IMSG_ADD_ADDRESS ifname missing"); + + if (hdr.len < totlen + sizeof(len)) + error("IMSG_ADD_ADDRESS missing rdomain length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_ADD_ADDRESS invalid rdomain length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_ADD_ADDRESS short rdomain"); + buf_read(fd, &rdomain, len); + totlen += len; } else - filename = NULL; - - buf_read(fd, &servername_len, sizeof(servername_len)); - totlen += servername_len + sizeof(size_t); - if (hdr.len < totlen || servername_len == SIZE_T_MAX) - error("corrupted message received"); - if (servername_len > 0) { - if ((servername = - calloc(1, servername_len + 1)) == NULL) + error("IMSG_ADD_ADDRESS rdomain missing"); + + if (hdr.len < totlen + sizeof(len)) + error("IMSG_ADD_ADDRESS missing addr length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_ADD_ADDRESS invalid addr"); + } else if (len == sizeof(*addr)) { + if ((addr = calloc(1, len)) == NULL) + error("%m"); + buf_read(fd, addr, len); + totlen += len; + } else { + error("IMSG_ADD_ADDRESS addr missing %zu", len); + } + + if (hdr.len < totlen + sizeof(len)) + error("IMSG_ADD_ADDRESS missing mask length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + mask = NULL; + if (len == SIZE_T_MAX) { + error("IMSG_ADD_ADDRESS invalid mask"); + } else if (len == sizeof(*mask)) { + if ((mask = calloc(1, len)) == NULL) + error("%m"); + buf_read(fd, mask, len); + totlen += len; + } else { + error("IMSG_ADD_ADDRESS mask missing %zu", len); + } + + priv_add_new_address(ifname, rdomain, *addr, *mask); + free(ifname); + free(addr); + free(mask); + break; + + case IMSG_FLUSH_ROUTES: + totlen = sizeof(hdr); + ifname = NULL; + addr = NULL; + if (hdr.len < totlen + sizeof(len)) + error("IMSG_FLUSH_ROUTES missing ifname length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_FLUSH_ROUTES invalid ifname length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_FLUSH_ROUTES short ifname"); + if ((ifname = calloc(1, len + 1)) == NULL) error("%m"); - buf_read(fd, servername, servername_len); + buf_read(fd, ifname, len); + totlen += len; } else - servername = NULL; - - buf_read(fd, &prefix_len, sizeof(prefix_len)); - totlen += prefix_len; - if (hdr.len < totlen || prefix_len == SIZE_T_MAX) - error("corrupted message received"); - if (prefix_len > 0) { - if ((prefix = calloc(1, prefix_len + 1)) == NULL) + error("IMSG_FLUSH_ROUTES ifname missing"); + + if (hdr.len < totlen + sizeof(len)) + error("IMSG_FLUSH_ROUTES missing rdomain length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_FLUSH_ROUTES invalid rdomain length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_FLUSH_ROUTES short rdomain"); + buf_read(fd, &rdomain, len); + totlen += len; + } else + error("IMSG_FLUSH_ROUTES rdomain missing"); + + priv_flush_routes_and_arp_cache(ifname, rdomain); + free(ifname); + break; + + case IMSG_ADD_DEFAULT_ROUTE: + totlen = sizeof(hdr); + ifname = NULL; + addr = NULL; + if (hdr.len < totlen + sizeof(len)) + error("IMSG_ADD_DEFAULT_ROUTE missing ifname length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_ADD_DEFAULT_ROUTE invalid ifname length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_ADD_DEFAULT_ROUTE short ifname"); + if ((ifname = calloc(1, len + 1)) == NULL) error("%m"); - buf_read(fd, prefix, prefix_len); + buf_read(fd, ifname, len); + totlen += len; } else - prefix = NULL; - - for (i = 0; i < 256; i++) { - totlen += sizeof(optlen); - if (hdr.len < totlen) - error("corrupted message received"); - buf_read(fd, &optlen, sizeof(optlen)); - lease.options[i].data = NULL; - lease.options[i].len = optlen; - if (optlen > 0) { - totlen += optlen; - if (hdr.len < totlen || optlen == SIZE_T_MAX) - error("corrupted message received"); - lease.options[i].data = - calloc(1, optlen + 1); - if (lease.options[i].data == NULL) - error("%m"); - buf_read(fd, lease.options[i].data, optlen); - } + error("IMSG_ADD_DEFAULT_ROUTE ifname missing"); + + if (hdr.len < totlen + sizeof(len)) + error("IMSG_ADD_DEFAULT_ROUTE missing rdomain length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_ADD_DEFAULT_ROUTE invalid rdomain length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_FLUSH_ROUTES short rdomain"); + buf_read(fd, &rdomain, len); + totlen += len; + } else + error("IMSG_ADD_DEFAULT_ROUTE rdomain missing"); + + if (hdr.len < totlen + sizeof(len)) + error("IMSG_ADD_DEFAULT_ROUTE missing addr length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_ADD_DEFAULT_ROUTE invalid addr"); + } else if (len == sizeof(*addr)) { + if ((addr = calloc(1, len)) == NULL) + error("%m"); + buf_read(fd, addr, len); + totlen += len; + } else { + error("IMSG_ADD_DEFAULT_ROUTE addr missing %zu", + len); } - lease.server_name = servername; - lease.filename = filename; - priv_script_write_params(prefix, &lease); + if (hdr.len < totlen + sizeof(len)) + error("IMSG_ADD_DEFAULT_ROUTE missing gateway length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + gateway = NULL; + if (len == SIZE_T_MAX) { + error("IMSG_ADD_DEFAULT_ROUTE invalid gateway"); + } else if (len == sizeof(*gateway)) { + if ((gateway = calloc(1, len)) == NULL) + error("%m"); + buf_read(fd, gateway, len); + totlen += len; + } else { + error("IMSG_ADD_DEFAULT_ROUTE gateway missing %zu", + len); + } - free(servername); - free(filename); - free(prefix); - for (i = 0; i < 256; i++) - if (lease.options[i].len > 0) - free(lease.options[i].data); + priv_add_default_route(ifname, rdomain, *addr, *gateway); + free(ifname); + free(addr); + free(gateway); break; - case IMSG_SCRIPT_GO: - if (hdr.len != sizeof(hdr)) - error("corrupted message received"); - - ret = priv_script_go(); - - hdr.code = IMSG_SCRIPT_GO_RET; - hdr.len = sizeof(struct imsg_hdr) + sizeof(int); - if ((buf = buf_open(hdr.len)) == NULL) - error("buf_open: %m"); - buf_add(buf, &hdr, sizeof(hdr)); - buf_add(buf, &ret, sizeof(ret)); - buf_close(fd, buf); + case IMSG_NEW_RESOLV_CONF: + totlen = sizeof(hdr); + ifname = NULL; + contents = NULL; + if (hdr.len < totlen + sizeof(len)) + error("IMSG_NEW_RESOLV_CONF missing ifname length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_NEW_RESOLV_CONF invalid ifname length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_NEW_RESOLV_CONF short ifname"); + if ((ifname = calloc(1, len + 1)) == NULL) + error("%m"); + buf_read(fd, ifname, len); + totlen += len; + } else + error("IMSG_NEW_RESOLV_CONF ifname missing"); + + if (hdr.len < totlen + sizeof(len)) + error("IMSG_NEW_RESOLV_CONF missing contents length"); + buf_read(fd, &len, sizeof(len)); + totlen += sizeof(len); + if (len == SIZE_T_MAX) { + error("IMSG_NEW_RESOLV_CONF invalid contents length"); + } else if (len > 0) { + if (hdr.len < totlen + len) + error("IMSG_NEW_RESOLV_CONF short contents"); + if ((contents = calloc(1, len + 1)) == NULL) + error("%m"); + buf_read(fd, contents, len); + totlen += len; + } else + error("IMSG_NEW_RESOLV_CONF contents missing"); + + priv_new_resolv_conf(ifname, contents); + free(ifname); + free(contents); break; default: error("received unknown message, code %d", hdr.code); diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h index b81a37db666..59300e00f53 100644 --- a/sbin/dhclient/privsep.h +++ b/sbin/dhclient/privsep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.h,v 1.5 2007/02/13 21:54:22 stevesk Exp $ */ +/* $OpenBSD: privsep.h,v 1.6 2012/10/30 18:39:44 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -27,10 +27,11 @@ struct buf { enum imsg_code { IMSG_NONE, - IMSG_SCRIPT_INIT, - IMSG_SCRIPT_WRITE_PARAMS, - IMSG_SCRIPT_GO, - IMSG_SCRIPT_GO_RET + IMSG_DELETE_ADDRESS, + IMSG_ADD_ADDRESS, + IMSG_FLUSH_ROUTES, + IMSG_ADD_DEFAULT_ROUTE, + IMSG_NEW_RESOLV_CONF }; struct imsg_hdr { diff --git a/share/man/man5/resolv.conf.5 b/share/man/man5/resolv.conf.5 index 367e73990f2..da340c4f371 100644 --- a/share/man/man5/resolv.conf.5 +++ b/share/man/man5/resolv.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: resolv.conf.5,v 1.37 2012/10/05 06:25:13 jmc Exp $ +.\" $OpenBSD: resolv.conf.5,v 1.38 2012/10/30 18:39:44 krw Exp $ .\" $NetBSD: resolv.conf.5,v 1.7 1996/03/06 18:22:16 scottr Exp $ .\" .\" Copyright (c) 1986, 1991 The Regents of the University of California. @@ -30,7 +30,7 @@ .\" .\" @(#)resolver.5 5.12 (Berkeley) 5/10/91 .\" -.Dd $Mdocdate: October 5 2012 $ +.Dd $Mdocdate: October 30 2012 $ .Dt RESOLV.CONF 5 .Os .Sh NAME @@ -63,9 +63,7 @@ or if any DNS nameservers are configured. .Pp If .Xr dhclient 8 -is used to configure the network, -the DHCP client back-end -.Xr dhclient-script 8 +is used to configure the network it will normally overwrite the .Nm resolv.conf file with updated information such as nameserver addresses, @@ -78,7 +76,7 @@ may be created manually. This file will be appended to the generated .Nm resolv.conf file by -.Xr dhclient-script 8 , +.Xr dhclient 8 , ensuring options remain. .Pp On a machine whose network connection does not change frequently (such as a desktop @@ -324,7 +322,6 @@ file. .Xr resolver 3 , .Xr hosts 5 , .Xr hostname 7 , -.Xr dhclient-script 8 , .Xr dhcp 8 , .Xr named 8 .Sh HISTORY diff --git a/share/man/man8/afterboot.8 b/share/man/man8/afterboot.8 index 7bff8ef8a6f..e0dc78ba912 100644 --- a/share/man/man8/afterboot.8 +++ b/share/man/man8/afterboot.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: afterboot.8,v 1.139 2012/08/18 16:25:20 jmc Exp $ +.\" $OpenBSD: afterboot.8,v 1.140 2012/10/30 18:39:44 krw Exp $ .\" .\" Copyright (c) 1997 Marshall M. Midden .\" All rights reserved. @@ -29,7 +29,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: August 18 2012 $ +.Dd $Mdocdate: October 30 2012 $ .Dt AFTERBOOT 8 .\" Originally created by Marshall M. Midden -- 1997-10-20, m4@umn.edu .Os @@ -275,7 +275,7 @@ while installing the system. If DHCP is in use, it will overwrite .Pa /etc/resolv.conf every time -.Xr dhclient-script 8 +.Xr dhclient 8 is run but .Pa /etc/resolv.conf.tail can be used to add options and extra name servers to those received diff --git a/usr.bin/spell/special.4bsd b/usr.bin/spell/special.4bsd index 8703c615d44..abd05e71a13 100644 --- a/usr.bin/spell/special.4bsd +++ b/usr.bin/spell/special.4bsd @@ -221,7 +221,6 @@ dffrac dflmax dflmin dhclient -dhclient-script dhcpd dhcrelay diction |