[ python-Bugs-1085069 ] gethostbyaddr on redhat for multiple hostnames

SourceForge.net noreply at sourceforge.net
Tue Dec 14 13:02:03 CET 2004


Bugs item #1085069, was opened at 2004-12-14 12:02
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1085069&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
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.





----------------------------------------------------------------------

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