The following reply was made to PR config/2710; it has been noted by GNATS.

From: "Ralf S. Engelschall" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: config/2710: configure breaks if you have more than one 'search' 
entry in the resolv.conf.
Date: Sat, 25 Jul 1998 12:48:30 +0200

 In article <[EMAIL PROTECTED]> you wrote:
 
 >[...]
 > configure breaks if you have more than one domain name listed in your 
 > /etc/resolv.conf in a 'search' directive.  IMHO, this isnt the right
 > way to do this at all- what guarantee is there that they have a resolv.conf
 > and that they have only a single domain name listed in the 'search' 
 > statement?
 >>How-To-Repeat:
 > in /etc/resolv.conf:
 > search foo.domain.com
 > search bar.otherdomain.com
 
 > then ./configure normally in the apache source directory
 >>Fix:
 > figure out a smarter way of getting the domain name (duh.) perhaps check to 
 > see if
 > there is more than one domain listed in the /etc/resolv.conf, and if so 
 > prompt the
 > user for the correct domain name, using the first one found as the default 
 > value.
 
 > The configure script looks incredibly broken. example:
 >             domainname="`egrep '^[      ]*search' /etc/resolv.conf |\
 >                          sed -e 's/.*search//' -e 's/^[         ]*//' \
 >                              -e 's/^ *//' -e 's/^       *//' \
 >                              -e 's/ .*//' -e 's/^\.//' -e 's/^/./'`"
 
 > ugly!!!! thats the most heinous sed script i've ever seen! it can be reduced 
 > to 
 > this:
 
 > domainname="`awk  '/search/ { print "."$2 }' /etc/resolv.conf`
 
 > someone needs to rewrite this configure. its terrible.
 
 >[...]
 > slight correction to the awk script:
 >  awk  '/search/ { print /^./ ? $2 : "."$2 }' /etc/resolv.conf
 >[...]
 
 A few statements:
 
 1. The configure is not such terrible because we like it this way.
    Its mostly such terrible to be portable. If the goal would be less
    complicated constructs we would write it in Icon or Perl or whatever
    powerful language. But we only have Bourne-Shell and a few
    semi-standardized tools we can use in a portable way. So just saying "some
    needs to rewrite this configure. its terrible" is not very realistic.  At
    least not when you are confronted with such a lot of platforms which such a
    lot of broken tools.
 
 2. Yes, the sed used construct is horrible. But its maximum portable 
    this way (even if there is a bug with the two search entries). Replacing it
    with your suggested Awk-based solution is perhaps possible. But you will
    not doubt me when I say that the chance is high that this one fails under
    some platforms. Awks are even more broken out there in the world then some
    Sed's, really.
 
 3. When you think about the problematic of determining the domainname
    of a machine _IN A PORTABLE WAY_ you recognize that trying to guess it from
    some information inside /etc/resolv.conf is the only acceptable way. Sure,
    its not the correct way on some platforms, but all other ways like
    nslookup-based approaches, uname-based approaches or even checking
    /etc/hosts is either non-portable or results in even more incorrect values.
 
 But you're right, we missed at least the fact that perhaps there are more than
 one "search" entry in /etc/resolv.conf. This is a bug. Thanks discovering
 this. But IMHO the best and most portable way is to just add a "head -1" after
 the egrep. 
 
 BTW, even you suggested 
    
    domainname="`awk '/search/ { print /^./ ? $2 : "."$2 }'`"
 
 as a better solution you also forgot the "multiple-search" problem: It fails
 also when more "search" entries exist! It just prints all of them. And
 additionally it is non-portable because it uses nested double quotes which
 some braindead Bourne Shell variants dislike most.
 
 So, please understand that we only add "head -1" for Apache 1.3.2 and have to
 ignore your suggestion because of portability. Nevertheless thanks for the
 report.
 
 Greetings,
                                        Ralf S. Engelschall
                                        [EMAIL PROTECTED]
                                        www.engelschall.com

Reply via email to