From b7bb58ef70b0c876941a1c31ed4e2f5f1dc5ed0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 17 Jan 2022 11:43:48 +0100 Subject: [PATCH 1/4] man: enhance the description of systemd-stdio-bridge I hope that this fixes the comment https://github.com/systemd/systemd/pull/22141#issuecomment-1013960371 > As someone who doesn't know what this prog does The listing in the man page is sorted according to logical use: all the options setting the address are now together. --- man/systemd-stdio-bridge.xml | 26 ++++++++++++++++++++------ src/stdio-bridge/stdio-bridge.c | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/man/systemd-stdio-bridge.xml b/man/systemd-stdio-bridge.xml index bef61cb7cfe..002a91b1299 100644 --- a/man/systemd-stdio-bridge.xml +++ b/man/systemd-stdio-bridge.xml @@ -31,9 +31,23 @@ Description - systemd-stdio-bridge may be used as a STDIO or socket-activatable - proxy to a given D-Bus endpoint. + systemd-stdio-bridge implements a proxy for a D-Bus endpoint. It expects to + receive an open connection to a bus when started, and will also connect to a (different) bus as a + client. It will then act as a server on the first connection, and forward messages between the two + busses. This program is suitable for socket activation: the first connection may be a pipe or a socket + and must be passed as either standard input, or as an open file descriptor according to the protocol + described in + sd_listen_fds3. The + second connection will be made by default to the local system bus, but this can be influenced by the + , , , and + options described below. + sd-bus3 uses + systemd-stdio-bridge to forward D-Bus connections over + ssh1, + or to connect to the bus of a different user, see + sd_bus_set_address3. + @@ -42,6 +56,10 @@ The following options are understood: + + + + @@ -52,9 +70,6 @@ - - - @@ -70,7 +85,6 @@ dbus-daemon1, dbus-broker1, D-Bus, - sd-bus3, systemd1 diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c index b45f7912cbe..5d4ffa5e323 100644 --- a/src/stdio-bridge/stdio-bridge.c +++ b/src/stdio-bridge/stdio-bridge.c @@ -28,7 +28,7 @@ static bool arg_user = false; static int help(void) { printf("%s [OPTIONS...]\n\n" - "STDIO or socket-activatable proxy to a given DBus endpoint.\n\n" + "Forward messages between two D-Bus busses via a pipe or socket.\n\n" " -h --help Show this help\n" " --version Show package version\n" " -p --bus-path=PATH Path to the bus address (default: %s)\n" From a80f17844ef1d7c622d17cb4b41eb337d438fffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 17 Jan 2022 11:44:44 +0100 Subject: [PATCH 2/4] stdio-bridge: make the error more straightforward --- src/stdio-bridge/stdio-bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c index 5d4ffa5e323..1a2099a8d1b 100644 --- a/src/stdio-bridge/stdio-bridge.c +++ b/src/stdio-bridge/stdio-bridge.c @@ -125,7 +125,7 @@ static int run(int argc, char *argv[]) { in_fd = SD_LISTEN_FDS_START; out_fd = SD_LISTEN_FDS_START; } else - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Illegal number of file descriptors passed."); + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "More than one file descriptor was passed."); is_unix = sd_is_socket(in_fd, AF_UNIX, 0, 0) > 0 && From 0d8930fd6d0416fbe1c14958a47c1d768e156aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 17 Jan 2022 11:44:59 +0100 Subject: [PATCH 3/4] stdio-bridge: trim whitespace and braces --- src/stdio-bridge/stdio-bridge.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c index 1a2099a8d1b..33701e775ea 100644 --- a/src/stdio-bridge/stdio-bridge.c +++ b/src/stdio-bridge/stdio-bridge.c @@ -26,7 +26,6 @@ static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static bool arg_user = false; static int help(void) { - printf("%s [OPTIONS...]\n\n" "Forward messages between two D-Bus busses via a pipe or socket.\n\n" " -h --help Show this help\n" @@ -41,7 +40,6 @@ static int help(void) { } static int parse_argv(int argc, char *argv[]) { - enum { ARG_VERSION = 0x100, ARG_MACHINE, @@ -64,7 +62,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "hp:M:", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "hp:M:", options, NULL)) >= 0) switch (c) { @@ -98,7 +96,6 @@ static int parse_argv(int argc, char *argv[]) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown option code %c", c); } - } return 1; } From 2979c8b7fc86c21b4a2536820a7e066f28683b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 17 Jan 2022 11:49:41 +0100 Subject: [PATCH 4/4] meson: drop unused SYSTEMD_STDIO_BRIDGE_BINARY_PATH The whole point of systemd-stdio-bridge is to be executed on "foreign" systems where the path might be different, so we use $PATH to find the binary everywhere. --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index 910862ed367..312439015fd 100644 --- a/meson.build +++ b/meson.build @@ -250,7 +250,6 @@ conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'lang conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs') conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull') conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown') -conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', bindir / 'systemd-stdio-bridge') conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata') conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent') conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')