DBUS_SESSION_BUS_ADDRESS fallback doesn't respect XDG_RUNTIME_DIR
systemd introduced /run
(now standard) but other systems still use /var/run
(e.g., ConsoleKit2, pam_xdg) or /tmp
. dbus@e3f117e7 added --address=unix:runtime=yes
as an alias for --address=unix:path=$XDG_RUNTIME_DIR/bus
. Unfortunately, zbus hardcodes /run
only to fail if DBUS_SESSION_BUS_ADDRESS
is not defined and /run
doesn't exist or not used by dbus-daemon.
$ uname -a
FreeBSD 14.0-CURRENT #0 main-n248639-a3ff18e2715b: Thu Aug 12 03:03:42 UTC 2021 foo@bar:/usr/src/usr/obj/amd64.amd64/sys/MYKERNEL amd64
$ echo $XDG_RUNTIME_DIR
/var/run/user/1234
$ echo ${DBUS_SESSION_BUS_ADDRESS-unset}
unset
$ dbus-daemon --session --fork --address=unix:runtime=yes
$ sockstat -lu | fgrep dbus
foo dbus-daemon 1859 3 stream /var/run/user/1234/bus
messagebus dbus-daemon 1460 3 stream /var/run/dbus/system_bus_socket
$ cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.05s
Running unittests (target/debug/deps/zbus-04c205ad27d3d2d2)
running 31 tests
test address::tests::parse_dbus_addresses ... ok
test azync::proxy::tests::signal_connect ... FAILED
test azync::connection::tests::serial_monotonically_increases ... FAILED
test azync::proxy::tests::signal_stream ... FAILED
test azync::proxy_builder::tests::builder ... FAILED
test azync::handshake::tests::async_handshake ... ok
test fdo::tests::error_from_zerror ... ok
test guid::tests::generate ... ok
test handshake::tests::handshake ... ok
test fdo::tests::signal_connect ... FAILED
test message_header::tests::header ... ok
test object_server::tests::basic_iface ... FAILED
test proxy::tests::signal ... FAILED
test raw::connection::tests::raw_send_receive ... ok
test azync::connection::tests::unix_p2p ... ok
test message::tests::test ... ok
test connection::tests::unix_p2p ... ok
test signal_receiver::tests::multiple_proxy_signals ... FAILED
test tests::basic_connection_async ... FAILED
test tests::issue_121 ... ignored
test fdo::tests::signal_stream ... FAILED
test tests::issue_81 ... ignored
test tests::issue104 ... FAILED
test tests::freedesktop_api ... FAILED
test tests::freedesktop_api_async ... FAILED
test tests::basic_connection ... FAILED
test tests::msg ... ok
test tests::issue_122 ... FAILED
test tests::issue_68 ... FAILED
test tests::fdpass_systemd ... FAILED
test xml::tests::serde ... ok
failures:
---- azync::proxy::tests::signal_connect stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/azync/proxy.rs:962:41
thread 'azync::proxy::tests::signal_connect' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/azync/proxy.rs:960:5
---- azync::connection::tests::serial_monotonically_increases stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/azync/connection.rs:967:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'azync::connection::tests::serial_monotonically_increases' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/azync/connection.rs:961:5
---- azync::proxy::tests::signal_stream stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/azync/proxy.rs:882:40
thread 'azync::proxy::tests::signal_stream' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/azync/proxy.rs:880:5
---- azync::proxy_builder::tests::builder stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/azync/proxy_builder.rs:161:48
thread 'azync::proxy_builder::tests::builder' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/azync/proxy_builder.rs:155:5
---- fdo::tests::signal_connect stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/fdo.rs:700:49
thread 'fdo::tests::signal_connect' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/fdo.rs:696:5
---- object_server::tests::basic_iface stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/object_server.rs:1036:42
thread 'object_server::tests::basic_iface' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/object_server.rs:1032:5
---- proxy::tests::signal stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/proxy.rs:354:42
thread 'proxy::tests::signal' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/proxy.rs:350:5
---- signal_receiver::tests::multiple_proxy_signals stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/signal_receiver.rs:229:42
thread 'signal_receiver::tests::multiple_proxy_signals' panicked at 'timeout: the function call took 1 ms. Max time 15000 ms', zbus/src/signal_receiver.rs:208:5
---- tests::basic_connection_async stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/lib.rs:298:53
thread 'tests::basic_connection_async' panicked at 'timeout: the function call took 1 ms. Max time 15000 ms', zbus/src/lib.rs:296:5
---- fdo::tests::signal_stream stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/fdo.rs:779:62
thread 'fdo::tests::signal_stream' panicked at 'timeout: the function call took 2 ms. Max time 15000 ms', zbus/src/fdo.rs:764:5
---- tests::issue104 stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/lib.rs:603:42
thread 'tests::issue104' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/lib.rs:590:5
---- tests::freedesktop_api stdout ----
error: I/O error: No such file or directory (os error 2)
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/lib.rs:358:14
thread 'tests::freedesktop_api' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/lib.rs:350:5
---- tests::freedesktop_api_async stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/lib.rs:452:52
thread 'tests::freedesktop_api_async' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/lib.rs:450:5
---- tests::basic_connection stdout ----
error: I/O error: No such file or directory (os error 2)
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/lib.rs:279:14
thread 'tests::basic_connection' panicked at 'timeout: the function call took 1 ms. Max time 15000 ms', zbus/src/lib.rs:271:5
---- tests::issue_122 stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/lib.rs:694:42
thread 'tests::issue_122' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/lib.rs:691:5
---- tests::issue_68 stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', zbus/src/lib.rs:562:42
thread 'tests::issue_68' panicked at 'timeout: the function call took 0 ms. Max time 15000 ms', zbus/src/lib.rs:555:5
---- tests::fdpass_systemd stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: MethodError(OwnedInterfaceName(InterfaceName(Str("org.freedesktop.DBus.Error.ServiceUnknown"))), Some("The name org.freedesktop.systemd1 was not provided by any .service files"), Msg { type: Error, sender: UniqueName(Str("org.freedesktop.DBus")), reply-serial: 2, body: Signature: [
s (115),
] })', zbus/src/lib.rs:335:14
thread 'tests::fdpass_systemd' panicked at 'timeout: the function call took 2 ms. Max time 15000 ms', zbus/src/lib.rs:323:5
failures:
azync::connection::tests::serial_monotonically_increases
azync::proxy::tests::signal_connect
azync::proxy::tests::signal_stream
azync::proxy_builder::tests::builder
fdo::tests::signal_connect
fdo::tests::signal_stream
object_server::tests::basic_iface
proxy::tests::signal
signal_receiver::tests::multiple_proxy_signals
tests::basic_connection
tests::basic_connection_async
tests::fdpass_systemd
tests::freedesktop_api
tests::freedesktop_api_async
tests::issue104
tests::issue_122
tests::issue_68
test result: FAILED. 12 passed; 17 failed; 2 ignored; 0 measured; 0 filtered out; finished in 0.01s
error: test failed, to rerun pass '-p zbus --lib'
$ DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.05s
Running unittests (target/debug/deps/zbus-04c205ad27d3d2d2)
running 31 tests
test address::tests::parse_dbus_addresses ... ok
test azync::handshake::tests::async_handshake ... ok
test fdo::tests::error_from_zerror ... ok
test azync::connection::tests::serial_monotonically_increases ... ok
test azync::connection::tests::unix_p2p ... ok
test azync::proxy_builder::tests::builder ... ok
test guid::tests::generate ... ok
test connection::tests::unix_p2p ... ok
test message_header::tests::header ... ok
test handshake::tests::handshake ... ok
test raw::connection::tests::raw_send_receive ... ok
test message::tests::test ... ok
test azync::proxy::tests::signal_stream ... ok
test tests::basic_connection ... ok
test azync::proxy::tests::signal_connect ... ok
test tests::fdpass_systemd ... FAILED
test tests::basic_connection_async ... ok
test fdo::tests::signal_connect ... ok
test tests::issue_121 ... ignored
test proxy::tests::signal ... ok
test tests::freedesktop_api ... ok
test tests::issue_81 ... ignored
test tests::msg ... ok
test tests::freedesktop_api_async ... ok
test xml::tests::serde ... ok
test tests::issue104 ... ok
test tests::issue_68 ... ok
test fdo::tests::signal_stream ... ok
test signal_receiver::tests::multiple_proxy_signals ... ok
test object_server::tests::basic_iface ... ok
test tests::issue_122 ... ok
failures:
---- tests::fdpass_systemd stdout ----
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: MethodError(OwnedInterfaceName(InterfaceName(Str("org.freedesktop.DBus.Error.ServiceUnknown"))), Some("The name org.freedesktop.systemd1 was not provided by any .service files"), Msg { type: Error, sender: UniqueName(Str("org.freedesktop.DBus")), reply-serial: 2, body: Signature: [
s (115),
] })', zbus/src/lib.rs:335:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tests::fdpass_systemd' panicked at 'timeout: the function call took 2 ms. Max time 15000 ms', zbus/src/lib.rs:323:5
failures:
tests::fdpass_systemd
test result: FAILED. 28 passed; 1 failed; 2 ignored; 0 measured; 0 filtered out; finished in 0.12s
error: test failed, to rerun pass '-p zbus --lib'