dbus: honor the shutdown timeout in the reboot family

initctl -t N reboot arms an emergency bypass timer over the legacy
socket, but the bus methods took no argument, so the timeout was
silently dropped whenever D-Bus was up.

Reboot, Halt, and Poweroff now take a timeout in seconds, 0 for
none, armed via the same shutdown_bypass() the legacy path uses.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-08-16 22:03:38 +02:00
1 parent 8b61aaea1a
commit 62b55d5b43
6 files changed
+55 -24

No files matched your search

+16 -3
View File
@@ -1067,13 +1067,26 @@ static int do_cmd(int cmd)
#ifdef HAVE_DBUS
static int do_reboot_dbus(const char *method)
{
int rc = try_dbus_manager(method, "", NULL);
link_client_t *c;
int rc;
if (rc == 0) {
c = link_client_open(FINIT_BUS_SOCKET);
if (!c)
return -1; /* fall back to legacy transport */
/* Timeout in seconds arms the emergency shutdown bypass, 0 = none */
rc = link_client_call_v(c, "/org/finit/manager",
"org.finit.Manager1", method,
"u", (uint32_t)timeout);
if (rc == LINK_CALL_ERROR)
map_dbus_err(c, method, NULL); /* exits */
link_client_close(c);
if (rc == LINK_CALL_OK) {
sleep(5); /* match legacy: wait for finit to shut down */
return 0;
}
return rc; /* 1 = error, -1 = fall back */
return -1; /* fall back */
}
#endif