chiark / gitweb /
relicense to LGPLv2.1 (with exceptions)
[elogind.git] / src / login / logind.c
index 8997b4689ed1a0d1a332401d4e6c5d0f3699a98d..67117405e67027f8b7b48677ec2c34de3cfcc585 100644 (file)
@@ -6,16 +6,16 @@
   Copyright 2011 Lennart Poettering
 
   systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
   (at your option) any later version.
 
   systemd is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
+  Lesser General Public License for more details.
 
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
@@ -782,12 +782,19 @@ finish:
 }
 
 int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **session) {
+        Session *s;
         char *p;
 
         assert(m);
         assert(cgroup);
         assert(session);
 
+        s = hashmap_get(m->cgroups, cgroup);
+        if (s) {
+                *session = s;
+                return 1;
+        }
+
         p = strdup(cgroup);
         if (!p) {
                 log_error("Out of memory.");
@@ -795,24 +802,23 @@ int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **sess
         }
 
         for (;;) {
-                Session *s;
                 char *e;
 
-                if (isempty(p) || streq(p, "/")) {
+                e = strrchr(p, '/');
+                if (!e || e == p) {
                         free(p);
                         *session = NULL;
                         return 0;
                 }
 
+                *e = 0;
+
                 s = hashmap_get(m->cgroups, p);
                 if (s) {
                         free(p);
                         *session = s;
                         return 1;
                 }
-
-                assert_se(e = strrchr(p, '/'));
-                *e = 0;
         }
 }
 
@@ -1210,7 +1216,7 @@ static int manager_parse_config_file(Manager *m) {
 
         assert(m);
 
-        fn = "/etc/systemd/systemd-logind.conf";
+        fn = "/etc/systemd/logind.conf";
         f = fopen(fn, "re");
         if (!f) {
                 if (errno == ENOENT)
@@ -1234,6 +1240,7 @@ int main(int argc, char *argv[]) {
         int r;
 
         log_set_target(LOG_TARGET_AUTO);
+        log_set_facility(LOG_AUTH);
         log_parse_environment();
         log_open();