6063eb27b9
The /usr/bin/toolbox binary is not only used to interact with toolbox
containers and images from the host. It's also used as the entry point
of the containers by bind mounting the binary from the host into the
container. This means that the /usr/bin/toolbox binary on the host must
also work inside the container, even if they have different operating
systems.
In the past, this worked perfectly well with the POSIX shell
implementation because it got intepreted by whichever /bin/sh was
available. However, the Go implementation, can run into ABI
compatibility issues because binaries built on newer toolchains aren't
meant to be run against older runtimes.
The previous approach [1] of restricting the versions of the glibc
symbols that are linked against isn't actually supported by glibc, and
breaks if the early process start-up code changes. This is seen in
glibc-2.34, which is used by Fedora 35 onwards, where a new version of
the __libc_start_main symbol [2] was added as part of some security
hardening:
$ objdump -T ./usr/bin/toolbox | grep GLIBC_2.34
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.34
__libc_start_main
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.34
pthread_detach
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.34
pthread_create
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.34
pthread_attr_getstacksize
This means that /usr/bin/toolbox binaries built against glibc-2.34 on
newer Fedoras fail to run against older glibcs in older Fedoras.
Another option is to make the host's runtime available inside the
toolbox container and ensure that the binary always runs against it.
Luckily, almost all supported containers have the host's /usr available
at /run/host/usr. This is exploited by embedding RPATHs or RUNPATHs to
/run/host/usr/lib and /run/host/usr/lib64 in the binary, and changing
the path of the dynamic linker (ie., PT_INTERP) to the one inside
/run/host.
Unfortunately, there can only be one PT_INTERP entry inside the
binary, so there must be a /run/host on the host too. Therefore, a
/run/host symbolic link is created on the host that points to the
host's /.
Based on ideas from Alexander Larsson and Ray Strode.
[1] Commit 6ad9c63180
https://github.com/containers/toolbox/pull/534
[2] glibc commit 035c012e32c11e84
https://sourceware.org/git/?p=glibc.git;a=commit;h=035c012e32c11e84
https://sourceware.org/bugzilla/show_bug.cgi?id=23323
https://github.com/containers/toolbox/issues/821
61 lines
1.6 KiB
Meson
61 lines
1.6 KiB
Meson
project(
|
|
'toolbox',
|
|
version: '0.0.99.2',
|
|
license: 'ASL 2.0',
|
|
meson_version: '>= 0.53.0',
|
|
)
|
|
|
|
go = find_program('go')
|
|
go_md2man = find_program('go-md2man')
|
|
patchelf = find_program('patchelf')
|
|
shellcheck = find_program('shellcheck', required: false)
|
|
skopeo = find_program('skopeo', required: false)
|
|
|
|
bash_completion = dependency('bash-completion', required: false)
|
|
|
|
profiledir = get_option('profile_dir')
|
|
|
|
tmpfilesdir = get_option('tmpfiles_dir')
|
|
if tmpfilesdir == ''
|
|
systemd_dep = dependency('systemd')
|
|
tmpfilesdir = systemd_dep.get_pkgconfig_variable('tmpfilesdir')
|
|
endif
|
|
|
|
if bash_completion.found()
|
|
install_data(
|
|
'completion/bash/toolbox',
|
|
install_dir: bash_completion.get_pkgconfig_variable('completionsdir')
|
|
)
|
|
endif
|
|
|
|
if not skopeo.found()
|
|
message('Running system tests requires Skopeo for OCI image manipulation.')
|
|
endif
|
|
|
|
install_subdir(
|
|
'test',
|
|
install_dir: join_paths(get_option('datadir'), meson.project_name()),
|
|
exclude_files: [
|
|
'system/libs/bats-assert/.git',
|
|
'system/libs/bats-assert/.gitignore',
|
|
'system/libs/bats-assert/.travis.yml',
|
|
'system/libs/bats-assert/package.json',
|
|
'system/libs/bats-support/.git',
|
|
'system/libs/bats-support/.gitignore',
|
|
'system/libs/bats-support/.travis.yml',
|
|
'system/libs/bats-support/package.json'
|
|
],
|
|
exclude_directories: [
|
|
'system/libs/bats-assert/.git',
|
|
'system/libs/bats-assert/script',
|
|
'system/libs/bats-assert/test',
|
|
'system/libs/bats-support/.git',
|
|
'system/libs/bats-support/script',
|
|
'system/libs/bats-support/test'
|
|
]
|
|
)
|
|
|
|
subdir('data')
|
|
subdir('doc')
|
|
subdir('profile.d')
|
|
subdir('src')
|