From: Lennart Poettering Date: Fri, 25 Jul 2025 06:29:32 +0000 (+0200) Subject: importctl: add --user/--system switches X-Git-Tag: v259-rc1~267^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0960b905bc849ff52cae26acc9cadbd33a0c35ec;p=thirdparty%2Fsystemd.git importctl: add --user/--system switches --- diff --git a/src/import/importctl.c b/src/import/importctl.c index 94140469c4b..731c311ffe7 100644 --- a/src/import/importctl.c +++ b/src/import/importctl.c @@ -45,6 +45,7 @@ static ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE; static const char* arg_format = NULL; static sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF; static ImageClass arg_image_class = _IMAGE_CLASS_INVALID; +static RuntimeScope arg_runtime_scope = RUNTIME_SCOPE_SYSTEM; #define PROGRESS_PREFIX "Total:" @@ -1014,6 +1015,8 @@ static int help(int argc, char *argv[], void *userdata) { " --no-ask-password Do not ask for system passwords\n" " -H --host=[USER@]HOST Operate on remote host\n" " -M --machine=CONTAINER Operate on local container\n" + " --system Connect to system machine manager\n" + " --user Connect to user machine manager\n" " --read-only Create read-only image\n" " -q --quiet Suppress output\n" " --json=pretty|short|off Generate JSON output\n" @@ -1055,6 +1058,8 @@ static int parse_argv(int argc, char *argv[]) { ARG_FORMAT, ARG_CLASS, ARG_KEEP_DOWNLOAD, + ARG_SYSTEM, + ARG_USER, }; static const struct option options[] = { @@ -1073,6 +1078,8 @@ static int parse_argv(int argc, char *argv[]) { { "format", required_argument, NULL, ARG_FORMAT }, { "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 }, {} }; @@ -1198,6 +1205,14 @@ static int parse_argv(int argc, char *argv[]) { arg_import_flags_mask |= IMPORT_PULL_KEEP_DOWNLOAD; break; + case ARG_USER: + arg_runtime_scope = RUNTIME_SCOPE_USER; + break; + + case ARG_SYSTEM: + arg_runtime_scope = RUNTIME_SCOPE_SYSTEM; + break; + case '?': return -EINVAL; @@ -1240,9 +1255,9 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, &bus); + r = bus_connect_transport(arg_transport, arg_host, arg_runtime_scope, &bus); if (r < 0) - return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + return bus_log_connect_error(r, arg_transport, arg_runtime_scope); (void) sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);