Package: nss-mdns
Version: 0.8-6
Severity: wishlist
Tags: patch

        Hi,

 Please merge the diff from the 0.8-6.1 NMU I just uploaded.  I'll
 comment in the RC bug I'm closing in an hour or so to explain a
 limitation in the NMU I did which I believe should be addressed in
 avahi-daemon.

   Bye,

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-3-686
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)

-- 
Loïc Minier <[EMAIL PROTECTED]>
 "Forget your stupid theme park! I'm gonna make my own! With hookers!
  And blackjack! In fact, forget the theme park!"          -- Bender
--- nss-mdns-0.8/debian/control
+++ nss-mdns-0.8/debian/control
@@ -7,8 +7,8 @@
 
 Package: libnss-mdns
 Section: admin
-Recommends: zeroconf
-Suggests: avahi-daemon
+Depends: perl, avahi-daemon
+Suggests: avahi-autoipd | zeroconf
 Architecture: any
 Depends: ${shlibs:Depends}, base-files (>= 3.1.10)
 Description: NSS module for Multicast DNS name resolution
--- nss-mdns-0.8/debian/rules
+++ nss-mdns-0.8/debian/rules
@@ -27,7 +27,7 @@
 config.status: configure
 	dh_testdir
 	# Add here commands to configure the package.
-	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --libexecdir=\${prefix}/lib/nss-mdns CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
+	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --libexecdir=\${prefix}/lib/nss-mdns CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" --disable-legacy
 
 
 build: build-stamp
--- nss-mdns-0.8/debian/changelog
+++ nss-mdns-0.8/debian/changelog
@@ -1,3 +1,41 @@
+nss-mdns (0.8-6.1) unstable; urgency=low
+
+  * Non-maintainer upload to fix a long-standing RC bug and to beat the
+    package into shape before etch with suggestions from upstream; thanks
+    Lennart Poettering.
+  * Configure with --disable-legacy, as recommended by upstream for security
+    reasons; the legacy mode might be offered in a separate binary package for
+    the corner cases where it can be useful; see full discussion in #393711;
+    depend on avahi-daemon as nss-mdns will not work without avahi when
+    compiled like this; closes: #399297.
+  * Only suggest zeroconf instead of Recommending it: even if it can act as a
+    nice complement to nss-mdns, it is intrusive and orthogonal to nss-mdns
+    and conflicts with avahi-autoipd; closes: #353131, #392590.
+  * Suggest avahi-autoipd as an alternative to zeroconf.
+  * Remove offensive comments in postinst and README.Debian.
+  * Document the history of postinst snippets in debian/NOTES.Debian to permit
+    handling all upgrade paths.
+  * Depend on Perl for the postinst snippets using the perl interpreter.
+  * Rewrite postinst to handle all upgrade paths.
+    - Does not wipe NSS configuration which matches the upstream recommended
+      configuration during upgrades from versions 0.8-4.2 or 0.8-5;
+      closes: #393608.
+    - Install the upstream recommended configuration for first installs and
+      upgrades from versions which did not automatically insert mdns in the
+      NSS setup (unless mdns is already setup); closes: #393711.
+    - Keep configuration intact when upgrading from versions which installed
+      the upstream recommended configuration.
+    - Remove whitespaces added in upgrades from version 0.8-4.2 or 0.8-5 to
+      0.8-6.
+    - For upgrades from 0.8-6, attempt to revert the problematic "mdns_minimal
+      dns mdns" configuration and to install the upstream recommended
+      configuration.
+  * Update README.Debian to match the above changes and a planned changes in
+    avahi-daemon which should disable itself if a .local SOA is found after a
+    change in the DNS settings.
+
+ -- Loic Minier <[EMAIL PROTECTED]>  Sun, 24 Dec 2006 20:27:30 +0100
+
 nss-mdns (0.8-6) unstable; urgency=medium
 
   * Revert hostile package takeover.
--- nss-mdns-0.8/debian/postinst
+++ nss-mdns-0.8/debian/postinst
@@ -4,47 +4,82 @@
 
-if [ "$1" = configure ] && [ -e /etc/nsswitch.conf ]; then
-	if [ -z "$2" ] || dpkg --compare-versions "$2" ge 0.8-6; then
-		perl -i -pe '
-			sub insert {
-				my @bits=split(" ", shift);
-				if (grep { $_ eq "mdns4_minimal" || $_ eq "mdns4"
-					|| $_ eq "mdns" || $_ eq "mdns_minimal"
-					|| $_ eq "mdns6" || $_ eq "mdns6_minimal"} @bits) {
-					return join " ", @bits;
-				}
-				return join " ", map {
-					$_ eq "dns" ? ("mdns_minimal",$_,"mdns") : $_
-				} @bits;
-			}
-			s/^(hosts:\s+)(.*)/$1.insert($2)/e;
-		' /etc/nsswitch.conf
-	fi
-	if [ -z "$2" ] || dpkg --compare-versions "$2" eq 0.8-5; then
-	# Undo the SjoerdHess damage
-		perl -i -pe '
-			s/^(hosts:\s+)(.*)mdns4_minimal \[NOTFOUND=return\](.*dns.*)mdns4(.*)/$1$2$3$4/;
-		' /etc/nsswitch.conf
-	fi
-	if [ -z "$2" ] || dpkg --compare-versions "$2" eq 0.8-4.2; then
-	# Undo the SjoerdHess damage
-		perl -i -pe '
-			s/^(hosts:\s+)(.*)mdns4_minimal \[NOTFOUND=return\](.*dns.*)mdns4(.*)/$1$2$3$4/;
-		' /etc/nsswitch.conf
-	fi
-	if [ -z "$2" ] || dpkg --compare-versions "$2" le 0.8-4.1; then
-		perl -i -pe '
-			sub insert {
-				my @bits=split(" ", shift);
-				if (grep { $_ eq "mdns4_minimal" || $_ eq "mdns4"
-					|| $_ eq "mdns" || $_ eq "mdns_minimal"
-					|| $_ eq "mdns6" || $_ eq "mdns6_minimal"} @bits) {
-					return join " ", @bits;
-				}
-				return join " ", map {
-					$_ eq "dns" ? ("mdns_minimal",$_,"mdns") : $_
-				} @bits;
-			}
-			s/^(hosts:\s+)(.*)/$1.insert($2)/e;
-		' /etc/nsswitch.conf
-	fi
+log() {
+    echo "$*"
+}
+
+# try to insert mdns entries to the "hosts" line in /etc/nsswitch.conf to
+# automatically enable nss-mdns support; do not change the configuration if the
+# "hosts" line already references some mdns lookups
+insert_mdns() {
+    log "Checking NSS setup..."
+    # abort if /etc/nsswitch.conf does not exist
+    if ! [ -e /etc/nsswitch.conf ]; then
+        log "Could not find /etc/nsswitch.conf."
+        return
+    fi
+    perl -i -pe '
+        sub insert {
+            # this also splits on tab
+            my @bits=split(" ", shift);
+            # do not break configuration if the "hosts" line already references
+            # mdns
+            if (grep { $_ eq "mdns4_minimal" || $_ eq "mdns4"
+                || $_ eq "mdns" || $_ eq "mdns_minimal" 
+                || $_ eq "mdns6" || $_ eq "mdns6_minimal"} @bits) {
+                return join " ", @bits;
+            }
+            # change "dns" into "mdns4_minimal [NOTFOUND=return] dns mdns4"
+            return join " ", map {
+                $_ eq "dns" ? ("mdns4_minimal","[NOTFOUND=return]",$_,"mdns4") : $_
+            } @bits;
+        }
+        s/^(hosts:\s+)(.*)/$1.insert($2)/e;
+    ' /etc/nsswitch.conf
+}
+
+action="$1"
+
+if [ configure = "$action" ]; then
+    if [ -z "$2" ]; then
+        log "First installation detected..."
+        # first install: setup the recommended configuration (unless
+        # nsswitch.conf already contains mdns entries)
+        insert_mdns
+    else
+        # upgrade
+        version="$2"
+
+        if dpkg --compare-versions "$version" lt 0.8-4.2; then
+            log "Upgrade from unconfigured version detected."
+            # versions prior to 0.8-4.2 did not setup nss-mdns automatically,
+            # do it now
+            insert_mdns
+        elif dpkg --compare-versions "$version" lt 0.8-6; then
+            log "Already configured version detected, skipping NSS setup."
+            # versions 0.8-4.2 and 0.8-5 installed the same configuration as
+            # this postinst, so nothing needs to be done
+            :
+        elif dpkg --compare-versions "$version" lt 0.8-6.1; then
+            log "Upgrade from possibly broken version detected."
+            if [ -e /etc/nsswitch.conf ]; then
+                # version 0.8-6 broke the configuration in multiple ways: 1)
+                # for systems which were upgraded from 0.8-4.2 or 0.8-5 to
+                # 0.8-6, the hosts line will look like:
+                #    hosts:          files  dns 
+                # cleanup from this specially formatted line into the default
+                # one:
+                sed -i \
+                    's/^hosts:          files  dns $/hosts:          files dns/' \
+                    /etc/nsswitch.conf
+                # 2) for systems which re-installed 0.8-6 or installed 0.8-6 as the
+                # first version, the hosts line will look like:
+                #    hosts:          files mdns_minimal dns mdns
+                # cleanup from this specially formatted line into the default one:
+                sed -i -r \
+                    '/^hosts:/s/\<mdns_minimal dns mdns\>/dns/' \
+                    /etc/nsswitch.conf
+            fi
+
+            insert_mdns
+        fi
+    fi
 fi
--- nss-mdns-0.8/debian/README.Debian
+++ nss-mdns-0.8/debian/README.Debian
@@ -1,53 +1,29 @@
-
 MODIFYING /etc/nsswitch.conf
 ----------------------------
 
 Previously the base-files package shipped /etc/nsswitch.conf and specified:
 
-hosts:          files dns mdns
+    hosts:          files dns mdns
 
 However, due to bug#351990, this is no longer the case. /etc/nsswitch.conf
-is now generated post-installation. Upon installation, if the strings 'mdns',
-'mdns_minimal', 'mdns4', 'mdns4_minimal', 'mdns6' and 'mdns6_minimal' do NOT
-appear on the hosts line, your /etc/nsswitch.conf file will be updated
-
-This means that, /etc/nsswitch.conf will be set to:
-
-hosts:	files mdns_minimal dns mdns
-
-Note: this is never removed once installed, the side-effect of not removing
-the entry is that there is a slight delay (similiar to how the Standard C
-libraries searches for optimised versions) during program startup and execution
-
-WHAT ABOUT UPSTREAM?
---------------------
-
-Upstream recommends a slightly different line, which make mDNS authoriative
-for both the .local, 169.254.0.0/16 and fe80::/16 zones. This means that
-local administrators do not have the opportunity to insert entries into
-any of those zones (unlikely but possible).
-
-Additionally, using the recommended upstream line can cause interaction
-issues with incorrectly configured installations (not surprisingly
-many "enterprises" use .local for their internal servers).
-
-Debian takes the most conservative approach to ensure that your installation
-continues to function correctly. However that may mean slightly longer delays
-(sometimes as long as 10 seconds) when things do not work properly.
-
-WHAT ABOUT IPv6?
-----------------
-
-mDNS (multicast DNS) has been widely deployed within the Apple
-community (since Mac OS X 10.1) and by many printer manufacturers.
-
-Initially the mDNS entries only contained IPv4 addresses (A records),
-however, since Mac OS X 10.3 onwards, mDNS entries have also been
-populated with IPv6 addresses (AAAA records).
-
-Therefore Debian, once again, differs from upstream by recommending
-an entry which looks up addresses via both IPv4 and IPv6.
-
--- Anand Kumria <[EMAIL PROTECTED]>, Sun, 2 Jul 2006 21:36:18 +1000
+is now generated post-installation. Upon installation of nss-mdns, if the
+strings 'mdns', 'mdns_minimal', 'mdns4', 'mdns4_minimal', 'mdns6' or
+'mdns6_minimal' appear on the hosts line, your /etc/nsswitch.conf file
+will not be updated, otherwise it will updated to match the upstream
+recommended configuration which usually looks like:
+
+    hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
+
+This is currently not removed on removal or purge of nss-mdns.
+
+
+.local domains
+--------------
+
+Making nss-mdns authoritative for .local breaks resolution on networks
+where .local is a real domain name.  To workaround this, avahi-daemon
+should be restarted when the DNS settings change (for example via
+resolvconf and dhclient hooks) and disable itself when a SOA for the
+.local zone is found.  This is not currently implemented at the time of
+writing, but should soon be.
 
-and further clarified in light of the SjoerdHess debacle on 20061016T1230
--- nss-mdns-0.8.orig/debian/NOTES.Debian
+++ nss-mdns-0.8/debian/NOTES.Debian
@@ -0,0 +1,62 @@
+Upgrade implementation notes
+============================
+
+The first version in Debian was 0.3-2.
+
+Starting with version 0.8-4.2 inclusive, the package started touching
+/etc/nsswitch.conf in debian/postinst.
+
+In versions 0.8-4.2, for first installs and upgrades from versions lower or
+equal to 0.8-4.1, the postinst would:
+- avoid doing anything if any of "mdns4_minimal", "mdns4", "mdns",
+  "mdns_minimal", "mdns6", "mdns6_minimal" was found in the hosts line; that
+  is, manually configured /etc/nsswitch.conf were kept intact
+- otherwise change the "dns" entry in /etc/hosts into:
+  "mdns4_minimal [NOTFOUND=return] dns mdns4"
+
+Problems with this version:
+1) does not preserve spacing ("foo   bar" becomes "foo bar")
+2) breaks local reaction overrides ("[STATUS=ACTION]")
+
+In version 0.8-5, the postinst is identical to the postinst of version 0.8-4.2.
+
+In version 0.8-6, the postinst was really messed up:
+* for first installs:
+  - avoid doing anything if any of "mdns4_minimal", "mdns4", "mdns",
+    "mdns_minimal", "mdns6", "mdns6_minimal" was found in the hosts line; that
+    is, manually configured /etc/nsswitch.conf were kept intact
+  - otherwise change the "dns" entry in /etc/hosts into:
+    "mdns_minimal dns mdns"
+  - if the hosts line contained "... mdns4_minimal [NOTFOUND=return] ... dns
+    ... mdns4 ...", remove these "mdns4_minimal [NOTFOUND=return]" and "mdns4"
+    entries
+* for upgrades from versions lower or equal to 0.8-4.1:
+  - avoid doing anything if any of "mdns4_minimal", "mdns4", "mdns",
+    "mdns_minimal", "mdns6", "mdns6_minimal" was found in the hosts line; that
+    is, manually configured /etc/nsswitch.conf were kept intact
+  - otherwise change the "dns" entry in /etc/hosts into:
+    "mdns_minimal dns mdns"
+* for upgrades from versions 0.8-4.2 and 0.8-5:
+  - if the hosts line contained "... mdns4_minimal [NOTFOUND=return] ... dns
+    ... mdns4 ...", remove these "mdns4_minimal [NOTFOUND=return]" and "mdns4"
+    entries
+* for upgrades from versions higher or equal to 0.8-6 (i.e. reinstalls of
+  0.8-6!):
+  - avoid doing anything if any of "mdns4_minimal", "mdns4", "mdns",
+    "mdns_minimal", "mdns6", "mdns6_minimal" was found in the hosts line; that
+    is, manually configured /etc/nsswitch.conf were kept intact
+  - otherwise change the "dns" entry in /etc/hosts into:
+    "mdns_minimal dns mdns"
+
+Problems with this version:
+1) does not preserve spacing ("foo   bar" becomes "foo bar") in many cases
+2) breaks local reaction overrides ("[STATUS=ACTION]") in many cases
+3) does not handle all versions (e.g. local versions, versions from Ubuntu)
+4) installs a configuration which does not match the upstream recommendations
+   for new installs or upgrades from >= 0.8-4.1
+5) removes any local or automatic configuration and breaks the mdns setup when
+   upgrading from versions 0.8-4.2 and 0.8-5
+6) results in ugly spacing when upgrading from versions 0.8-4.2 and 0.8-5 (note
+   the trailing space and the double space between files and dns):
+    hosts:          files  dns 
+

Reply via email to