Skip to content

Expose sd_bus_open_address or sd_bus_set_address for custom D-Bus transports #120

Open

Description

@dingo9

python-sdbus currently exposes sd_bus_open(), sd_bus_open_user(),
sd_bus_open_system_remote(host), and machine helpers, but there does not
appear to be a way to open an explicit D-Bus address from Python.

This makes it difficult to use libsystemd-supported transports such as:

unixexec:path=/usr/bin/ssh,argv1=host,argv2=systemd-stdio-bridge,argv3=--user

Use case: connect to a remote user bus over SSH via
systemd-stdio-bridge --user. This works if DBUS_SESSION_BUS_ADDRESS is set
before calling sdbus.sd_bus_open_user(), but mutating process-global
environment variables is awkward and unsafe when opening multiple clients
concurrently.

The underlying libsystemd APIs support this through
sd_bus_new() + sd_bus_set_address() + sd_bus_start() (and related
sd_bus_set_fd() / sd_bus_set_exec() APIs), but python-sdbus does not seem to
expose an equivalent API.

Would you consider adding an API such as:

sdbus.sd_bus_open_address(address: str) -> sdbus.SdBus

or exposing SdBus.set_address(address) before SdBus.start()?

Example desired usage:

address = (
    "unixexec:path=/usr/bin/ssh,"
    "argv1=my-host,"
    "argv2=systemd-stdio-bridge,"
    "argv3=--user"
)
bus = sdbus.sd_bus_open_address(address)

This would avoid relying on DBUS_SESSION_BUS_ADDRESS and would make custom
D-Bus transports usable from Python.

Activity

  1. igo95862 commented on Jun 8, 2026

    @igo95862
    Collaborator

    Definitely possible. I will look in to including this in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions