diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
commit | 78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch) | |
tree | f515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/busctl/busctl.c | |
parent | Adding debian version 255.5-1. (diff) | |
download | systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/busctl/busctl.c')
-rw-r--r-- | src/busctl/busctl.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 01cb896..8db9076 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -13,6 +13,7 @@ #include "bus-type.h" #include "bus-util.h" #include "busctl-introspect.h" +#include "capsule-util.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" @@ -72,6 +73,7 @@ static int json_transform_message(sd_bus_message *m, JsonVariant **ret); static int acquire_bus(bool set_monitor, sd_bus **ret) { _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL; + _cleanup_close_ int pin_fd = -EBADF; int r; r = sd_bus_new(&bus); @@ -138,10 +140,13 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) { r = bus_set_address_machine(bus, arg_runtime_scope, arg_host); break; + case BUS_TRANSPORT_CAPSULE: + r = bus_set_address_capsule_bus(bus, arg_host, &pin_fd); + break; + default: assert_not_reached(); } - if (r < 0) return bus_log_address_error(r, arg_transport); @@ -1366,10 +1371,10 @@ static int verb_monitor(int argc, char **argv, void *userdata) { static int verb_capture(int argc, char **argv, void *userdata) { _cleanup_free_ char *osname = NULL; static const char info[] = - "busctl (systemd) " STRINGIFY(PROJECT_VERSION) " (Git " GIT_VERSION ")"; + "busctl (systemd) " PROJECT_VERSION_FULL " (Git " GIT_VERSION ")"; int r; - if (isatty(fileno(stdout)) > 0) + if (isatty(STDOUT_FILENO)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Refusing to write message data to console, please redirect output to a file."); @@ -2385,6 +2390,7 @@ static int parse_argv(int argc, char *argv[]) { { "match", required_argument, NULL, ARG_MATCH }, { "host", required_argument, NULL, 'H' }, { "machine", required_argument, NULL, 'M' }, + { "capsule", required_argument, NULL, 'C' }, { "size", required_argument, NULL, ARG_SIZE }, { "list", no_argument, NULL, ARG_LIST }, { "quiet", no_argument, NULL, 'q' }, @@ -2406,7 +2412,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "hH:M:qjl", options, NULL)) >= 0) + while ((c = getopt_long(argc, argv, "hH:M:C:J:qjl", options, NULL)) >= 0) switch (c) { @@ -2490,6 +2496,17 @@ static int parse_argv(int argc, char *argv[]) { arg_host = optarg; break; + case 'C': + r = capsule_name_is_valid(optarg); + if (r < 0) + return log_error_errno(r, "Unable to validate capsule name '%s': %m", optarg); + if (r == 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid capsule name: %s", optarg); + + arg_host = optarg; + arg_transport = BUS_TRANSPORT_CAPSULE; + break; + case 'q': arg_quiet = true; break; |