Re: [CFR] reflect resolv.conf update to running application

From: Brooks Davis (brooks_at_one-eyed-alien.net)
Date: 09/08/05

  • Next message: Jung-uk Kim: "Bigger boot block size?"
    Date: Thu, 8 Sep 2005 11:10:52 -0700
    To: "Matthew N. Dodd" <mdodd@FreeBSD.ORG>
    
    
    

    On Sun, Aug 28, 2005 at 02:25:05AM -0400, Matthew N. Dodd wrote:
    > On Sat, 27 Aug 2005, Brooks Davis wrote:
    > >I'd like to see dhclient-script pull in /etc/rc.conf.
    >
    > Attached.

    I've looked this over and while I like the concept, I think the
    implementation could be improved. First, it looks like named.conf has
    an include directive what is conveniently undocumented in the manpage,
    but in the BIND 9 Administrator Reference Manual at:

    http://www.bind9.net/manual/bind/9.3.1/Bv9ARM.ch06.html#AEN1534

    so if it actually works, we should use that instead of rebuiling the
    config file each time. Second, the forwarders file should default to
    living in the /var/run of the named chroot since we default to chrooted
    operation these day. Third, I think we need to kick the server with
    "rndc reconfig" once the file is updated.

    Thanks,
    Brooks

    > --
    > 10 40 80 C0 00 FF FF FF FF C0 00 00 00 00 10 AA AA 03 00 00 00 08 00

    > Index: sbin/dhclient/dhclient-script
    > ===================================================================
    > RCS file: /home/cvs/src/sbin/dhclient/dhclient-script,v
    > retrieving revision 1.8
    > diff -u -u -r1.8 dhclient-script
    > --- sbin/dhclient/dhclient-script 26 Aug 2005 20:31:04 -0000 1.8
    > +++ sbin/dhclient/dhclient-script 28 Aug 2005 06:02:16 -0000
    > @@ -19,6 +19,9 @@
    > #
    > #
    >
    > +. /etc/rc.subr
    > +load_rc_config dhclient-script
    > +
    > NETSTAT=/usr/bin/netstat
    > AWK=/usr/bin/awk
    > HOSTNAME=/bin/hostname
    > @@ -127,6 +130,23 @@
    > fi
    > }
    >
    > +make_named_forwarders() {
    > + if [ -z "$new_domain_name_servers" ]; then
    > + return 1
    > + fi
    > +
    > + rm -f /var/run/named.forwarders
    > + echo " forwarders {" > /var/run/named.forwarders
    > + for nameserver in $new_domain_name_servers; do
    > + echo " $nameserver;" >> /var/run/named.forwarders
    > + done
    > + echo " };" >> /var/run/named.forwarders
    > +
    > + cd /etc/namedb && make -f make-named.conf
    > +
    > + return 0
    > +}
    > +
    > add_new_resolv_conf() {
    > # XXX Old code did not create/update resolv.conf unless both
    > # $new_domain_name and $new_domain_name_servers were provided. PR
    > @@ -238,7 +258,12 @@
    > if [ "$new_ip_address" != "$alias_ip_address" ]; then
    > add_new_alias
    > fi
    > - add_new_resolv_conf
    > + if checkyesno dhclient_script_resolv_conf; then
    > + add_new_resolv_conf
    > + fi
    > + if checkyesno dhclient_script_named_forwarders; then
    > + make_named_forwarders
    > + fi
    > ;;
    >
    > EXPIRE|FAIL)
    > @@ -266,8 +291,13 @@
    > add_new_alias
    > fi
    > add_new_routes
    > - if add_new_resolv_conf; then
    > - exit_with_hooks 0
    > + if checkyesno dhclient_script_named_forwarders; then
    > + make_named_forwarders
    > + fi
    > + if checkyesno dhclient_script_resolv_conf; then
    > + if add_new_resolv_conf; then
    > + exit_with_hooks 0
    > + fi
    > fi
    > fi
    > fi
    > Index: etc/defaults/rc.conf
    > ===================================================================
    > RCS file: /home/cvs/src/etc/defaults/rc.conf,v
    > retrieving revision 1.259
    > diff -u -u -r1.259 rc.conf
    > --- etc/defaults/rc.conf 24 Aug 2005 16:25:47 -0000 1.259
    > +++ etc/defaults/rc.conf 28 Aug 2005 05:46:18 -0000
    > @@ -93,6 +93,9 @@
    > nisdomainname="NO" # Set to NIS domain if using NIS (or NO).
    > dhclient_program="/sbin/dhclient" # Path to dhcp client program.
    > dhclient_flags="" # Additional flags to pass to dhcp client.
    > +dhclient_script_resolv_conf="YES" # Update /etc/resolv.conf
    > +dhclient_script_named_forwarders="NO" # Update /var/run/named.forwarders and
    > + # rebuild /etc/namedb/named.conf
    > background_dhclient="NO" # Start dhcp client in the background.
    > firewall_enable="NO" # Set to YES to enable firewall functionality
    > firewall_script="/etc/rc.firewall" # Which script to run to set up the firewall
    > Index: etc/namedb/Makefile
    > ===================================================================
    > RCS file: /home/cvs/src/etc/namedb/Makefile,v
    > retrieving revision 1.4
    > diff -u -u -r1.4 Makefile
    > --- etc/namedb/Makefile 21 Dec 2004 08:46:50 -0000 1.4
    > +++ etc/namedb/Makefile 28 Aug 2005 06:14:50 -0000
    > @@ -1,7 +1,7 @@
    > -# $FreeBSD$
    > +# $FreeBSD: src/etc/namedb/Makefile,v 1.4 2004/12/21 08:46:50 ru Exp $
    >
    > FILES= PROTO.localhost.rev PROTO.localhost-v6.rev named.conf named.root \
    > - make-localhost
    > + make-localhost make-named.conf
    > NO_OBJ=
    > FILESDIR= /etc/namedb
    > FILESMODE= 644
    > Index: etc/namedb/make-named.conf
    > ===================================================================
    > RCS file: etc/namedb/make-named.conf
    > diff -N etc/namedb/make-named.conf
    > --- /dev/null 1 Jan 1970 00:00:00 -0000
    > +++ etc/namedb/make-named.conf 28 Aug 2005 05:59:12 -0000
    > @@ -0,0 +1,17 @@
    > +# $FreeBSD$
    > +#
    > +
    > +#
    > +# Move /etc/named.conf to /etc/named.conf.in and add the following
    > +# lines to the options section.
    > +#
    > +# forward only;
    > +# #include "/var/run/named.forwarders"
    > +#
    > +
    > +named.conf: named.conf.in /var/run/named.forwarders
    > + cpp -P -C named.conf.in > $@
    > + /etc/rc.d/named restart
    > +
    > +/var/run/named.forwarders:
    > + @touch /var/run/named.forwarders

    -- 
    Any statement of the form "X is the one, true Y" is FALSE.
    PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
    
    



  • Next message: Jung-uk Kim: "Bigger boot block size?"