diff --git a/src/import/import-common.c b/src/import/import-common.c index 0b63828869..eb828d6b14 100644 --- a/src/import/import-common.c +++ b/src/import/import-common.c @@ -5,6 +5,7 @@ #include "sd-event.h" +#include "acl-util.h" #include "capability-util.h" #include "compress.h" #include "dirent-util.h" @@ -31,6 +32,7 @@ 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); if (r < 0) return r; @@ -99,6 +101,7 @@ 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); if (r < 0) return r; diff --git a/src/import/meson.build b/src/import/meson.build index 1bfdba1e55..a1ac50594f 100644 --- a/src/import/meson.build +++ b/src/import/meson.build @@ -17,6 +17,7 @@ executables += [ 'qcow2-util.c', ), 'dependencies' : [ + libacl_cflags, libarchive_cflags, libselinux_cflags, ], diff --git a/src/import/test-tar.c b/src/import/test-tar.c index 6fca4b89cb..c73062e9ed 100644 --- a/src/import/test-tar.c +++ b/src/import/test-tar.c @@ -26,7 +26,7 @@ static int run(int argc, char **argv) { else return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown operation '%s'.", argv[1]); - r = dlopen_libarchive(LOG_DEBUG); + r = dlopen_libarchive(LOG_ERR); if (r < 0) return r; diff --git a/src/shared/tar-util.c b/src/shared/tar-util.c index c60054b2d1..f3b63fe98f 100644 --- a/src/shared/tar-util.c +++ b/src/shared/tar-util.c @@ -79,12 +79,14 @@ static void open_inode_done(OpenInode *of) { of->fd = safe_close(of->fd); of->path = mfree(of->path); } + xattr_free_array(of->xattr, of->n_xattr); + of->xattr = NULL; + of->n_xattr = 0; + #if HAVE_ACL - if (of->acl_access) - sym_acl_free(of->acl_access); - if (of->acl_default) - sym_acl_free(of->acl_default); + acl_freep(&of->acl_access); + acl_freep(&of->acl_default); #endif } @@ -747,6 +749,10 @@ int tar_x(int input_fd, int tree_fd, TarFlags flags) { assert(input_fd >= 0); assert(tree_fd >= 0); + r = dlopen_libarchive(LOG_DEBUG); + if (r < 0) + return r; + _cleanup_(archive_read_freep) struct archive *a = NULL; a = sym_archive_read_new(); if (!a) @@ -845,11 +851,10 @@ int tar_x(int input_fd, int tree_fd, TarFlags flags) { /* Finalize all inodes we won't need anymore now (go backwards, i.e. close inner fds first) */ while (n_open_inodes > i) { - r = open_inode_finalize(open_inodes + n_open_inodes - 1); + n_open_inodes--; + r = open_inode_finalize(open_inodes + n_open_inodes); if (r < 0) return r; - - n_open_inodes--; } /* And now create all remaining components */ @@ -1604,6 +1609,10 @@ int tar_c(int tree_fd, int output_fd, const char *filename, int hardlink_db_fd, assert(tree_fd >= 0); assert(output_fd >= 0); + r = dlopen_libarchive(LOG_DEBUG); + if (r < 0) + return r; + _cleanup_(archive_write_freep) struct archive *a = sym_archive_write_new(); if (!a) return log_oom();