X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogin%2Flogind-session.c;h=e297d3feeba689880c2b01e51ffd8c0e31df79b2;hp=af9c12dcd57d22c35eff72c5c500506115f4ed71;hb=b80efeb9ae23b493d03501caa7e6334d1db65dd9;hpb=55efac6cbcea0d8edda9c6820620ceb390009e7a diff --git a/src/login/logind-session.c b/src/login/logind-session.c index af9c12dcd..e297d3fee 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -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 . ***/ @@ -25,10 +25,11 @@ #include #include -#include "logind-session.h" #include "strv.h" #include "util.h" +#include "mkdir.h" #include "cgroup-util.h" +#include "logind-session.h" #define IDLE_THRESHOLD_USEC (5*USEC_PER_MINUTE) @@ -51,7 +52,7 @@ Session* session_new(Manager *m, User *u, const char *id) { s->id = file_name_from_path(s->state_file); if (hashmap_put(m->sessions, s->id, s) < 0) { - free(s->id); + free(s->state_file); free(s); return NULL; } @@ -98,7 +99,6 @@ void session_free(Session *s) { free(s->service); hashmap_remove(s->manager->sessions, s->id); - session_remove_fifo(s); free(s->state_file); @@ -286,14 +286,9 @@ int session_load(Session *s) { } if (leader) { - pid_t pid; - - k = parse_pid(leader, &pid); - if (k >= 0 && pid >= 1) { - s->leader = pid; - - audit_session_from_pid(pid, &s->audit_id); - } + k = parse_pid(leader, &s->leader); + if (k >= 0) + audit_session_from_pid(s->leader, &s->audit_id); } if (type) { @@ -325,7 +320,6 @@ int session_load(Session *s) { close_nointr_nofail(fd); } - finish: free(remote); free(kill_processes); @@ -333,6 +327,7 @@ finish: free(vtnr); free(leader); free(audit_id); + free(class); return r; } @@ -391,6 +386,10 @@ static int session_link_x11_socket(Session *s) { return -ENOENT; } + /* Note that this cannot be in a subdir to avoid + * vulnerabilities since we are privileged but the runtime + * path is owned by the user */ + t = strappend(s->user->runtime_path, "/X11-display"); if (!t) { log_error("Out of memory"); @@ -835,7 +834,7 @@ int session_create_fifo(Session *s) { if (s->fifo_fd < 0) return -errno; - r = hashmap_put(s->manager->fifo_fds, INT_TO_PTR(s->fifo_fd + 1), s); + r = hashmap_put(s->manager->session_fds, INT_TO_PTR(s->fifo_fd + 1), s); if (r < 0) return r; @@ -859,7 +858,7 @@ void session_remove_fifo(Session *s) { assert(s); if (s->fifo_fd >= 0) { - assert_se(hashmap_remove(s->manager->fifo_fds, INT_TO_PTR(s->fifo_fd + 1)) == s); + assert_se(hashmap_remove(s->manager->session_fds, INT_TO_PTR(s->fifo_fd + 1)) == s); assert_se(epoll_ctl(s->manager->epoll_fd, EPOLL_CTL_DEL, s->fifo_fd, NULL) == 0); close_nointr_nofail(s->fifo_fd); s->fifo_fd = -1;