From: Lennart Poettering Date: Mon, 18 Aug 2025 07:12:27 +0000 (+0200) Subject: importd: teach all backends --system/--user mode X-Git-Tag: v259-rc1~267^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b76a76ac15fa3a609982c298e58ee756a6b21f46;p=thirdparty%2Fsystemd.git importd: teach all backends --system/--user mode The runtime scope logic is internally already in place, let's expose this via getopt() command line too. This way importd later can propagate the invocation scope down to the backends. --- diff --git a/src/import/export.c b/src/import/export.c index d891ca18168..bbea5b0343b 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -207,7 +207,9 @@ static int help(int argc, char *argv[], void *userdata) { " --version Show package version\n" " --format=FORMAT Select format\n" " --class=CLASS Select image class (machine, sysext, confext,\n" - " portable)\n", + " portable)\n" + " --system Operate in per-system mode\n" + " --user Operate in per-user mode\n", program_invocation_short_name, ansi_underline(), ansi_normal(), @@ -223,6 +225,8 @@ static int parse_argv(int argc, char *argv[]) { ARG_VERSION = 0x100, ARG_FORMAT, ARG_CLASS, + ARG_SYSTEM, + ARG_USER, }; static const struct option options[] = { @@ -230,6 +234,8 @@ static int parse_argv(int argc, char *argv[]) { { "version", no_argument, NULL, ARG_VERSION }, { "format", required_argument, NULL, ARG_FORMAT }, { "class", required_argument, NULL, ARG_CLASS }, + { "system", no_argument, NULL, ARG_SYSTEM }, + { "user", no_argument, NULL, ARG_USER }, {} }; @@ -262,6 +268,14 @@ static int parse_argv(int argc, char *argv[]) { break; + case ARG_SYSTEM: + arg_runtime_scope = RUNTIME_SCOPE_SYSTEM; + break; + + case ARG_USER: + arg_runtime_scope = RUNTIME_SCOPE_USER; + break; + case '?': return -EINVAL; diff --git a/src/import/import-fs.c b/src/import/import-fs.c index 783b0461ef4..342c024d56f 100644 --- a/src/import/import-fs.c +++ b/src/import/import-fs.c @@ -280,7 +280,9 @@ static int help(int argc, char *argv[], void *userdata) { " subvolume\n" " --sync=BOOL Controls whether to sync() before completing\n" " --class=CLASS Select image class (machine, sysext, confext,\n" - " portable)\n", + " portable)\n" + " --system Operate in per-system mode\n" + " --user Operate in per-user mode\n", program_invocation_short_name, ansi_underline(), ansi_normal(), @@ -302,6 +304,8 @@ static int parse_argv(int argc, char *argv[]) { ARG_BTRFS_QUOTA, ARG_SYNC, ARG_CLASS, + ARG_SYSTEM, + ARG_USER, }; static const struct option options[] = { @@ -315,6 +319,8 @@ static int parse_argv(int argc, char *argv[]) { { "btrfs-quota", required_argument, NULL, ARG_BTRFS_QUOTA }, { "sync", required_argument, NULL, ARG_SYNC }, { "class", required_argument, NULL, ARG_CLASS }, + { "system", no_argument, NULL, ARG_SYSTEM }, + { "user", no_argument, NULL, ARG_USER }, {} }; @@ -377,6 +383,14 @@ static int parse_argv(int argc, char *argv[]) { break; + case ARG_SYSTEM: + arg_runtime_scope = RUNTIME_SCOPE_SYSTEM; + break; + + case ARG_USER: + arg_runtime_scope = RUNTIME_SCOPE_USER; + break; + case '?': return -EINVAL; diff --git a/src/import/import.c b/src/import/import.c index 9b458dff9f9..f41a42f7e6b 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -290,7 +290,9 @@ static int help(int argc, char *argv[], void *userdata) { " --offset=BYTES Offset to seek to in destination\n" " --size-max=BYTES Maximum number of bytes to write to destination\n" " --class=CLASS Select image class (machine, sysext, confext,\n" - " portable)\n", + " portable)\n" + " --system Operate in per-system mode\n" + " --user Operate in per-user mode\n", program_invocation_short_name, ansi_underline(), ansi_normal(), @@ -315,6 +317,8 @@ static int parse_argv(int argc, char *argv[]) { ARG_OFFSET, ARG_SIZE_MAX, ARG_CLASS, + ARG_SYSTEM, + ARG_USER, }; static const struct option options[] = { @@ -331,6 +335,8 @@ static int parse_argv(int argc, char *argv[]) { { "offset", required_argument, NULL, ARG_OFFSET }, { "size-max", required_argument, NULL, ARG_SIZE_MAX }, { "class", required_argument, NULL, ARG_CLASS }, + { "system", no_argument, NULL, ARG_SYSTEM }, + { "user", no_argument, NULL, ARG_USER }, {} }; @@ -430,6 +436,14 @@ static int parse_argv(int argc, char *argv[]) { break; + case ARG_SYSTEM: + arg_runtime_scope = RUNTIME_SCOPE_SYSTEM; + break; + + case ARG_USER: + arg_runtime_scope = RUNTIME_SCOPE_USER; + break; + case '?': return -EINVAL; diff --git a/src/import/pull.c b/src/import/pull.c index 41193e43971..9c915536d8a 100644 --- a/src/import/pull.c +++ b/src/import/pull.c @@ -275,7 +275,9 @@ static int help(int argc, char *argv[], void *userdata) { " --class=CLASS Select image class (machine, sysext, confext,\n" " portable)\n" " --keep-download=BOOL Keep a copy pristine copy of the downloaded file\n" - " around\n", + " around\n" + " --system Operate in per-system mode\n" + " --user Operate in per-user mode\n", program_invocation_short_name, ansi_underline(), ansi_normal(), @@ -306,6 +308,8 @@ static int parse_argv(int argc, char *argv[]) { ARG_SIZE_MAX, ARG_CLASS, ARG_KEEP_DOWNLOAD, + ARG_SYSTEM, + ARG_USER, }; static const struct option options[] = { @@ -328,6 +332,8 @@ static int parse_argv(int argc, char *argv[]) { { "size-max", required_argument, NULL, ARG_SIZE_MAX }, { "class", required_argument, NULL, ARG_CLASS }, { "keep-download", required_argument, NULL, ARG_KEEP_DOWNLOAD }, + { "system", no_argument, NULL, ARG_SYSTEM }, + { "user", no_argument, NULL, ARG_USER }, {} }; @@ -508,6 +514,14 @@ static int parse_argv(int argc, char *argv[]) { auto_keep_download = false; break; + case ARG_SYSTEM: + arg_runtime_scope = RUNTIME_SCOPE_SYSTEM; + break; + + case ARG_USER: + arg_runtime_scope = RUNTIME_SCOPE_USER; + break; + case '?': return -EINVAL;