[ python-Bugs-1085069 ] gethostbyaddr on redhat for multiple
hostnames
SourceForge.net
noreply at sourceforge.net
Thu Jan 6 21:28:12 CET 2005
Bugs item #1085069, was opened at 2004-12-14 13:02
Message generated for change (Settings changed) made by loewis
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1085069&group_id=5470
Category: None
>Group: 3rd Party
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Dave Kirby (davekirby)
Assigned to: Nobody/Anonymous (nobody)
Summary: gethostbyaddr on redhat for multiple hostnames
Initial Comment:
When running socket.gethostbyaddr against a host with
multiple hostnames assigned to it, the behaviour does
not work as advertised under Red Hat linux (tested with
Fedora Core 2 and Red Hat 8 - other versions of Linux
have not been tested).
calling socket.gethostbyaddr from Windows or Mac OS X
against a test machine set up with multiple hosts gives
the correct result:
>>> socket.gethostbyaddr('1.2.3.4')
('testhost2', ['testhost7', 'testhost', 'testhost1',
'testhost3', 'testhost4', 'testhost6', 'testhost5'],
['1.2.3.4'])
>>>
(The real IP address and hostnames have been changed
for security).
running the same thing from Linux only gives a single
hostname, and the alias list is empty. Repeated calls
to the same function cycles through the hostnames (or
picks them at random):
>>> socket.gethostbyaddr('1.2.3.4')
('testhost', [], ['1.2.3.4'])
>>> socket.gethostbyaddr('1.2.3.4')
('testhost1', [], ['1.2.3.4'])
>>> socket.gethostbyaddr('1.2.3.4')
('testhost3', [], ['1.2.3.4'])
>>> socket.gethostbyaddr('1.2.3.4')
('testhost4', [], ['1.2.3.4'])
>>> socket.gethostbyaddr('1.2.3.4')
('testhost6', [], ['1.2.3.4'])
>>> socket.gethostbyaddr('1.2.3.4')
('testhost5', [], ['1.2.3.4'])
>>> socket.gethostbyaddr('1.2.3.4')
('testhost2', [], ['1.2.3.4'])
>>> socket.gethostbyaddr('1.2.3.4')
('testhost7', [], ['1.2.3.4'])
>>> socket.gethostbyaddr('1.2.3.4')
('testhost', [], ['1.2.3.4'])
This behaviour has been seen with Python 2.2.1, 2.3.3
and 2.4-RC2.
This is probably a bug in the underlying C function.
According to the Linux man page, the POSIX
gethostbyaddr has been superceded by getipnodebyaddr.
This behaviour should at least be documented, and if
possible fixed by using the new function.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2005-01-06 21:28
Message:
Logged In: YES
user_id=21627
This is indeed likely a bug in the underlying C library (or
a misconfiguration of the system, see /etc/hosts). As Python
exposes the function more-or-less as-is, I'm closing this as
a third-party bug.
It is true that gethostbyaddr was superceded by
getipnodebyaddr at some point. Meanwhile, this, in turn, was
superceded by getaddrinfo/getnameinfo, which Python exposes.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1085069&group_id=5470
More information about the Python-bugs-list
mailing list