From olli@grabthar.secnetix.de  Thu Feb  6 13:08:16 2014
Return-Path: <olli@grabthar.secnetix.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 8F16CBC6
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  6 Feb 2014 13:08:16 +0000 (UTC)
Received: from grabthar.secnetix.de (grabthar.secnetix.de [IPv6:2a01:170:102f::1])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 125B012CD
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  6 Feb 2014 13:08:15 +0000 (UTC)
Received: from grabthar.secnetix.de (localhost [127.0.0.1])
	by grabthar.secnetix.de (8.14.7/8.14.7) with ESMTP id s16D8BZk005008;
	Thu, 6 Feb 2014 14:08:12 +0100 (CET)
	(envelope-from oliver.fromme@secnetix.de)
Received: (from olli@localhost)
	by grabthar.secnetix.de (8.14.7/8.14.7/Submit) id s16D8BCC005007;
	Thu, 6 Feb 2014 14:08:11 +0100 (CET)
	(envelope-from olli)
Message-Id: <201402061308.s16D8BCC005007@grabthar.secnetix.de>
Date: Thu, 6 Feb 2014 14:08:11 +0100 (CET)
From: Oliver Fromme <oliver.fromme@secnetix.de>
Reply-To: Oliver Fromme <oliver.fromme@secnetix.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc: olli@secnetix.de
Subject: [PATCH] Latest BIND port triggers problem in portsnap
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         186510
>Category:       bin
>Synopsis:       [PATCH] Latest BIND port triggers problem in portsnap(8)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    delphij
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 06 13:10:00 UTC 2014
>Closed-Date:    Mon Apr 21 19:34:26 UTC 2014
>Last-Modified:  Fri May  9 08:10:00 UTC 2014
>Originator:     Oliver Fromme
>Release:        FreeBSD 9.2 i386
>Organization:
secnetix GmbH & Co. KG
		http://www.secnetix.de/bsd
>Environment:

$ pkg_info | grep bind
bind99-base-9.9.5
$ grep BASE\$ /var/db/ports/dns_bind99/options
OPTIONS_FILE_SET+=REPLACE_BASE

The problem only affects FreeBSD 9 and earlier.
FreeBSD 10+ is not affected by the problem because
BIND was removed from the base system, so the
"replace base" option of the port isn't supported
anymore.

NB:  I decided to set the priority "high" for this PR,
because the problem prevents affected users from updating
the ports collection.  It's also trivial to fix.

>Description:

Since I updated to the latest BIND 9.9.5 port, portsnap fails
with this message:

    Looking up portsnap.FreeBSD.org mirrors... none found.

It turns out that the reason for this is the fact that the
output from the host(1) command changed with the latest BIND
update.
Before the update, the lines looked tlike this:

    _http._tcp.portsnap.FreeBSD.org has SRV record x y z ...

With the new version, they look like this:

    _http._tcp.portsnap.freebsd.org has SRV record x y z ...

That is, the names being looked up on the left are converted
to lower case.  The portsnap script contains a sed command that
tries to match the lines with the host name.  That match now
fails because of the upper/lower case difference.  This means
that no mirrors are found.

>How-To-Repeat:

On a FreeBSD 9 machine, install the latest dns/bind99 port
with the option "replace base" set, so that /usr/bin/host
comes from the BIND port.  Then try to use portsnap.

>Fix:

The fix is trivial:  Add the "I" flag to the sed command
in order to make it case-insensitive.

The fix should be applied on all branches, including HEAD
and FreeBSD 10, even though they are not affected by this
particular problem.  DNS names are generally case-insensitive,
so a script should never rely on the case of output produced
by a program.  Therefore, when matching host names, it should
*always* be done in a case-insensitive manner.

PS:  I'm sorry, I had to copy&paste the diff, so I probably
broke the tab characters.  But the patch is sufficiently
trivial so the patch(1) command isn't really required.

@@ -348,7 +348,7 @@
 # "$name server selection ..."; we allow either format.
        MLIST="_http._tcp.${SERVERNAME}"
        host -t srv "${MLIST}" |
-           sed -nE "s/${MLIST} (has SRV record|server selection) //p" |
+           sed -nE "s/${MLIST} (has SRV record|server selection) //Ip" |
            cut -f 1,2,4 -d ' ' |
            sed -e 's/\.$//' |
            sort > serverlist_full

>Release-Note:
>Audit-Trail:

From: Oliver Fromme <oliver.fromme@secnetix.de>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/186510: [PATCH] Latest BIND port triggers problem in portsnap
Date: Thu, 6 Feb 2014 15:20:33 +0100 (CET)

 Addendum:
 
 At first I wasn't able to reproduce the problem on a second machine.
 Then it turned out that it actually depends on the name server being used:
 
 $ host -t srv _http._tcp.portsnap.freebsd.org. ns-20.awsdns-02.com.
 ;; Truncated, retrying in TCP mode.
 Using domain server:
 Name: ns-20.awsdns-02.com.
 Address: 205.251.192.20#53
 Aliases:
 _http._tcp.portsnap.freebsd.org has SRV record 1 10 80 ec2-eu-west-1.portsnap.freebsd.org.
 _http._tcp.portsnap.freebsd.org has SRV record 2 10 80 sourcefire.portsnap.freebsd.org.
 _http._tcp.portsnap.freebsd.org has SRV record 2 10 80 your-org.portsnap.freebsd.org.
 _http._tcp.portsnap.freebsd.org has SRV record 3 10 80 isc.portsnap.freebsd.org.
 _http._tcp.portsnap.freebsd.org has SRV record 4 10 80 ec2-ap-northeast-1.portsnap.freebsd.org.
 _http._tcp.portsnap.freebsd.org has SRV record 4 10 80 ec2-ap-southeast-2.portsnap.freebsd.org.
 _http._tcp.portsnap.freebsd.org has SRV record 4 10 80 ec2-sa-east-1.portsnap.freebsd.org.
 
 $ host -t srv _http._tcp.portsnap.freebsd.org. 127.0.0.1
 ;; Truncated, retrying in TCP mode.
 Using domain server:
 Name: 127.0.0.1
 Address: 127.0.0.1#53
 Aliases:
 _http._tcp.portsnap.FreeBSD.org has SRV record 2 10 80 your-org.portsnap.freebsd.org.
 _http._tcp.portsnap.FreeBSD.org has SRV record 4 10 80 ec2-ap-southeast-2.portsnap.freebsd.org.
 _http._tcp.portsnap.FreeBSD.org has SRV record 1 10 80 ec2-eu-west-1.portsnap.freebsd.org.
 _http._tcp.portsnap.FreeBSD.org has SRV record 4 10 80 ec2-ap-northeast-1.portsnap.freebsd.org.
 _http._tcp.portsnap.FreeBSD.org has SRV record 3 10 80 isc.portsnap.freebsd.org.
 _http._tcp.portsnap.FreeBSD.org has SRV record 2 10 80 sourcefire.portsnap.freebsd.org.
 _http._tcp.portsnap.FreeBSD.org has SRV record 4 10 80 ec2-sa-east-1.portsnap.freebsd.org.
 
 In the first case, one of the authoritative servers for the
 portsnap.freebsd.org domain was used.  In the second case,
 the local BIND *the one from the dns/bind99 port) was used.
 The latter seems to preserve the case, the former does not.
 
 I'm not sure at what point the case conversion happens exactly.
 But that doesn't really matter.  As I wrote earlier, DNS names
 are generally case-insensitive, so matching must be done in a
 case-insensitive way.
 
 Best regards
    Oliver
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Sun Apr 13 23:34:37 UTC 2014 
State-Changed-Why:  
to which part of the system does the patch pertain to? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=186510 
State-Changed-From-To: feedback->open 
State-Changed-By: delphij 
State-Changed-When: Mon Apr 14 19:38:43 UTC 2014 
State-Changed-Why:  
I think we have enough information to solve this already. 


Responsible-Changed-From-To: freebsd-bugs->cperciva 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Mon Apr 14 19:38:43 UTC 2014 
Responsible-Changed-Why:  
Hi, Colin, 

The proposed change looks reasonable to me and I have tested 
it.  Can you approve or commit the change?  I'll commit this 
one if you have no objections nor committed it by Apr 21. 

Thanks in advance! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=186510 
State-Changed-From-To: open->closed 
State-Changed-By: delphij 
State-Changed-When: Mon Apr 21 19:33:33 UTC 2014 
State-Changed-Why:  
Committed, thanks! 


Responsible-Changed-From-To: cperciva->delphij 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Mon Apr 21 19:33:33 UTC 2014 
Responsible-Changed-Why:  
Take because I have committed the patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=186510 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/186510: commit references a PR
Date: Mon, 21 Apr 2014 19:33:31 +0000 (UTC)

 Author: delphij
 Date: Mon Apr 21 19:33:27 2014
 New Revision: 264740
 URL: http://svnweb.freebsd.org/changeset/base/264740
 
 Log:
   Use case insensitive match in portsnap.
   
   PR:		bin/186510
   Submitted by:	olli
   MFC after:	2 weeks
 
 Modified:
   head/usr.sbin/portsnap/portsnap/portsnap.sh
 
 Modified: head/usr.sbin/portsnap/portsnap/portsnap.sh
 ==============================================================================
 --- head/usr.sbin/portsnap/portsnap/portsnap.sh	Mon Apr 21 19:17:19 2014	(r264739)
 +++ head/usr.sbin/portsnap/portsnap/portsnap.sh	Mon Apr 21 19:33:27 2014	(r264740)
 @@ -367,7 +367,7 @@ fetch_pick_server_init() {
  # "$name server selection ..."; we allow either format.
  	MLIST="_http._tcp.${SERVERNAME}"
  	host -t srv "${MLIST}" |
 -	    sed -nE "s/${MLIST} (has SRV record|server selection) //p" |
 +	    sed -nE "s/${MLIST} (has SRV record|server selection) //Ip" |
  	    cut -f 1,2,4 -d ' ' |
  	    sed -e 's/\.$//' |
  	    sort > serverlist_full
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/186510: commit references a PR
Date: Fri,  9 May 2014 07:07:30 +0000 (UTC)

 Author: delphij
 Date: Fri May  9 07:07:25 2014
 New Revision: 265742
 URL: http://svnweb.freebsd.org/changeset/base/265742
 
 Log:
   MFC r264740:
   
   Use case insensitive match in portsnap.
   
   PR:		bin/186510
   Submitted by:	olli
 
 Modified:
   stable/10/usr.sbin/portsnap/portsnap/portsnap.sh
 Directory Properties:
   stable/10/   (props changed)
 
 Modified: stable/10/usr.sbin/portsnap/portsnap/portsnap.sh
 ==============================================================================
 --- stable/10/usr.sbin/portsnap/portsnap/portsnap.sh	Fri May  9 07:04:12 2014	(r265741)
 +++ stable/10/usr.sbin/portsnap/portsnap/portsnap.sh	Fri May  9 07:07:25 2014	(r265742)
 @@ -362,7 +362,7 @@ fetch_pick_server_init() {
  # "$name server selection ..."; we allow either format.
  	MLIST="_http._tcp.${SERVERNAME}"
  	host -t srv "${MLIST}" |
 -	    sed -nE "s/${MLIST} (has SRV record|server selection) //p" |
 +	    sed -nE "s/${MLIST} (has SRV record|server selection) //Ip" |
  	    cut -f 1,2,4 -d ' ' |
  	    sed -e 's/\.$//' |
  	    sort > serverlist_full
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/186510: commit references a PR
Date: Fri,  9 May 2014 08:07:10 +0000 (UTC)

 Author: delphij
 Date: Fri May  9 08:07:05 2014
 New Revision: 265753
 URL: http://svnweb.freebsd.org/changeset/base/265753
 
 Log:
   MFC r264740:
   
   Use case insensitive match in portsnap.
   
   PR:		bin/186510
   Submitted by:	olli
 
 Modified:
   stable/9/usr.sbin/portsnap/portsnap/portsnap.sh
 Directory Properties:
   stable/9/usr.sbin/portsnap/   (props changed)
   stable/9/usr.sbin/portsnap/portsnap/   (props changed)
 
 Modified: stable/9/usr.sbin/portsnap/portsnap/portsnap.sh
 ==============================================================================
 --- stable/9/usr.sbin/portsnap/portsnap/portsnap.sh	Fri May  9 08:02:52 2014	(r265752)
 +++ stable/9/usr.sbin/portsnap/portsnap/portsnap.sh	Fri May  9 08:07:05 2014	(r265753)
 @@ -348,7 +348,7 @@ fetch_pick_server_init() {
  # "$name server selection ..."; we allow either format.
  	MLIST="_http._tcp.${SERVERNAME}"
  	host -t srv "${MLIST}" |
 -	    sed -nE "s/${MLIST} (has SRV record|server selection) //p" |
 +	    sed -nE "s/${MLIST} (has SRV record|server selection) //Ip" |
  	    cut -f 1,2,4 -d ' ' |
  	    sed -e 's/\.$//' |
  	    sort > serverlist_full
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
