Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4235 > unrolled thread

socket.gethostbyaddr() wrongly returning a DNS CNAME as the 'primary' hostname

Started bycjblaine <cjblaine@gmail.com>
First post2011-04-28 09:10 -0700
Last post2011-04-28 12:34 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  socket.gethostbyaddr() wrongly returning a DNS CNAME as the 'primary' hostname cjblaine <cjblaine@gmail.com> - 2011-04-28 09:10 -0700
    Re: socket.gethostbyaddr() wrongly returning a DNS CNAME as the 'primary' hostname Ned Deily <nad@acm.org> - 2011-04-28 12:34 -0700

#4235 — socket.gethostbyaddr() wrongly returning a DNS CNAME as the 'primary' hostname

Fromcjblaine <cjblaine@gmail.com>
Date2011-04-28 09:10 -0700
Subjectsocket.gethostbyaddr() wrongly returning a DNS CNAME as the 'primary' hostname
Message-ID<850c85c0-be6e-4eec-b6b1-5c79e1716f6d@glegroupsg2000goo.googlegroups.com>
Python 2.7.1 (perhaps others)

I believe this is a bug.  Comments?

Docs state: Return a triple (hostname, aliaslist, ipaddrlist)
where hostname is the primary host name responding to the
given ip_address, aliaslist is a (possibly empty) list of
alternative host names  for the same address, and ipaddrlist
is a list of IPv4/v6 addresses for the same interface on the
same host (most likely containing only a single address).

my-dns-cname.our.org is a CNAME record for primary.our.org
primary.our.org has IP address xx.xx.xx.xx

import socket
socket.gethostbyaddr('xx.xx.xx.xx')

returns:

    ('my-dns-cname.our.org', ['primary.our.org'], ['xx.xx.xx.xx'])

[toc] | [next] | [standalone]


#4253

FromNed Deily <nad@acm.org>
Date2011-04-28 12:34 -0700
Message-ID<mailman.955.1304019300.9059.python-list@python.org>
In reply to#4235
In article 
<850c85c0-be6e-4eec-b6b1-5c79e1716f6d@glegroupsg2000goo.googlegroups.com
>, cjblaine <cjblaine@gmail.com> wrote:
> Python 2.7.1 (perhaps others)
> 
> I believe this is a bug.  Comments?
> 
> Docs state: Return a triple (hostname, aliaslist, ipaddrlist)
> where hostname is the primary host name responding to the
> given ip_address, aliaslist is a (possibly empty) list of
> alternative host names  for the same address, and ipaddrlist
> is a list of IPv4/v6 addresses for the same interface on the
> same host (most likely containing only a single address).
> 
> my-dns-cname.our.org is a CNAME record for primary.our.org
> primary.our.org has IP address xx.xx.xx.xx
> 
> import socket
> socket.gethostbyaddr('xx.xx.xx.xx')
> 
> returns:
> 
>     ('my-dns-cname.our.org', ['primary.our.org'], ['xx.xx.xx.xx'])

socket.gethostbyaddr() is pretty much just a transparent wrapper around 
the platform's C library function of the same name.  See if a simple C 
program with a similar call to gethostbyaddr produces the same results.  
The code in question for Python 2.7 is here:

http://hg.python.org/cpython/file/a6b772599594/Modules/socketmodule.c

-- 
 Ned Deily,
 nad@acm.org

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web