import: dlopen libacl only when libarchive support is enabled

Otherwise, test-dlopen-note.py fails when libarchive support is disabled
but libacl support is enabled.

Also, log the dlopen_libarchive() failure at LOG_ERR level, matching how
the other failures are already logged.

Fixes #43530.
This commit is contained in:
Yu Watanabe
2026-08-27 17:05:34 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 85cdcad36b
commit 82fb7a0297
+16 -4
View File
@@ -32,11 +32,18 @@ int import_fork_tar_x(int tree_fd, int userns_fd, PidRef *ret_pid) {
assert(tree_fd >= 0);
assert(ret_pid);
(void) dlopen_libacl(LOG_DEBUG);
r = dlopen_libarchive(LOG_DEBUG);
r = dlopen_libarchive(LOG_ERR);
if (r < 0)
return r;
/* Add the #if guard here to suppress a test-dlopen-note.py failure. If libarchive support is
* disabled, dlopen_libarchive() above fails, so this code is never reached. However, without
* the #if guard, the dlopen_libacl symbol would still end up in the final executable, and the
* resulting missing dlopen note would trigger the test failure. */
#if HAVE_LIBARCHIVE
(void) dlopen_libacl(LOG_DEBUG);
#endif
TarFlags flags =
(userns_fd >= 0 ? TAR_SQUASH_UIDS_ABOVE_64K : 0) |
(mac_selinux_use() ? TAR_SELINUX : 0);
@@ -101,11 +108,16 @@ int import_fork_tar_c(int tree_fd, int userns_fd, PidRef *ret_pid) {
assert(tree_fd >= 0);
assert(ret_pid);
(void) dlopen_libacl(LOG_DEBUG);
r = dlopen_libarchive(LOG_DEBUG);
r = dlopen_libarchive(LOG_ERR);
if (r < 0)
return r;
/* Add the #if guard here to suppress a test-dlopen-note.py failure. See the comment in
* import_fork_tar_x() above. */
#if HAVE_LIBARCHIVE
(void) dlopen_libacl(LOG_DEBUG);
#endif
TarFlags flags =
(userns_fd >= 0 ? TAR_SQUASH_UIDS_ABOVE_64K : 0) |
(mac_selinux_use() ? TAR_SELINUX : 0);