]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind-dbus: avoid assertion on HandlePowerKey=factory-reset
authorDavid Tardon <dtardon@redhat.com>
Tue, 21 Oct 2025 07:43:22 +0000 (09:43 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 16 Nov 2025 08:00:53 +0000 (17:00 +0900)
The factory-reset action is handled together with the various
sleep/shutdown actions, but its not either one.

Fixes #39385

src/login/logind-dbus.c

index 7211dad9baa7dedda718ecc18431e12feb85d30a..6adcc789b7814a5d427d7206e4bc1d7c06fd2caf 100644 (file)
@@ -1946,6 +1946,11 @@ static int send_prepare_for(Manager *m, const HandleActionData *a, bool _active)
 
         assert(m);
         assert(a);
+
+        /* Only sleep/shutdown actions emit a signal */
+        if (a->inhibit_what < 0)
+                return 0;
+
         assert(IN_SET(a->inhibit_what, INHIBIT_SHUTDOWN, INHIBIT_SLEEP));
 
         /* We need to send both old and new signal for backward compatibility. The newer one allows clients
@@ -2163,6 +2168,7 @@ int bus_manager_shutdown_or_sleep_now_or_later(
 
         delayed =
                 m->inhibit_delay_max > 0 &&
+                a->inhibit_what >= 0 &&
                 manager_is_inhibited(m, a->inhibit_what, NULL, MANAGER_IS_INHIBITED_CHECK_DELAY, UID_INVALID, NULL);
 
         if (delayed)