Skip to content

gethostbyaddr() obsoleted. Change to getaddrinfo()? #162

Description

@jrybar-rh

(should be POSIX-safe across platforms)

Activity

  1. jrybar-rh commented on Jul 20, 2021

    @jrybar-rh
    ContributorAuthor

    This issue created for tracking purposes.
    It originated from rpminspect warning about obsoleted functions from netdb.h.

  2. jiegec commented on Jan 20, 2023

    @jiegec
    Member

    getnameinfo() combines gethostbyaddr() and getservbyport(), and currently in lsof, the latter is queried from both getservbyport() and the port mapper via rpc. I wonder if getnameinfo() queries the port mapper? The manpage does not reveal the detail, and I am unsure whether port map is still extensively used today.

    Update: yes, port map is still used today, e.g. NFS server + rpcbind. The rpcbind process provides the port mapper. getservbyport()/getnameinfo() does not query port mapper via rpc.

    Update 2: although gethostbyaddr() is obsoleted, it fits well in the current code: there is a host cache for gethostbyaddr(), a port cache for getservbyport() + port mapper. If we want to migrate to getaddrinfo(), we will need to merge the two calls and caches, or simply provide an empty port to gethostbyaddr() to only replace gethostbyaddr(). Is it worth it?

  3. kurok commented on Mar 13, 2026

    @kurok
    Contributor

    gethostbyaddr() is obsolete, but getaddrinfo() is not the correct replacement here; getnameinfo() is. However, because lsof intentionally keeps host lookup separate from service lookup and still relies on portmapper/rpcbind behavior, a full migration to getnameinfo() would not be behavior-preserving. Given that, I’d suggest closing this unless someone wants to implement a host-only getnameinfo() refactor without touching the existing service-resolution logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions