chiark / gitweb /
Prep v239: Fix and add debug messages to method_can_shutdown_or_sleep()
[elogind.git] / src / login / logind-dbus.c
index 63a206ce2c113d8783ce3f3d7adf587e3d734f94..9d70928691eda62c0c8f8772964c8c08a59799d4 100644 (file)
@@ -2367,8 +2367,9 @@ static int method_can_shutdown_or_sleep(
         blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid, NULL);
 
         handle = handle_action_from_string(sleep_verb);
-#if 0 /// elogind uses its own variant, which can use the handle directly.
+
         if (handle >= 0) {
+#if 0 /// elogind uses its own variant, which can use the handle directly.
                 const char *target;
 
                 target = manager_target_for_action(handle);
@@ -2384,12 +2385,12 @@ static int method_can_shutdown_or_sleep(
                                 goto finish;
                         }
                 }
-#else
-                if ( (handle <= HANDLE_IGNORE) || (handle >= _HANDLE_ACTION_MAX) ) {
-                        result = "no";
-                        goto finish;
         }
+#else
+                log_debug_elogind("CanShutDownOrSleep: %s [%d] %s blocked",
+                                  sleep_verb, handle, blocked ? "is" : "not");
 #endif // 0
+        }
 
         if (multiple_sessions) {
                 r = bus_test_polkit(message, CAP_SYS_BOOT, action_multiple_sessions, NULL, UID_INVALID, &challenge, error);
@@ -2402,6 +2403,8 @@ static int method_can_shutdown_or_sleep(
                         result = "challenge";
                 else
                         result = "no";
+                log_debug_elogind("CanShutDownOrSleep: multiple_sessions: %s = %s",
+                                  action_multiple_sessions, result);
         }
 
         if (blocked) {
@@ -2415,6 +2418,8 @@ static int method_can_shutdown_or_sleep(
                         result = "challenge";
                 else
                         result = "no";
+                log_debug_elogind("CanShutDownOrSleep: blocked          : %s = %s",
+                                  action_ignore_inhibit, result);
         }
 
         if (!multiple_sessions && !blocked) {
@@ -2431,10 +2436,11 @@ static int method_can_shutdown_or_sleep(
                         result = "challenge";
                 else
                         result = "no";
+                log_debug_elogind("CanShutDownOrSleep: regular          : %s = %s",
+                                  action, result);
         }
 
  finish:
-
         return sd_bus_reply_method_return(message, "s", result);
 }