Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'responding': 0.04; '2.7': 0.05; 'socket': 0.05; 'bug.': 0.07; 'produces': 0.07; 'wrapper': 0.07; 'python': 0.07; '(possibly': 0.09; 'hostname': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:DNS': 0.09; 'skip:[ 20': 0.12; 'wrote:': 0.14; 'library': 0.15; 'address).': 0.16; 'from:addr:acm.org': 0.16; 'received:198.144': 0.16; 'subject:() ': 0.16; 'subject:returning': 0.16; 'url:hg': 0.16; '(most': 0.16; '(perhaps': 0.19; "subject:' ": 0.19; 'interface': 0.20; 'code': 0.22; 'state:': 0.23; 'skip:[ 10': 0.26; 'function': 0.27; 'host': 0.30; 'list': 0.30; 'skip:( 20': 0.31; 'comments?': 0.31; "subject: '": 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'received:198': 0.33; 'record': 0.34; 'header:X-Complaints-To:1': 0.34; 'primary': 0.34; 'question': 0.35; 'header:User-Agent:1': 0.35; 'addresses': 0.36; 'charset:us-ascii': 0.36; 'url:python': 0.37; 'results.': 0.38; 'pretty': 0.38; 'url:org': 0.38; 'received:org': 0.38; 'docs': 0.39; 'likely': 0.39; 'skip:s 30': 0.39; 'to:addr:python.org': 0.39; 'where': 0.39; 'header:Mime- Version:1': 0.39; 'similar': 0.40; 'containing': 0.40; 'header:Received:5': 0.40; 'simple': 0.60; 'address': 0.61; 'here:': 0.61; 'transparent': 0.65; 'believe': 0.66; 'address,': 0.68; 'alternative': 0.69; 'url:c': 0.74; 'article': 0.75; '2.7.1': 0.84; 'subject:skip:s 20': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Deily Subject: Re: socket.gethostbyaddr() wrongly returning a DNS CNAME as the 'primary' hostname Date: Thu, 28 Apr 2011 12:34:45 -0700 References: <850c85c0-be6e-4eec-b6b1-5c79e1716f6d@glegroupsg2000goo.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: baybryj.net User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304019301 news.xs4all.nl 41113 [::ffff:82.94.164.166]:57096 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4253 In article <850c85c0-be6e-4eec-b6b1-5c79e1716f6d@glegroupsg2000goo.googlegroups.com >, cjblaine 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