Skip to content

component/userhosts: use github.com/figiel/hosts for compatibility with recent libc

Jérome Perrin requested to merge fix/userhosts-new-glibc into master

In ubuntu 21.04 (libc6 2.33-0ubuntu5) or current debian testing (libc6 2.32-5) no longer use open to open /etc/hosts, but what appears as "openat" in strace output - but can not be replaced by defining an openat function.

This uses https://github.com/figiel/hosts which uses another approach of replacing getaddrinfo, gethostbyname* and inet_aton.

Users have been updated a bit, because there are some small differences:

  • the /etc/hosts replacement file is defined by HOSTS_FILE environment variable, not HOSTS
  • the library name is libuserhosts.so, not userhosts.so

Other notable differences, for which we did not need code change are:

  • the new library also try to load a file when HOSTS_FILE is not set
  • the new library still use original /etc/hosts file
  • the new library supports aliases to hostnames, not only ip addresses
Edited by Jérome Perrin

Merge request reports