chiark / gitweb /
Prep v239: Add support for the new 'suspend-then-hibernate' method.
[elogind.git] / src / login / logind.c
index 1687891d0f31ff8839f62288edd1f96a34246bd8..4c4577965294b319dd5dbae363fab8fa9ff264cc 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 <fcntl.h>
@@ -27,7 +22,7 @@
 #include "format-util.h"
 #include "fs-util.h"
 #include "logind.h"
-//#include "parse-util.h"
+#include "parse-util.h"
 //#include "process-util.h"
 #include "selinux-util.h"
 #include "signal-util.h"
@@ -79,7 +74,7 @@ static int manager_new(Manager **ret) {
 #if 1 /// elogind needs some more data
         r = elogind_manager_new(m);
         if (r < 0)
-                goto fail;
+                return r;
 #endif // 1
         m->udev = udev_new();
         if (!m->udev)
@@ -416,14 +411,18 @@ static int parse_fdname(const char *fdname, char **session_id, dev_t *dev) {
 
         if (!streq(parts[0], "session"))
                 return -EINVAL;
+
         id = strdup(parts[1]);
         if (!id)
                 return -ENOMEM;
 
         if (!streq(parts[2], "device"))
                 return -EINVAL;
-        r = safe_atou(parts[3], &major) ||
-            safe_atou(parts[4], &minor);
+
+        r = safe_atou(parts[3], &major);
+        if (r < 0)
+                return r;
+        r = safe_atou(parts[4], &minor);
         if (r < 0)
                 return r;
 
@@ -1108,18 +1107,6 @@ static int manager_dispatch_idle_action(sd_event_source *s, uint64_t t, void *us
         return 0;
 }
 
-#if 0 /// elogind parses its own config file
-#else
-         const char* logind_conf = getenv("ELOGIND_CONF_FILE");
-
-         assert(m);
-
-         if (!logind_conf)
-                 logind_conf = PKGSYSCONFDIR "/logind.conf";
-
-         return config_parse(NULL, logind_conf, NULL, "Login\0Sleep\0",
-                             config_item_perf_lookup, logind_gperf_lookup,
-#endif // 0
 static int manager_dispatch_reload_signal(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
         Manager *m = userdata;
         int r;
@@ -1294,15 +1281,16 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        /* Always create the directories people can create inotify
-         * watches in. Note that some applications might check for the
-         * existence of /run/systemd/seats/ to determine whether
-         * logind is available, so please always make sure this check
-         * stays in. */
 #if 0 /// elogind can not rely on systemd to help, so we need a bit more effort than this
         mkdir_label("/run/systemd/seats", 0755);
         mkdir_label("/run/systemd/users", 0755);
         mkdir_label("/run/systemd/sessions", 0755);
+        /* Always create the directories people can create inotify watches in. Note that some applications might check
+         * for the existence of /run/systemd/seats/ to determine whether logind is available, so please always make
+         * sure these directories are created early on and unconditionally. */
+        (void) mkdir_label("/run/systemd/seats", 0755);
+        (void) mkdir_label("/run/systemd/users", 0755);
+        (void) mkdir_label("/run/systemd/sessions", 0755);
 
         assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGHUP, SIGTERM, SIGINT, -1) >= 0);
 
@@ -1326,8 +1314,6 @@ int main(int argc, char *argv[]) {
         if ( r < 0 && (-EEXIST != r) )
                 return log_error_errno(r, "Failed to create /run/systemd/machines : %m");
 #endif // 0
-                goto finish;
-        }
 
         (void) manager_parse_config_file(m);