Commit b1acdb0a authored by Jérome Perrin's avatar Jérome Perrin

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

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
parent e0262aaf
[userhosts]
recipe = slapos.recipe.cmmi
shared = true
url = https://lab.nexedi.com/nexedi/userhosts/repository/${:revision}/archive.tar.gz
revision = a05fe5a3a5cb7005351ef4ec41460089f3ce4d0a
md5sum = 5a80b4d962d975f290a60cf790c3334d
url = https://github.com/figiel/hosts/archive/${:revision}.tar.gz
revision = fdb45fe219593d63453f4be55cfc2a1199c18f59
md5sum = 9ff5407132a2a67200ef1036a02f0ee2
configure-command = true
make-options = PREFIX=@@LOCATION@@
make-targets = check install
make-targets = test install
......@@ -15,4 +15,4 @@
[template]
filename = instance.cfg
md5sum = 597c29546519aabe7259e416d0b92095
md5sum = ba6c572678687081ce111d3805be3cee
......@@ -35,10 +35,10 @@ repository = ${caucase-repository:location}
[caucase-test-runner]
recipe = slapos.recipe.template:jinja2
template = inline:#!/bin/sh
export HOSTS="$(mktemp)"
trap 'rm "$HOSTS"' EXIT
printf '%s testhost\n%s testhost\n' "$SLAPOS_TEST_IPV4" "$SLAPOS_TEST_IPV6" > "$HOSTS"
export CAUCASE_NETLOC=testhost:8000 LD_PRELOAD=${userhosts:location}/lib/userhosts.so:$LD_PRELOAD
export HOSTS_FILE="$(mktemp)"
trap 'rm "$HOSTS_FILE"' EXIT
printf '%s testhost\n%s testhost\n' "$SLAPOS_TEST_IPV4" "$SLAPOS_TEST_IPV6" > "$HOSTS_FILE"
export CAUCASE_NETLOC=testhost:8000 LD_PRELOAD=${userhosts:location}/lib/libuserhosts.so:$LD_PRELOAD
exec python -m unittest discover -v
rendered = $${caucase:location}/host_setting.sh
......
......@@ -70,7 +70,7 @@ md5sum = 7a14019abf48ca100eb94d9add20f5ae
[template]
filename = instance.cfg.in
md5sum = bbef65b4edeb342f08309604ca3717d5
md5sum = 0444d646607f8643e987bb62d1cbbc1d
[template-erp5]
filename = instance-erp5.cfg.in
......@@ -86,7 +86,7 @@ md5sum = bc821f9f9696953b10a03ad7b59a1936
[template-zope]
filename = instance-zope.cfg.in
md5sum = f3121380ab4d31ba5f4984aec74d0a2f
md5sum = 09895deebca3206425fada3caf1d92cf
[template-balancer]
filename = instance-balancer.cfg.in
......
......@@ -185,7 +185,7 @@ context = key host_dict hosts-parameter:host-dict
recipe = slapos.recipe.template:jinja2
mode = 755
template = inline:#!{{ parameter_dict['dash'] }}/bin/dash
export HOSTS=${hosts:rendered}
export HOSTS_FILE=${hosts:rendered}
export LD_PRELOAD={{ parameter_dict['userhosts'] }}:$LD_PRELOAD
exec "$@"
rendered = ${directory:bin}/userhosts
......
......@@ -110,7 +110,7 @@ link-binary = {{ dumps(zope_link_binary) }}
fonts = {{ dumps(zope_fonts) }}
fontconfig-includes = {{ dumps(zope_fontconfig_includes) }}
template-fonts-conf = {{ dumps(template_fonts_conf) }}
userhosts = {{ userhosts_location }}/lib/userhosts.so
userhosts = {{ userhosts_location }}/lib/libuserhosts.so
site-zcml = {{ site_zcml }}
extra-path-list = {{ dumps(extra_path_list) }}
matplotlibrc = {{ matplotlibrc_location }}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment