diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:40 +0000 |
commit | fc53809803cd2bc2434e312b19a18fa36776da12 (patch) | |
tree | b4b43bd6538f51965ce32856e9c053d0f90919c8 /src/sysupdate/sysupdate-transfer.c | |
parent | Adding upstream version 255.5. (diff) | |
download | systemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip |
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/sysupdate/sysupdate-transfer.c')
-rw-r--r-- | src/sysupdate/sysupdate-transfer.c | 91 |
1 files changed, 35 insertions, 56 deletions
diff --git a/src/sysupdate/sysupdate-transfer.c b/src/sysupdate/sysupdate-transfer.c index f8f4a15..435c380 100644 --- a/src/sysupdate/sysupdate-transfer.c +++ b/src/sysupdate/sysupdate-transfer.c @@ -4,6 +4,7 @@ #include "alloc-util.h" #include "blockdev-util.h" +#include "build-path.h" #include "chase.h" #include "conf-parser.h" #include "dirent-util.h" @@ -531,6 +532,7 @@ int transfer_read_definition(Transfer *t, const char *path) { "Target path is not a normalized, absolute path: %s", t->target.path); if (strv_isempty(t->target.patterns)) { + log_syntax(NULL, LOG_INFO, path, 1, 0, "Target specification lacks MatchPattern= expression. Assuming same value as in source specification."); strv_free(t->target.patterns); t->target.patterns = strv_copy(t->source.patterns); if (!t->target.patterns) @@ -782,25 +784,23 @@ static void compile_pattern_fields( memcpy(ret->sha256sum, i->metadata.sha256sum, sizeof(ret->sha256sum)); } -static int run_helper( +static int run_callout( const char *name, - const char *path, - const char * const cmdline[]) { + char *cmdline[]) { int r; assert(name); - assert(path); assert(cmdline); + assert(cmdline[0]); r = safe_fork(name, FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGTERM|FORK_LOG|FORK_WAIT, NULL); if (r < 0) return r; if (r == 0) { /* Child */ - - execv(path, (char *const*) cmdline); - log_error_errno(errno, "Failed to execute %s tool: %m", path); + r = invoke_callout_binary(cmdline[0], (char *const*) cmdline); + log_error_errno(r, "Failed to execute %s tool: %m", cmdline[0]); _exit(EXIT_FAILURE); } @@ -907,36 +907,30 @@ int transfer_acquire_instance(Transfer *t, Instance *i) { * importer has some tricks up its sleeve, such as sparse file generation, which we * want to take benefit of, too.) */ - r = run_helper("(sd-import-raw)", - import_binary_path(), - (const char* const[]) { - "systemd-import", + r = run_callout("(sd-import-raw)", + STRV_MAKE( + SYSTEMD_IMPORT_PATH, "raw", "--direct", /* just copy/unpack the specified file, don't do anything else */ arg_sync ? "--sync=yes" : "--sync=no", i->path, - t->temporary_path, - NULL - }); + t->temporary_path)); break; case RESOURCE_PARTITION: /* regular file → partition */ - r = run_helper("(sd-import-raw)", - import_binary_path(), - (const char* const[]) { - "systemd-import", + r = run_callout("(sd-import-raw)", + STRV_MAKE( + SYSTEMD_IMPORT_PATH, "raw", "--direct", /* just copy/unpack the specified file, don't do anything else */ "--offset", offset, "--size-max", max_size, arg_sync ? "--sync=yes" : "--sync=no", i->path, - t->target.path, - NULL - }); + t->target.path)); break; default: @@ -951,18 +945,15 @@ int transfer_acquire_instance(Transfer *t, Instance *i) { /* directory/subvolume → directory/subvolume */ - r = run_helper("(sd-import-fs)", - import_fs_binary_path(), - (const char* const[]) { - "systemd-import-fs", + r = run_callout("(sd-import-fs)", + STRV_MAKE( + SYSTEMD_IMPORT_FS_PATH, "run", "--direct", /* just untar the specified file, don't do anything else */ arg_sync ? "--sync=yes" : "--sync=no", t->target.type == RESOURCE_SUBVOLUME ? "--btrfs-subvol=yes" : "--btrfs-subvol=no", i->path, - t->temporary_path, - NULL - }); + t->temporary_path)); break; case RESOURCE_TAR: @@ -970,18 +961,15 @@ int transfer_acquire_instance(Transfer *t, Instance *i) { /* tar → directory/subvolume */ - r = run_helper("(sd-import-tar)", - import_binary_path(), - (const char* const[]) { - "systemd-import", + r = run_callout("(sd-import-tar)", + STRV_MAKE( + SYSTEMD_IMPORT_PATH, "tar", "--direct", /* just untar the specified file, don't do anything else */ arg_sync ? "--sync=yes" : "--sync=no", t->target.type == RESOURCE_SUBVOLUME ? "--btrfs-subvol=yes" : "--btrfs-subvol=no", i->path, - t->temporary_path, - NULL - }); + t->temporary_path)); break; case RESOURCE_URL_FILE: @@ -992,28 +980,24 @@ int transfer_acquire_instance(Transfer *t, Instance *i) { /* url file → regular file */ - r = run_helper("(sd-pull-raw)", - pull_binary_path(), - (const char* const[]) { - "systemd-pull", + r = run_callout("(sd-pull-raw)", + STRV_MAKE( + SYSTEMD_PULL_PATH, "raw", "--direct", /* just download the specified URL, don't download anything else */ "--verify", digest, /* validate by explicit SHA256 sum */ arg_sync ? "--sync=yes" : "--sync=no", i->path, - t->temporary_path, - NULL - }); + t->temporary_path)); break; case RESOURCE_PARTITION: /* url file → partition */ - r = run_helper("(sd-pull-raw)", - pull_binary_path(), - (const char* const[]) { - "systemd-pull", + r = run_callout("(sd-pull-raw)", + STRV_MAKE( + SYSTEMD_PULL_PATH, "raw", "--direct", /* just download the specified URL, don't download anything else */ "--verify", digest, /* validate by explicit SHA256 sum */ @@ -1021,9 +1005,7 @@ int transfer_acquire_instance(Transfer *t, Instance *i) { "--size-max", max_size, arg_sync ? "--sync=yes" : "--sync=no", i->path, - t->target.path, - NULL - }); + t->target.path)); break; default: @@ -1035,19 +1017,16 @@ int transfer_acquire_instance(Transfer *t, Instance *i) { case RESOURCE_URL_TAR: assert(IN_SET(t->target.type, RESOURCE_DIRECTORY, RESOURCE_SUBVOLUME)); - r = run_helper("(sd-pull-tar)", - pull_binary_path(), - (const char*const[]) { - "systemd-pull", + r = run_callout("(sd-pull-tar)", + STRV_MAKE( + SYSTEMD_PULL_PATH, "tar", "--direct", /* just download the specified URL, don't download anything else */ "--verify", digest, /* validate by explicit SHA256 sum */ t->target.type == RESOURCE_SUBVOLUME ? "--btrfs-subvol=yes" : "--btrfs-subvol=no", arg_sync ? "--sync=yes" : "--sync=no", i->path, - t->temporary_path, - NULL - }); + t->temporary_path)); break; default: |