[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getfqdn passes a hostname to gethostbyaddr instead of an ip address

On 12/09/18 15:29, Florian Bergmann wrote:
> Hello,
> While I was debugging some salt issues I dug into the python code and found a
> piece of code in the `socket.py` module that surprised my a bit:
> In the `getfqdn` function the `gethostbyaddr` name function is being called with
> a `hostname` instead of an `ipaddress`:


> 2. `gethostbyaddr()`:
> Also from the documentation:
> ```
> Return a triple (hostname, aliaslist, ipaddrlist) where hostname is the primary host name responding to the *given ip_address* (...)
> ```
> As the documentation states it expects an `ip_address` and not a hostname,
> but it is given a `hostname` instead.

I believe the online documentation is wrong.  The help text certainly 

Help on built-in function gethostbyaddr in module _socket:

     gethostbyaddr(host) -> (name, aliaslist, addresslist)

     Return the true host name, a list of aliases, and a list of IP 
     for a host.  The host argument is a string giving a host name or IP 

Rhodri James *-* Kynesim Ltd