chiark / gitweb /
logind: load SELinux labelling system
[elogind.git] / src / login / logind-dbus.c
index 0c25d1f6f13dc70286cfb76c438eb13a55d2c271..a54071800f28c5574442ad0e737ab924f1c2e431 100644 (file)
@@ -32,7 +32,7 @@
 #include "bus-error.h"
 #include "bus-util.h"
 #include "dirent-util.h"
-#include "efivars.h"
+//#include "efivars.h"
 #include "escape.h"
 #include "fd-util.h"
 #include "fileio-label.h"
@@ -50,7 +50,7 @@
 #include "udev-util.h"
 #include "unit-name.h"
 #include "user-util.h"
-#include "utmp-wtmp.h"
+//#include "utmp-wtmp.h"
 
 int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret) {
         _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
@@ -1117,7 +1117,7 @@ static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bu
         errno = 0;
         pw = getpwuid(uid);
         if (!pw)
-                return errno ? -errno : -ENOENT;
+                return errno > 0 ? -errno : -ENOENT;
 
         r = bus_verify_polkit_async(
                         message,
@@ -1235,7 +1235,6 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
                 return -ENOMEM;
 
         mkdir_p_label("/etc/udev/rules.d", 0755);
-        mac_selinux_init("/etc");
         r = write_string_file_atomic_label(file, rule);
         if (r < 0)
                 return r;
@@ -1367,8 +1366,7 @@ static int have_multiple_sessions(
 static int bus_manager_log_shutdown(
                 Manager *m,
                 InhibitWhat w,
-/// elogind does not support systemd units
-#if 0
+#if 0 /// elogind does not support systemd units
                 const char *unit_name) {
 
         const char *p, *q;
@@ -1504,8 +1502,7 @@ static int execute_shutdown_or_sleep(
                 HandleAction action,
                 sd_bus_error *error) {
 
-/// elogind does not need these, we do it ourselves
-#if 0
+#if 0 /// elogind does not need these, we do it ourselves
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
         char *c = NULL;
         const char *p;
@@ -1518,8 +1515,7 @@ static int execute_shutdown_or_sleep(
 
         bus_manager_log_shutdown(m, w, action);
 
-/// elogind does it directly without depending on systemd running the system
-#if 0
+#if 0 /// elogind does it directly without depending on systemd running the system
         if (m->shutdown_dry_run) {
                 log_info("Running in dry run, suppressing action.");
                 reset_scheduled_shutdown(m);
@@ -1535,12 +1531,15 @@ static int execute_shutdown_or_sleep(
                         "ss", NULL, "replace-irreversibly");
 #else
         r = shutdown_or_sleep(m, action);
+
+        /* no more pending actions, whether this failed or not */
+        m->pending_action = HANDLE_IGNORE;
+        m->action_what    = 0;
 #endif // 0
         if (r < 0)
                 return r;
 
-/// elogind neither needs a dbus reply, nor supports systemd action jobs
-#if 0
+#if 0 /// elogind neither needs a dbus reply, nor supports systemd action jobs
         r = sd_bus_message_read(reply, "o", &p);
         if (r < 0)
                 return r;
@@ -1865,7 +1864,7 @@ static int nologin_timeout_handler(
 
         log_info("Creating /run/nologin, blocking further logins...");
 
-        r = write_string_file("/run/nologin", "System is going down.", WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
+        r = write_string_file_atomic_label("/run/nologin", "System is going down.");
         if (r < 0)
                 log_error_errno(r, "Failed to create /run/nologin: %m");
         else
@@ -1989,9 +1988,9 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
                 action_multiple_sessions = "org.freedesktop.login1.halt-multiple-sessions";
                 action_ignore_inhibit = "org.freedesktop.login1.halt-ignore-inhibit";
         } else if (streq(type, "poweroff")) {
-                action = "org.freedesktop.login1.poweroff";
-                action_multiple_sessions = "org.freedesktop.login1.poweroff-multiple-sessions";
-                action_ignore_inhibit = "org.freedesktop.login1.poweroff-ignore-inhibit";
+                action = "org.freedesktop.login1.power-off";
+                action_multiple_sessions = "org.freedesktop.login1.power-off-multiple-sessions";
+                action_ignore_inhibit = "org.freedesktop.login1.power-off-ignore-inhibit";
         } else
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unsupported shutdown type");
 
@@ -2040,7 +2039,7 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
 
         r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_AUGMENT|SD_BUS_CREDS_TTY|SD_BUS_CREDS_UID, &creds);
         if (r >= 0) {
-                const char *tty;
+                const char *tty = NULL;
 
                 (void) sd_bus_creds_get_uid(creds, &m->scheduled_shutdown_uid);
                 (void) sd_bus_creds_get_tty(creds, &tty);
@@ -2052,9 +2051,11 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
                 }
         }
 
+#if 0 /// elogind does not support utmp-wtmp
         r = manager_setup_wall_message_timer(m);
         if (r < 0)
                 return r;
+#endif // 0
 
         if (!isempty(type)) {
                 r = update_schedule_file(m);
@@ -2076,6 +2077,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
         cancelled = m->scheduled_shutdown_type != NULL;
         reset_scheduled_shutdown(m);
 
+#if 0 /// elogind does not support utmp-wtmp
         if (cancelled) {
                 _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
                 const char *tty = NULL;
@@ -2091,6 +2093,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
                 utmp_wall("The system shutdown has been cancelled",
                           uid_to_name(uid), tty, logind_wall_tty_filter, m);
         }
+#endif // 0
 
         return sd_bus_reply_method_return(message, "b", cancelled);
 }
@@ -2288,6 +2291,7 @@ static int property_get_reboot_to_firmware_setup(
                 sd_bus_message *reply,
                 void *userdata,
                 sd_bus_error *error) {
+#if 0 /// elogind does not support EFI
         int r;
 
         assert(bus);
@@ -2299,6 +2303,9 @@ static int property_get_reboot_to_firmware_setup(
                 return r;
 
         return sd_bus_message_append(reply, "b", r > 0);
+#else
+        return sd_bus_message_append(reply, "b", -EOPNOTSUPP);
+#endif // 0
 }
 
 static int method_set_reboot_to_firmware_setup(
@@ -2329,9 +2336,11 @@ static int method_set_reboot_to_firmware_setup(
         if (r == 0)
                 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
 
+#if 0 /// elogind does not support EFI
         r = efi_set_reboot_to_firmware(b);
         if (r < 0)
                 return r;
+#endif // 0
 
         return sd_bus_reply_method_return(message, NULL);
 }
@@ -2341,6 +2350,7 @@ static int method_can_reboot_to_firmware_setup(
                 void *userdata,
                 sd_bus_error *error) {
 
+#if 0 /// elogind does not support EFI
         int r;
         bool challenge;
         const char *result;
@@ -2373,6 +2383,9 @@ static int method_can_reboot_to_firmware_setup(
                 result = "no";
 
         return sd_bus_reply_method_return(message, "s", result);
+#else
+        return sd_bus_reply_method_return(message, "s", "na");
+#endif // 0
 }
 
 static int method_set_wall_message(
@@ -2614,8 +2627,7 @@ const sd_bus_vtable manager_vtable[] = {
         SD_BUS_VTABLE_END
 };
 
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
 static int session_jobs_reply(Session *s, const char *unit, const char *result) {
         int r = 0;
 
@@ -2800,8 +2812,7 @@ int manager_send_changed(Manager *manager, const char *property, ...) {
                         l);
 }
 
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
 int manager_start_slice(
                 Manager *manager,
                 const char *slice,