diff options
author | Shawn Landden <slandden@gmail.com> | 2018-02-09 19:29:27 +0100 |
---|---|---|
committer | Shawn Landden <shawn@git.icu> | 2018-08-06 23:30:53 +0200 |
commit | 19df1528fc3b8b3069496cba3a83107784a1ccd5 (patch) | |
tree | 99355d5de249353591fd0fd08de38492854bd744 /src/stdio-bridge | |
parent | sd-bus rework host handling (diff) | |
download | systemd-19df1528fc3b8b3069496cba3a83107784a1ccd5.tar.xz systemd-19df1528fc3b8b3069496cba3a83107784a1ccd5.zip |
stdio-bridge: support --machine
--machine hasn't been supported since 798c486
Closes: #8116
Diffstat (limited to 'src/stdio-bridge')
-rw-r--r-- | src/stdio-bridge/stdio-bridge.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c index 519a92a094..0034ec8878 100644 --- a/src/stdio-bridge/stdio-bridge.c +++ b/src/stdio-bridge/stdio-bridge.c @@ -10,6 +10,7 @@ #include "sd-bus.h" #include "sd-daemon.h" +#include "alloc-util.h" #include "bus-internal.h" #include "bus-util.h" #include "build.h" @@ -18,7 +19,8 @@ #define DEFAULT_BUS_PATH "unix:path=/run/dbus/system_bus_socket" -const char *arg_bus_path = DEFAULT_BUS_PATH; +static const char *arg_bus_path = DEFAULT_BUS_PATH; +static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static int help(void) { @@ -26,7 +28,8 @@ static int help(void) { "STDIO or socket-activatable proxy to a given DBus endpoint.\n\n" " -h --help Show this help\n" " --version Show package version\n" - " -p --bus-path=PATH Path to the kernel bus (default: %s)\n", + " -p --bus-path=PATH Path to the kernel bus (default: %s)\n" + " -M --machine=MACHINE Name of machine to connect to\n", program_invocation_short_name, DEFAULT_BUS_PATH); return 0; @@ -36,12 +39,14 @@ static int parse_argv(int argc, char *argv[]) { enum { ARG_VERSION = 0x100, + ARG_MACHINE, }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, ARG_VERSION }, { "bus-path", required_argument, NULL, 'p' }, + { "machine", required_argument, NULL, 'M' }, {}, }; @@ -66,8 +71,15 @@ static int parse_argv(int argc, char *argv[]) { case 'p': arg_bus_path = optarg; + break; + case 'M': + arg_bus_path = optarg; + + arg_transport = BUS_TRANSPORT_MACHINE; + + break; default: log_error("Unknown option code %c", c); return -EINVAL; @@ -113,7 +125,10 @@ int main(int argc, char *argv[]) { goto finish; } - r = sd_bus_set_address(a, arg_bus_path); + if (arg_transport == BUS_TRANSPORT_MACHINE) + r = bus_set_address_system_machine(a, arg_bus_path); + else + r = sd_bus_set_address(a, arg_bus_path); if (r < 0) { log_error_errno(r, "Failed to set address to connect to: %m"); goto finish; |