chiark / gitweb /
Stop sessions on ReleaseSession
[elogind.git] / src / login / logind.c
index a51f02ebe95c89d688d2eac724347f07f4480529..5da76a76754ec76e6aeac89910766c9fa6b3e3aa 100644 (file)
@@ -36,6 +36,7 @@
 #include "label.h"
 #include "label.h"
 #include "cgroup.h"
+#include "virt.h"
 
 static void manager_free(Manager *m);
 
@@ -99,6 +100,23 @@ static Manager *manager_new(void) {
         if (r < 0)
                 goto fail;
 
+        m->suspend_mode = NULL;
+        m->suspend_state = strv_new("mem", "standby", "freeze", NULL);
+        if (!m->suspend_state)
+                goto fail;
+        m->hibernate_mode = strv_new("platform", "shutdown", NULL);
+        if (!m->hibernate_mode)
+                goto fail;
+        m->hibernate_state = strv_new("disk", NULL);
+        if (!m->hibernate_state)
+                goto fail;
+        m->hybrid_sleep_mode = strv_new("suspend", "platform", "shutdown", NULL);
+        if (!m->hybrid_sleep_mode)
+                goto fail;
+        m->hybrid_sleep_state = strv_new("disk", NULL);
+        if (!m->hybrid_sleep_state)
+                goto fail;
+
         m->udev = udev_new();
         if (!m->udev)
                 goto fail;
@@ -189,6 +207,12 @@ static void manager_free(Manager *m) {
         safe_close(m->reserve_vt_fd);
 #endif // 0
 
+        /* Avoid the creation of new processes forked by the
+         * kernel; at this point, we will not listen to the
+         * signals anyway */
+        if (detect_container(NULL) <= 0)
+                (void) cg_uninstall_release_agent(ELOGIND_CGROUP_CONTROLLER);
+
         manager_shutdown_cgroup(m, true);
 
         strv_free(m->kill_only_users);
@@ -197,7 +221,14 @@ static void manager_free(Manager *m) {
         free(m->scheduled_shutdown_type);
         free(m->scheduled_shutdown_tty);
         free(m->wall_message);
-        free(m->action_job);
+
+        strv_free(m->suspend_mode);
+        strv_free(m->suspend_state);
+        strv_free(m->hibernate_mode);
+        strv_free(m->hibernate_state);
+        strv_free(m->hybrid_sleep_mode);
+        strv_free(m->hybrid_sleep_state);
+
         free(m);
 }
 
@@ -643,6 +674,8 @@ static int manager_connect_bus(Manager *m) {
         if (r < 0)
                 return log_error_errno(r, "Failed to add user enumerator: %m");
 
+/// elogind does not support systemd action jobs
+#if 0
         r = sd_bus_add_match(m->bus,
                              NULL,
                              "type='signal',"
@@ -653,6 +686,7 @@ static int manager_connect_bus(Manager *m) {
                              match_job_removed, m);
         if (r < 0)
                 log_warning_errno(r, "Failed to add match for JobRemoved: %m");
+#endif // 0
 
         r = sd_bus_add_match(m->bus,
                              NULL,
@@ -1131,13 +1165,29 @@ static int manager_run(Manager *m) {
 }
 
 static int manager_parse_config_file(Manager *m) {
+        const char *unit = NULL, *logind_conf, *sections;
+        FILE *file = NULL;
+        bool relaxed = false, allow_include = false, warn = true;
+
         assert(m);
 
+/// elogind parses its own config file
+#if 0
         return config_parse_many("/etc/systemd/logind.conf",
                                  CONF_DIRS_NULSTR("systemd/logind.conf"),
                                  "Login\0",
                                  config_item_perf_lookup, logind_gperf_lookup,
                                  false, m);
+#endif // 0
+
+        logind_conf = getenv("ELOGIND_CONF_FILE");
+        if (!logind_conf)
+                logind_conf = PKGSYSCONFDIR "/logind.conf";
+        sections = "Login\0Sleep\0";
+
+        return config_parse(unit, logind_conf, file, sections,
+                            config_item_perf_lookup, logind_gperf_lookup,
+                            relaxed, allow_include, warn, m);
 }
 
 int main(int argc, char *argv[]) {