stdio-bridge: support --machine
--machine hasn't been supported since 798c486
Closes: #8116
This commit is contained in:
parent
b85b4a70d7
commit
19df1528fc
|
@ -10,6 +10,7 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
#include "sd-daemon.h"
|
#include "sd-daemon.h"
|
||||||
|
|
||||||
|
#include "alloc-util.h"
|
||||||
#include "bus-internal.h"
|
#include "bus-internal.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
|
@ -18,7 +19,8 @@
|
||||||
|
|
||||||
#define DEFAULT_BUS_PATH "unix:path=/run/dbus/system_bus_socket"
|
#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) {
|
static int help(void) {
|
||||||
|
|
||||||
|
@ -26,7 +28,8 @@ static int help(void) {
|
||||||
"STDIO or socket-activatable proxy to a given DBus endpoint.\n\n"
|
"STDIO or socket-activatable proxy to a given DBus endpoint.\n\n"
|
||||||
" -h --help Show this help\n"
|
" -h --help Show this help\n"
|
||||||
" --version Show package version\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);
|
program_invocation_short_name, DEFAULT_BUS_PATH);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -36,12 +39,14 @@ static int parse_argv(int argc, char *argv[]) {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ARG_VERSION = 0x100,
|
ARG_VERSION = 0x100,
|
||||||
|
ARG_MACHINE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ "version", no_argument, NULL, ARG_VERSION },
|
{ "version", no_argument, NULL, ARG_VERSION },
|
||||||
{ "bus-path", required_argument, NULL, 'p' },
|
{ "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':
|
case 'p':
|
||||||
arg_bus_path = optarg;
|
arg_bus_path = optarg;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'M':
|
||||||
|
arg_bus_path = optarg;
|
||||||
|
|
||||||
|
arg_transport = BUS_TRANSPORT_MACHINE;
|
||||||
|
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
log_error("Unknown option code %c", c);
|
log_error("Unknown option code %c", c);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -113,7 +125,10 @@ int main(int argc, char *argv[]) {
|
||||||
goto finish;
|
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) {
|
if (r < 0) {
|
||||||
log_error_errno(r, "Failed to set address to connect to: %m");
|
log_error_errno(r, "Failed to set address to connect to: %m");
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
Loading…
Reference in New Issue