]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
stdio-bridge: support --machine
authorShawn Landden <slandden@gmail.com>
Fri, 9 Feb 2018 18:29:27 +0000 (10:29 -0800)
committerShawn Landden <shawn@git.icu>
Mon, 6 Aug 2018 21:30:53 +0000 (14:30 -0700)
--machine hasn't been supported since 798c486
Closes: #8116
src/stdio-bridge/stdio-bridge.c

index 519a92a09449bc247823676cd9eb5037f9edb3d1..0034ec8878f418205411d22c0725d5df1939d7bb 100644 (file)
@@ -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;