1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-04-02 00:07:16 +01:00

Call Subscribe on systemd D-Bus connect to enable signals (#6659)

systemd only emits bus signals (including PropertiesChanged) when at
least one client has called Subscribe() on the Manager interface. On
regular HAOS systems, systemd-logind calls Subscribe which enables
signals for all bus clients. However, in environments without
systemd-logind (such as the Supervisor devcontainer with systemd), no
signals are emitted, causing the firewall unit wait to time out.

Explicitly calling Subscribe() has no downsides and makes it clear
that the Supervisor relies on these signals. There is no need to call
Unsubscribe() as systemd automatically tracks clients and stops
emitting signals when all subscribers have disconnected from the bus.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Agner
2026-03-23 14:21:09 +01:00
committed by GitHub
parent 0cb96c36b6
commit c9a2da34c2
3 changed files with 22 additions and 0 deletions

View File

@@ -112,6 +112,12 @@ class Systemd(DBusInterfaceProxy):
"No systemd support on the host. Host control has been disabled."
)
if self.is_connected:
try:
await self.connected_dbus.Manager.call("subscribe")
except DBusError:
_LOGGER.warning("Could not subscribe to systemd signals")
@property
@dbus_property
def startup_time(self) -> float:

View File

@@ -32,6 +32,18 @@ async def test_dbus_systemd_info(dbus_session_bus: MessageBus):
assert systemd.startup_time == 45.304696
async def test_subscribe_on_connect(
systemd_service: SystemdService, dbus_session_bus: MessageBus
):
"""Test that Subscribe is called on connect to enable signal emission."""
systemd_service.Subscribe.calls.clear()
systemd = Systemd()
await systemd.connect(dbus_session_bus)
assert systemd_service.Subscribe.calls == [()]
async def test_reboot(systemd_service: SystemdService, dbus_session_bus: MessageBus):
"""Test reboot."""
systemd_service.Reboot.calls.clear()

View File

@@ -656,6 +656,10 @@ class Systemd(DBusServiceMock):
def PowerOff(self) -> None:
"""Power off host computer."""
@dbus_method()
def Subscribe(self) -> None:
"""Subscribe to systemd signals."""
@dbus_method()
def StartUnit(self, name: "s", mode: "s") -> "o":
"""Start a service unit."""