Your message dated Tue, 11 Sep 2012 16:51:37 -0400
with message-id <[email protected]>
and subject line Wrong package
has caused the Debian Bug report #687336,
regarding dhclient-script change to wait for /etc/resolv.conf to be writable
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
687336: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=687336
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: src:bridge-utils

Hey there,

A while ago (not sure why it wasn't forwarded earlier), Ubuntu
implemented an extra check in dhclient-script to wait until
/etc/resolv.conf is writable.

I believe this should equally apply to Debian and would reduce our delta
on that file to pretty much nothing (just some apparmor bits)

I just re-updated our patch to work on the current isc-dhcp. Please note
that this patch hasn't been widely tested as recent versions of Ubuntu
now use resolvconf instead of dhclient-script to generate resolv.conf.

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
=== modified file 'debian/dhclient-script.linux'
--- debian/dhclient-script.linux	2012-09-05 08:59:49 +0000
+++ debian/dhclient-script.linux	2012-09-11 20:37:39 +0000
@@ -24,6 +24,30 @@
 
 # The alias handling in here probably still sucks. -mdz
 
+# wait for given file to be writable
+wait_for_rw() {
+    local file=$1
+    # Find out whether we are going to mount / rw
+    exec 9>&0 </etc/fstab
+    rootmode=rw
+    while read dev mnt type opts dump pass junk; do
+        [ "$mnt" != / ] && continue
+        case "$opts" in
+            ro|ro,*|*,ro|*,ro,*)
+               rootmode=ro
+               ;;
+             esac
+     done
+     exec 0>&9 9>&-
+
+    # Wait for $file to become writable
+    if [ "$rootmode" = "rw" ]; then
+        while ! { : >> "$file"; } 2>/dev/null; do
+            sleep 0.1
+        done
+    fi
+}
+
 # update /etc/resolv.conf based on received values
 make_resolv_conf() {
     local new_resolv_conf
@@ -31,7 +55,11 @@
     # DHCPv4
     if [ -n "$new_domain_search" ] || [ -n "$new_domain_name" ] ||
        [ -n "$new_domain_name_servers" ]; then
-        new_resolv_conf=/etc/resolv.conf.dhclient-new
+        resolv_conf=$(readlink -f "/etc/resolv.conf" 2>/dev/null) ||
+            resolv_conf="/etc/resolv.conf"
+
+        new_resolv_conf="${resolv_conf}.dhclient-new.$$"
+        wait_for_rw "$new_resolv_conf"
         rm -f $new_resolv_conf
 
         if [ -n "$new_domain_name" ]; then
@@ -61,17 +89,21 @@
                 echo nameserver $nameserver >>$new_resolv_conf
             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 $resolv_conf >>$new_resolv_conf
         fi
 
-	if [ -f /etc/resolv.conf ]; then
-	    chown --reference=/etc/resolv.conf $new_resolv_conf
-	    chmod --reference=/etc/resolv.conf $new_resolv_conf
+	if [ -f $resolv_conf ]; then
+	    chown --reference=$resolv_conf $new_resolv_conf
+	    chmod --reference=$resolv_conf $new_resolv_conf
 	fi
-        mv -f $new_resolv_conf /etc/resolv.conf
+        mv -f $new_resolv_conf $resolv_conf
     # DHCPv6
     elif [ -n "$new_dhcp6_domain_search" ] || [ -n "$new_dhcp6_name_servers" ]; then
-        new_resolv_conf=/etc/resolv.conf.dhclient-new
+        resolv_conf=$(readlink -f "/etc/resolv.conf" 2>/dev/null) ||
+            resolv_conf="/etc/resolv.conf"
+
+        new_resolv_conf="${resolv_conf}.dhclient-new.$$"
+        wait_for_rw "$new_resolv_conf"
         rm -f $new_resolv_conf
 
         if [ -n "$new_dhcp6_domain_search" ]; then
@@ -88,14 +120,14 @@
                 echo nameserver $nameserver >>$new_resolv_conf
             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 $resolv_conf >>$new_resolv_conf
         fi
 
-	if [ -f /etc/resolv.conf ]; then
-            chown --reference=/etc/resolv.conf $new_resolv_conf
-            chmod --reference=/etc/resolv.conf $new_resolv_conf
+	if [ -f $resolv_conf ]; then
+            chown --reference=$resolv_conf $new_resolv_conf
+            chmod --reference=$resolv_conf $new_resolv_conf
 	fi
-        mv -f $new_resolv_conf /etc/resolv.conf
+        mv -f $new_resolv_conf $resolv_conf
     fi
 }
 

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
Sorry for that, I noticed while sending the e-mail that this went to the
wrong source and thought I canceled it early enough...


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

Reply via email to