From: Daan De Meyer Date: Sun, 2 Nov 2025 13:17:36 +0000 (+0100) Subject: sd-bus: Pass --user and --quiet to systemd-stdio-bridge if local X-Git-Tag: v259-rc1~69^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F39718%2Fhead;p=thirdparty%2Fsystemd.git sd-bus: Pass --user and --quiet to systemd-stdio-bridge if local If we're switching users but not entering a container, then we can assume that new switches for systemd-stdio-bridge are available, so make use of them in that case. --- diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 6908e529d69..5fab814abce 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -1623,14 +1623,20 @@ int bus_set_address_machine(sd_bus *b, RuntimeScope runtime_scope, const char *m if (!a) return -ENOMEM; + bool local = !eh || streq(eh, ".host"); + + /* Ideally we'd always use the "--user" and "--quiet" switches to systemd-stdio-bridge here, + * but they're only available in recent systemd versions, meaning we can only use them if + * we're not connecting to a container. Using the "-p" switch with an explicit path is a + * working alternative for "--user", and is compatible with older versions, hence that's what + * we use when connecting to a container. */ + if (runtime_scope == RUNTIME_SCOPE_USER) { - /* Ideally we'd use the "--user" switch to systemd-stdio-bridge here, but it's only - * available in recent systemd versions. Using the "-p" switch with the explicit path - * is a working alternative, and is compatible with older versions, hence that's what - * we use here. */ - if (!strextend(&a, ",argv7=-punix:path%3d%24%7bXDG_RUNTIME_DIR%7d/bus")) + if (!strextend(&a, local ? ",argv7=--user,argv8=--quiet" : ",argv7=-punix:path%3d%24%7bXDG_RUNTIME_DIR%7d/bus")) + return -ENOMEM; + } else if (local) + if (!strextend(&a, ",argv7=--quiet")) return -ENOMEM; - } } else { _cleanup_free_ char *e = NULL;