tar-util: several fixlets for tar_x/tar_c() (#43522)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -17,6 +17,7 @@ executables += [
|
||||
'qcow2-util.c',
|
||||
),
|
||||
'dependencies' : [
|
||||
libacl_cflags,
|
||||
libarchive_cflags,
|
||||
libselinux_cflags,
|
||||
],
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+16
-7
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user