summaryrefslogtreecommitdiff
path: root/src/busctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-03-10 09:47:10 +0100
committerLennart Poettering <lennart@poettering.net>2023-03-10 09:47:39 +0100
commit4870133bfaaf97189a970a29bf47e0e38fa721aa (patch)
treed2fa9a5699a8b4c948179afabf3da2f9da322ce5 /src/busctl
parent5f64d2bf332371bdfdcb91b588e57d4c0c20428f (diff)
downloadsystemd-4870133bfaaf97189a970a29bf47e0e38fa721aa.tar.gz
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/busctl')
-rw-r--r--src/busctl/busctl.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index 87becdbc7e..e176710dfa 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -27,6 +27,7 @@
#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"
+#include "runtime-scope.h"
#include "set.h"
#include "sort-util.h"
#include "strv.h"
@@ -47,7 +48,7 @@ static bool arg_show_machine = false;
static char **arg_matches = NULL;
static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
static const char *arg_host = NULL;
-static bool arg_user = false;
+static RuntimeScope arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
static size_t arg_snaplen = 4096;
static bool arg_list = false;
static bool arg_quiet = false;
@@ -109,10 +110,21 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) {
switch (arg_transport) {
case BUS_TRANSPORT_LOCAL:
- if (arg_user)
+
+ switch (arg_runtime_scope) {
+
+ case RUNTIME_SCOPE_USER:
r = bus_set_address_user(bus);
- else
+ break;
+
+ case RUNTIME_SCOPE_SYSTEM:
r = bus_set_address_system(bus);
+ break;
+
+ default:
+ assert_not_reached();
+ }
+
break;
case BUS_TRANSPORT_REMOTE:
@@ -120,7 +132,7 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) {
break;
case BUS_TRANSPORT_MACHINE:
- r = bus_set_address_machine(bus, arg_user, arg_host);
+ r = bus_set_address_machine(bus, arg_runtime_scope, arg_host);
break;
default:
@@ -2405,11 +2417,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 ARG_ADDRESS: