chiark / gitweb /
Prep v239: Uncomment header inclusions that are new or needed now.
[elogind.git] / src / login / logind-dbus.c
index 26a4ed889817b69a971d5202bccdc88ece7069a0..31acd57dc62641ae8ec123c3cd2c3ef1cc8f9d6d 100644 (file)
@@ -1,9 +1,4 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
-/***
-  This file is part of systemd.
-
-  Copyright 2011 Lennart Poettering
-***/
 
 #include <errno.h>
 #include <pwd.h>
@@ -2343,11 +2338,11 @@ static int method_can_shutdown_or_sleep(
         if (sleep_verb) {
 #if 0 /// elogind needs to have the manager being passed
                 r = can_sleep(sleep_verb);
-                if (IN_SET(r,  0, -ENOSPC))
-                        return sd_bus_reply_method_return(message, "s", "na");
 #else
                 r = can_sleep(m, sleep_verb);
 #endif // 0
+                if (IN_SET(r,  0, -ENOSPC))
+                        return sd_bus_reply_method_return(message, "s", "na");
                 if (r < 0)
                         return r;
         }
@@ -2372,6 +2367,7 @@ static int method_can_shutdown_or_sleep(
                 const char *target;
 
                 target = manager_target_for_action(handle);
+#if 0 /// elogind does not support systemd units units. A valid handle is enough
                 if (target) {
                         _cleanup_free_ char *load_state = NULL;
 
@@ -2380,10 +2376,19 @@ static int method_can_shutdown_or_sleep(
                                 return r;
 
                         if (!streq(load_state, "loaded")) {
+#else
+                if (NULL == target) {
+#endif // 0
                                 result = "no";
                                 goto finish;
+#if 0 /// one less with elogind...
                         }
+#endif // 0
                 }
+#else
+                if ( (handle <= HANDLE_IGNORE) || (handle >= _HANDLE_ACTION_MAX) ) {
+                        result = "no";
+                        goto finish;
         }
 
         if (multiple_sessions) {
@@ -2429,6 +2434,7 @@ static int method_can_shutdown_or_sleep(
         }
 
  finish:
+
         return sd_bus_reply_method_return(message, "s", result);
 }