]> err.no Git - systemd/commitdiff
logind: parse configuration file
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Jun 2011 23:47:55 +0000 (01:47 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 28 Jun 2011 23:47:55 +0000 (01:47 +0200)
Makefile.am
src/logind-dbus.c
src/logind-session.c
src/logind-user.c
src/logind.c
src/logind.h

index 3d6951acdc8f9e7274f6da07aaa02b65455f6dbe..c288ad4c2909dc0a54d2014c190326336e19d12b 100644 (file)
@@ -197,7 +197,9 @@ pamlib_LTLIBRARIES = \
 endif
 
 dist_pkgsysconf_DATA = \
-       src/system.conf
+       src/system.conf \
+        src/user.conf \
+        src/systemd-logind.conf
 
 dist_dbuspolicy_DATA = \
        src/org.freedesktop.systemd1.conf \
index ff500f3c6b2e64b7a86c4619f8393c9bbe6c4c1c..69e6b189aaf0a75b33b5c5357abd1c4a342c29da 100644 (file)
@@ -641,6 +641,7 @@ static DBusHandlerResult manager_message_handler(
         const BusProperty properties[] = {
                 { "org.freedesktop.login1.Manager", "ControlGroupHierarchy",  bus_property_append_string,   "s",  m->cgroup_path          },
                 { "org.freedesktop.login1.Manager", "Controllers",            bus_property_append_strv,     "as", m->controllers          },
+                { "org.freedesktop.login1.Manager", "ResetControllers",       bus_property_append_strv,     "as", m->reset_controllers    },
                 { "org.freedesktop.login1.Manager", "NAutoVTs",               bus_property_append_unsigned, "u",  &m->n_autovts           },
                 { "org.freedesktop.login1.Manager", "KillOnlyUsers",          bus_property_append_strv,     "as", m->kill_only_users      },
                 { "org.freedesktop.login1.Manager", "KillExcludeUsers",       bus_property_append_strv,     "as", m->kill_exclude_users   },
index 76718500032502f79265130a007d15c180109cd1..088e956bfcf5366f53743759a2c73d841ded9eef 100644 (file)
@@ -473,6 +473,7 @@ static int session_create_cgroup(Session *s) {
         STRV_FOREACH(k, s->manager->controllers) {
 
                 if (strv_contains(s->reset_controllers, *k) ||
+                    strv_contains(s->manager->reset_controllers, *k) ||
                     strv_contains(s->controllers, *k))
                         continue;
 
@@ -489,6 +490,18 @@ static int session_create_cgroup(Session *s) {
                                 log_warning("Failed to reset controller %s: %s", *k, strerror(-r));
 
                 }
+
+                STRV_FOREACH(k, s->manager->reset_controllers) {
+
+                        if (strv_contains(s->reset_controllers, *k) ||
+                            strv_contains(s->controllers, *k))
+                                continue;
+
+                        r = cg_attach(*k, "/", s->leader);
+                        if (r < 0)
+                                log_warning("Failed to reset controller %s: %s", *k, strerror(-r));
+
+                }
         }
 
         hashmap_put(s->manager->cgroups, s->cgroup_path, s);
index 4335bf646203cd8af4793c300476d0198701a45b..3076ed15738fb68ca5b37438315151406d1722b1 100644 (file)
@@ -246,6 +246,10 @@ static int user_create_cgroup(User *u) {
         u->cgroup_path = p;
 
         STRV_FOREACH(k, u->manager->controllers) {
+
+                if (strv_contains(u->manager->reset_controllers, *k))
+                        continue;
+
                 r = cg_create(*k, p);
                 if (r < 0)
                         log_warning("Failed to create cgroup %s:%s: %s", *k, p, strerror(-r));
index d38d7d51c3e21270a528331a2207732fa5a7f7fc..fd17d80541e8dbd02fe28d454456dc48292bec7f 100644 (file)
@@ -32,6 +32,8 @@
 #include "logind.h"
 #include "dbus-common.h"
 #include "dbus-loop.h"
+#include "strv.h"
+#include "conf-parser.h"
 
 Manager *manager_new(void) {
         Manager *m;
@@ -124,6 +126,11 @@ void manager_free(Manager *m) {
         if (m->epoll_fd >= 0)
                 close_nointr_nofail(m->epoll_fd);
 
+        strv_free(m->controllers);
+        strv_free(m->reset_controllers);
+        strv_free(m->kill_only_users);
+        strv_free(m->kill_exclude_users);
+
         free(m->cgroup_path);
         free(m);
 }
@@ -1144,6 +1151,48 @@ int manager_run(Manager *m) {
         return 0;
 }
 
+static int manager_parse_config_file(Manager *m) {
+
+        const ConfigItem items[] = {
+                { "NAutoVTs",          config_parse_unsigned, 0, &m->n_autovts,           "Login" },
+                { "KillUserProcesses", config_parse_bool,     0, &m->kill_user_processes, "Login" },
+                { "KilOnlyUsers",      config_parse_strv,     0, &m->kill_only_users,     "Login" },
+                { "KillExcludeUsers",  config_parse_strv,     0, &m->kill_exclude_users,  "Login" },
+                { "Controllers",       config_parse_strv,     0, &m->controllers,         "Login" },
+                { "ResetControllers",  config_parse_strv,     0, &m->reset_controllers,   "Login" },
+                { NULL, NULL, 0, NULL, NULL }
+        };
+
+        static const char * const sections[] = {
+                "Login",
+                NULL
+        };
+
+        FILE *f;
+        const char *fn;
+        int r;
+
+        assert(m);
+
+        fn = "/etc/systemd/systemd-logind.conf";
+        f = fopen(fn, "re");
+        if (!f) {
+                if (errno == ENOENT)
+                        return 0;
+
+                log_warning("Failed to open configuration file %s: %m", fn);
+                return -errno;
+        }
+
+        r = config_parse(fn, f, sections, items, false, NULL);
+        if (r < 0)
+                log_warning("Failed to parse configuration file: %s", strerror(-r));
+
+        fclose(f);
+
+        return r;
+}
+
 int main(int argc, char *argv[]) {
         Manager *m = NULL;
         int r;
@@ -1167,6 +1216,8 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
+        manager_parse_config_file(m);
+
         r = manager_startup(m);
         if (r < 0) {
                 log_error("Failed to fully start up daemon: %s", strerror(-r));
index 9b9f38bb801e327b1d746489f0c1f7690c0216a9..97cfc90ebdf702639855c12e5f66fd96b4578501 100644 (file)
@@ -84,7 +84,7 @@ struct Manager {
         Seat *vtconsole;
 
         char *cgroup_path;
-        char **controllers;
+        char **controllers, **reset_controllers;
 
         char **kill_only_users, **kill_exclude_users;