> Following the track of the problem I think the culprit is the script
> /sbin/dhclient-script, exactly the function make_resolv_conf().

Indeed, dhclient-script plainly overwrites any configuration already
arranged in /etc/resolv.conf. This makes it hard to integrate it with
other concurrent daemons and systems like resolvconf.

We are about to release an RDNSS dameon as part of the ndisc6 package,
which adds IPv6 DNS resolvers to /etc/resolv.conf. In the same way,
to coexist nicely with dhclient, it requires DNS configuration from
different sources to be merged into /etc/resolv.conf, instead of
directly overwriting it.

This patch allows the use of an external merge hook in
make_resolv_conf(), for this purpose. Please consider.

--- debian/dhclient-script.linux        2007-12-15 12:26:41.000000000 +0100
+++ debian/dhclient-script.linux        2007-12-15 13:47:04.000000000 +0100
@@ -8,27 +8,55 @@
 # being mounted, which causes cosmetic errors on hosts that NFS mount /usr
 # Andrew Pollock, February 2005
 # Modified to work on point-to-point links. Andrew Pollock, June 2005
-# Modified to support passing the parameters called with to the hooks. Andrew 
Pollock, November 2005
+# Modified to support passing the parameters called with to the hooks.
+# Andrew Pollock, November 2005
+# Modified to allow the use of an external script to write /etc/resolv.conf
+# Pierre Ynard, December 2007
 
 # The alias handling in here probably still sucks. -mdz
 
+resolv_conf_hook=""
+
 make_resolv_conf() {
     if [ -n "$new_domain_name" -o -n "$new_domain_name_servers" ]; then
-        local new_resolv_conf=/etc/resolv.conf.dhclient-new
-        rm -f $new_resolv_conf
+        if ! [ -d /var/run/dhclient ]; then
+            mkdir -p /var/run/dhclient
+        fi
+        local my_resolv_conf=/var/run/dhclient/resolv.conf.$interface
+        rm -f $my_resolv_conf-new
         if [ -n "$new_domain_name" ]; then
-            echo search $new_domain_name >>$new_resolv_conf
+            echo search $new_domain_name >>$my_resolv_conf-new
         fi
         if [ -n "$new_domain_name_servers" ]; then
-                   for nameserver in $new_domain_name_servers; do
-                       echo nameserver $nameserver >>$new_resolv_conf
+            for nameserver in $new_domain_name_servers; do
+                echo nameserver $nameserver >>$my_resolv_conf-new
             done
         else # keep 'old' nameservers
-            sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p 
/etc/resolv.conf >>$new_resolv_conf
+            sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p 
$my_resolv_conf >>$my_resolv_conf-new
+        fi
+        mv -f $my_resolv_conf-new $my_resolv_conf
+
+        if [ -n "$resolv_conf_hook" ]; then
+            if [ -x "$resolv_conf_hook" ]; then
+                local exit_status
+
+                $resolv_conf_hook # run the external hook
+
+                exit_status=$?
+                if [ "$exit_status" -ne 0 ]; then
+                    logger -p daemon.err "$resolv_conf_hook returned non-zero 
exit status $exit_status"
+                    save_exit_status=$exit_status
+                fi
+            else
+                logger -p daemon.err "cannot run resolv.conf hook 
$resolv_conf_hook!"
+            fi
+        else
+            local tmp_resolv_conf=/etc/resolv.conf.dhclient-new
+            cp -f $my_resolv_conf $tmp_resolv_conf
+            chown --reference=/etc/resolv.conf $tmp_resolv_conf
+            chmod --reference=/etc/resolv.conf $tmp_resolv_conf
+            mv -f $tmp_resolv_conf /etc/resolv.conf
         fi
-        chown --reference=/etc/resolv.conf $new_resolv_conf
-        chmod --reference=/etc/resolv.conf $new_resolv_conf
-        mv -f $new_resolv_conf /etc/resolv.conf
     fi
 }
 

Regards,

-- 
Pierre Ynard
For hire - http://www.linkfanel.net/resume.pdf
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."


Reply via email to