chiark / gitweb /
Prep v234: Check against TRANSPORT_LOCAL in check_inhibitors()
[elogind.git] / src / login / logind-dbus.c
index 26b6c3a92368445f85cdbac946bcf6be79be1e45..70d2b1ffc0f9c463f3d0c14c500be2857eba788b 100644 (file)
@@ -34,7 +34,7 @@
 #include "escape.h"
 #include "fd-util.h"
 #include "fileio-label.h"
-#include "formats-util.h"
+#include "format-util.h"
 #include "fs-util.h"
 #include "logind.h"
 #include "mkdir.h"
@@ -69,6 +69,9 @@ int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const ch
                         return r;
 
                 r = sd_bus_creds_get_session(creds, &name);
+                if (r == -ENXIO)
+                        return sd_bus_error_setf(error, BUS_ERROR_NO_SESSION_FOR_PID,
+                                                 "Caller does not belong to any known session");
                 if (r < 0)
                         return r;
         }
@@ -1301,8 +1304,7 @@ static int flush_devices(Manager *m) {
         } else {
                 struct dirent *de;
 
-                while ((de = readdir(d))) {
-
+                FOREACH_DIRENT_ALL(de, d, break) {
                         if (!dirent_is_file(de))
                                 continue;
 
@@ -1391,7 +1393,6 @@ static int method_flush_devices(sd_bus_message *message, void *userdata, sd_bus_
         return sd_bus_reply_method_return(message, NULL);
 }
 
-#if 0 /// elogind has its own variant in elogind-dbus.c
 static int have_multiple_sessions(
                 Manager *m,
                 uid_t uid) {
@@ -1411,6 +1412,7 @@ static int have_multiple_sessions(
         return false;
 }
 
+#if 0 /// elogind has its own variant in elogind-dbus.c
 static int bus_manager_log_shutdown(
                 Manager *m,
                 InhibitWhat w,
@@ -1447,7 +1449,7 @@ static int bus_manager_log_shutdown(
                 p = strjoina(p, " (", m->wall_message, ").");
 
         return log_struct(LOG_NOTICE,
-                          LOG_MESSAGE_ID(SD_MESSAGE_SHUTDOWN),
+                          "MESSAGE_ID=" SD_MESSAGE_SHUTDOWN_STR,
                           p,
                           q,
                           NULL);
@@ -1605,8 +1607,13 @@ int manager_dispatch_delayed(Manager *manager, bool timeout) {
 
         return 1;
 }
+#endif // 0
 
+#if 0 /// elogind-dbus.c needs to access this
 static int manager_inhibit_timeout_handler(
+#else
+int manager_inhibit_timeout_handler(
+#endif // 0
                         sd_event_source *s,
                         uint64_t usec,
                         void *userdata) {
@@ -1621,6 +1628,7 @@ static int manager_inhibit_timeout_handler(
         return (r < 0) ? r : 0;
 }
 
+#if 0 /// elogind has its own variant in elogind-dbus.c
 static int delay_shutdown_or_sleep(
                 Manager *m,
                 InhibitWhat w,
@@ -1656,8 +1664,13 @@ static int delay_shutdown_or_sleep(
 
         return 0;
 }
+#endif // 0
 
+#if 0 /// elogind-dbus.c needs to access this
 static int send_prepare_for(Manager *m, InhibitWhat w, bool _active) {
+#else
+int send_prepare_for(Manager *m, InhibitWhat w, bool _active) {
+#endif // 0
 
         static const char * const signal_name[_INHIBIT_WHAT_MAX] = {
                 [INHIBIT_SHUTDOWN] = "PrepareForShutdown",
@@ -1679,6 +1692,7 @@ static int send_prepare_for(Manager *m, InhibitWhat w, bool _active) {
                                   active);
 }
 
+#if 0 /// elogind has its own variant in elogind-dbus.c
 int bus_manager_shutdown_or_sleep_now_or_later(
                 Manager *m,
                 const char *unit_name,
@@ -1715,8 +1729,13 @@ int bus_manager_shutdown_or_sleep_now_or_later(
 
         return r;
 }
+#endif // 0
 
+#if 0 /// elogind-dbus.c needs to access this
 static int verify_shutdown_creds(
+#else
+int verify_shutdown_creds(
+#endif // 0
                 Manager *m,
                 sd_bus_message *message,
                 InhibitWhat w,
@@ -1778,6 +1797,7 @@ static int verify_shutdown_creds(
         return 0;
 }
 
+#if 0 /// elogind has its own variant in elogind-dbus.c
 static int method_do_shutdown_or_sleep(
                 Manager *m,
                 sd_bus_message *message,
@@ -2465,13 +2485,9 @@ static int method_set_wall_message(
                 return 1; /* Will call us back */
 #endif // 0
 
-        if (isempty(wall_message))
-                m->wall_message = mfree(m->wall_message);
-        else {
-                r = free_and_strdup(&m->wall_message, wall_message);
-                if (r < 0)
-                        return log_oom();
-        }
+        r = free_and_strdup(&m->wall_message, empty_to_null(wall_message));
+        if (r < 0)
+                return log_oom();
 
         m->enable_wall_messages = enable_wall_messages;