> > As I recall, Sean Kelly wrote:
> > > I've got two machines here, one running 4.1-STABLE (from Aug 3) and a
> > > 5.0-CURRENT (from Aug 10) and both of them show the same issue.  When
> > > you use the 'host' command to resolve a CNAME, it will show all the A
> > > records twice:
> > > 
> > > (7) smkelly@edgemaster:~$ host www.microsoft.com
> > > www.microsoft.com is a nickname for microsoft.com
> > > microsoft.com has address
> > > microsoft.com has address
> > > microsoft.com has address
> > > microsoft.com has address
> > > microsoft.com has address
> > > microsoft.com has address
> It is more complicated than that... the bug only shows up if you specify
> an alias name...

You are both correct.  In fact, it looks like you're stating the exact
same thing.

The obvious problem is that if 'host' is resolving a CNAME, there are
two independant places which display the real address.  My guess is
that at some point, two independant developers decided to change the
way 'host' deals with CNAMEs, but they put their code in different
places.  When they commited their code to the CVS repository, there
were no conflicts, and the second one to commit failed to notice that
a part of his code was already implemented.

This bug was actually fixed in rev. 8.28 of host.c (BIND v8.2.1), but
was resurrected in rev. 8.31 (BIND v8.2.2-REL).  Since ISC doesn't
release their CVS logs to the public, I can't find out why this was
done (perhaps a developer commited something based on an earlier rev.,
and didn't merge this change).

If anybody wants it, I've made a patch to correct the problem (see
attached).  It applies against src/contrib/bind/bin/host/host.c of
5-CURRENT (although host.c is the same in RELENG_4, and it applies
cleanly there).  I heard somewhere that the contrib/ tree shouldn't
contain local changes, but I'm unclear as to where local changes to
contribited software go, so I made it against that.  Once you've
applied it, all you should have to do is `( cd /usr/src/usr.bin/host
&& make)`, although I haven't tested that approach.  This should also
apply cleanly to host.c of BIND 8.2.3-T5B, as that's what is in

Hope this helps

Dima Dorfman <[EMAIL PROTECTED]>
Finger [EMAIL PROTECTED] for my public PGP key.

"When in doubt, use brute force."
        -- Ken Thompson
Index: host.c
RCS file: /usr/cvs/FreeBSD/src/contrib/bind/bin/host/host.c,v
retrieving revision
diff -u -r1.1.1.3 host.c
--- host.c      2000/05/26 07:17:07
+++ host.c      2000/09/21 23:46:26
@@ -696,8 +696,18 @@
                if (!hp->ad)
                    if (verbose && isls == 0)
                        printf("The following answer is not verified as authentic by 
the server:\n");
-               while (--ancount >= 0 && cp && cp < eom)
+               while (--ancount >= 0 && cp && cp < eom) {
                        cp = pr_rr(cp, answer->qb2, stdout, filter);
+                       /*
+                        * When we ask for address and there is a CNAME, it
+                        * seems to return both the CNAME and the address.
+                        * Since we trace down the CNAME chain ourselves, we
+                        * don't really want to print the address at this
+                        * point.
+                        */
+                        if (cname && ! verbose)
+                                return (1);
+                }
        if (!verbose)
                return (1);

Reply via email to