diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-03-10 09:47:10 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-03-10 09:47:39 +0100 |
commit | 4870133bfaaf97189a970a29bf47e0e38fa721aa (patch) | |
tree | d2fa9a5699a8b4c948179afabf3da2f9da322ce5 /src/mount | |
parent | socket-util: fix socket_get_family() (diff) | |
download | systemd-4870133bfaaf97189a970a29bf47e0e38fa721aa.tar.xz systemd-4870133bfaaf97189a970a29bf47e0e38fa721aa.zip |
basic: add RuntimeScope enum
In various tools and services we have a per-system and per-user concept.
So far we sometimes used a boolean indicating whether we are in system
mode, or a reversed boolean indicating whether we are in user mode, or
the LookupScope enum used by the lookup path logic.
Let's address that, in introduce a common enum for this, we can use all
across the board.
This is mostly just search/replace, no actual code changes.
Diffstat (limited to 'src/mount')
-rw-r--r-- | src/mount/mount-tool.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index ea6d528189..5cb1cd5526 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -54,7 +54,7 @@ static bool arg_full = false; static bool arg_ask_password = true; static bool arg_quiet = false; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; -static bool arg_user = false; +static RuntimeScope arg_runtime_scope = RUNTIME_SCOPE_SYSTEM; static const char *arg_host = NULL; static bool arg_discover = false; static char *arg_mount_what = NULL; @@ -223,11 +223,11 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_USER: - arg_user = true; + arg_runtime_scope = RUNTIME_SCOPE_USER; break; case ARG_SYSTEM: - arg_user = false; + arg_runtime_scope = RUNTIME_SCOPE_SYSTEM; break; case 'H': @@ -334,12 +334,13 @@ static int parse_argv(int argc, char *argv[]) { assert_not_reached(); } - if (arg_user) + if (arg_runtime_scope == RUNTIME_SCOPE_USER) { arg_ask_password = false; - if (arg_user && arg_transport != BUS_TRANSPORT_LOCAL) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Execution in user context is not supported on non-local systems."); + if (arg_transport != BUS_TRANSPORT_LOCAL) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Execution in user context is not supported on non-local systems."); + } if (arg_action == ACTION_LIST) { if (optind < argc) @@ -1459,7 +1460,7 @@ static int run(int argc, char* argv[]) { if (arg_action == ACTION_LIST) return list_devices(); - r = bus_connect_transport_systemd(arg_transport, arg_host, arg_user, &bus); + r = bus_connect_transport_systemd(arg_transport, arg_host, arg_runtime_scope, &bus); if (r < 0) return bus_log_connect_error(r, arg_transport); |