From 8d67580cc2bb8a87f57d4a8bdfc2069b0707e3bb Mon Sep 17 00:00:00 2001 From: Ron Waldon-Howe Date: Tue, 3 Dec 2024 21:06:51 +1100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Implement=20unix:dir=20and=20unix:t?= =?UTF-8?q?mpdir=20for=20`--address`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to https://dbus.freedesktop.org/doc/dbus-specification.html , for unix:tmpdir, the service _may_ create an abstract socket, but is not required to do so, thus our implementation is the same as our unix:dir, as suggested by the specification --- src/bus/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bus/mod.rs b/src/bus/mod.rs index 1ca1c80..b8f6280 100644 --- a/src/bus/mod.rs +++ b/src/bus/mod.rs @@ -164,8 +164,16 @@ impl Bus { addr } - UnixSocket::Dir(_) => bail!("`dir` transport is not supported (yet)."), - UnixSocket::TmpDir(_) => bail!("`tmpdir` transport is not supported (yet)."), + UnixSocket::Dir(dir) | UnixSocket::TmpDir(dir) => { + let path = dir.join(format!("dbus-{}", fastrand::u32(1_000_000..u32::MAX))); + let addr = SocketAddr::from_pathname(&path)?; + info!( + "Listening on UNIX socket file `{}`.", + path.to_string_lossy() + ); + + addr + } _ => bail!("Unsupported address."), }; let std_listener =