[systemd-commits] 3 commits - Makefile.am src/73-seat-late.rules src/73-seat-late.rules.in src/.gitignore src/logind.c src/logind.h src/logind-seat.c src/logind-seat.h src/logind-session.c src/logind-session.h src/logind-user.c src/logind-user.h src/uaccess.c

Lennart Poettering lennart at kemper.freedesktop.org
Tue Jun 28 19:15:07 PDT 2011


 Makefile.am               |   10 +++++-
 src/.gitignore            |    1 
 src/73-seat-late.rules    |   15 ---------
 src/73-seat-late.rules.in |   17 +++++++++++
 src/logind-seat.c         |    4 +-
 src/logind-seat.h         |    2 -
 src/logind-session.c      |   70 ++++++++++++++++++++++------------------------
 src/logind-session.h      |    3 -
 src/logind-user.c         |    4 +-
 src/logind-user.h         |    2 -
 src/logind.c              |   15 +++++----
 src/logind.h              |    3 -
 src/uaccess.c             |    6 +--
 13 files changed, 80 insertions(+), 72 deletions(-)

New commits:
commit 0b191e603cc31ef0aff435fe20d49c7df39dfb8c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jun 29 04:14:43 2011 +0200

    logind: hook uaccess into udev by default

diff --git a/Makefile.am b/Makefile.am
index 940892c..8da2e1b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -218,9 +218,11 @@ dist_dbussystemservice_DATA = \
 dist_udevrules_DATA = \
         src/70-uaccess.rules \
         src/71-seat.rules \
-        src/73-seat-late.rules \
 	src/99-systemd.rules
 
+nodist_udevrules_DATA = \
+        src/73-seat-late.rules
+
 dbusinterface_DATA = \
 	org.freedesktop.systemd1.Manager.xml \
 	org.freedesktop.systemd1.Job.xml \
@@ -404,7 +406,8 @@ EXTRA_DIST = \
 	units/quotacheck.service.in \
 	systemd.pc.in \
 	introspect.awk \
-	src/org.freedesktop.systemd1.policy.in
+	src/org.freedesktop.systemd1.policy.in \
+        src/73-seat-late.rules.in
 
 if ENABLE_BINFMT
 EXTRA_DIST += \
@@ -1306,6 +1309,9 @@ man/%: man/%.in Makefile
 src/%.policy: src/%.policy.in Makefile
 	$(SED_PROCESS)
 
+src/%.rules: src/%.rules.in Makefile
+	$(SED_PROCESS)
+
 M4_PROCESS_SYSTEM = \
 	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
 	$(M4) -P $(M4_DISTRO_FLAG) -DFOR_SYSTEM=1 < $< > $@ || rm $@
diff --git a/src/.gitignore b/src/.gitignore
index 4c7d3c8..de3bb5f 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -2,3 +2,4 @@ org.freedesktop.systemd1.policy
 gnome-ask-password-agent.c
 systemd-interfaces.c
 systemadm.c
+73-seat-late.rules
diff --git a/src/73-seat-late.rules b/src/73-seat-late.rules
deleted file mode 100644
index 5a17c81..0000000
--- a/src/73-seat-late.rules
+++ /dev/null
@@ -1,15 +0,0 @@
-#  This file is part of systemd.
-#
-#  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
-#  (at your option) any later version.
-
-ACTION=="remove", GOTO="seat_late_end"
-
-ENV{ID_SEAT}=="", ENV{ID_AUTOSEAT}=="1", ENV{ID_FOR_SEAT}!="", ENV{ID_SEAT}="seat-$env{ID_FOR_SEAT}"
-ENV{ID_SEAT}=="", IMPORT{parent}="ID_SEAT"
-
-ENV{ID_SEAT}!="", TAG+="$env{ID_SEAT}"
-
-LABEL="seat_late_end"
diff --git a/src/73-seat-late.rules.in b/src/73-seat-late.rules.in
new file mode 100644
index 0000000..e93a0e6
--- /dev/null
+++ b/src/73-seat-late.rules.in
@@ -0,0 +1,17 @@
+#  This file is part of systemd.
+#
+#  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
+#  (at your option) any later version.
+
+ACTION=="remove", GOTO="seat_late_end"
+
+ENV{ID_SEAT}=="", ENV{ID_AUTOSEAT}=="1", ENV{ID_FOR_SEAT}!="", ENV{ID_SEAT}="seat-$env{ID_FOR_SEAT}"
+ENV{ID_SEAT}=="", IMPORT{parent}="ID_SEAT"
+
+ENV{ID_SEAT}!="", TAG+="$env{ID_SEAT}"
+
+TAG=="uaccess", RUN+="@rootlibexecdir@/systemd-uaccess $env{DEVNAME} $env{ID_SEAT}"
+
+LABEL="seat_late_end"
diff --git a/src/logind.h b/src/logind.h
index 8726502..aaa21cd 100644
--- a/src/logind.h
+++ b/src/logind.h
@@ -37,7 +37,6 @@
  * spawn user systemd
  * direct client API
  * verify access to SetIdleHint
- * hook up ACL tool for udev
  *
  * udev:
  * drop redundant udev_device_get_is_initialized() use as soon as libudev is fixed
diff --git a/src/uaccess.c b/src/uaccess.c
index 524e4f0..392b516 100644
--- a/src/uaccess.c
+++ b/src/uaccess.c
@@ -36,14 +36,14 @@ int main(int argc, char *argv[]) {
         log_parse_environment();
         log_open();
 
-        if (argc != 2) {
-                log_error("This program expects two argument.");
+        if (argc < 2 || argc > 3) {
+                log_error("This program expects one or two arguments.");
                 r = -EINVAL;
                 goto finish;
         }
 
         path = argv[1];
-        seat = argv[2];
+        seat = argc >= 3 ? argv[2] : "seat0";
 
         p = strappend("/run/systemd/seats/", seat);
         if (!p) {

commit b4f78aeac66e64e0489d7a26f1370a69d0fcf011
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jun 29 03:48:53 2011 +0200

    logind: we need to open and close a named pipe once for read before we get EOF

diff --git a/src/logind-session.c b/src/logind-session.c
index 3521309..bc1b9b7 100644
--- a/src/logind-session.c
+++ b/src/logind-session.c
@@ -297,7 +297,19 @@ int session_load(Session *s) {
                         s->type = t;
         }
 
-        session_open_fifo(s);
+        if (s->fifo_path) {
+                int fd;
+
+                /* If we open an unopened pipe for reading we will not
+                   get an EOF. to trigger an EOF we hence open it for
+                   reading, but close it right-away which then will
+                   trigger the EOF. */
+
+                fd = session_create_fifo(s);
+                if (fd >= 0)
+                        close_nointr_nofail(fd);
+        }
+
 
 finish:
         free(remote);
@@ -768,41 +780,12 @@ void session_set_idle_hint(Session *s, bool b) {
                              "IdleSinceHintMonotonic\0");
 }
 
-int session_open_fifo(Session *s) {
-        struct epoll_event ev;
-        int r;
-
-        assert(s);
-
-        if (s->fifo_fd >= 0)
-                return 0;
-
-        if (!s->fifo_path)
-                return -EINVAL;
-
-        s->fifo_fd = open(s->fifo_path, O_RDONLY|O_CLOEXEC|O_NDELAY);
-        if (s->fifo_fd < 0)
-                return -errno;
-
-        r = hashmap_put(s->manager->fifo_fds, INT_TO_PTR(s->fifo_fd + 1), s);
-        if (r < 0)
-                return r;
-
-        zero(ev);
-        ev.events = 0;
-        ev.data.u32 = FD_FIFO_BASE + s->fifo_fd;
-
-        if (epoll_ctl(s->manager->epoll_fd, EPOLL_CTL_ADD, s->fifo_fd, &ev) < 0)
-                return -errno;
-
-        return 0;
-}
-
 int session_create_fifo(Session *s) {
         int r;
 
         assert(s);
 
+        /* Create FIFO */
         if (!s->fifo_path) {
                 if (asprintf(&s->fifo_path, "/run/systemd/sessions/%s.ref", s->id) < 0)
                         return -ENOMEM;
@@ -812,9 +795,24 @@ int session_create_fifo(Session *s) {
         }
 
         /* Open reading side */
-        r = session_open_fifo(s);
-        if (r < 0)
-                return r;
+        if (s->fifo_fd < 0) {
+                struct epoll_event ev;
+
+                s->fifo_fd = open(s->fifo_path, O_RDONLY|O_CLOEXEC|O_NDELAY);
+                if (s->fifo_fd < 0)
+                        return -errno;
+
+                r = hashmap_put(s->manager->fifo_fds, INT_TO_PTR(s->fifo_fd + 1), s);
+                if (r < 0)
+                        return r;
+
+                zero(ev);
+                ev.events = 0;
+                ev.data.u32 = FD_FIFO_BASE + s->fifo_fd;
+
+                if (epoll_ctl(s->manager->epoll_fd, EPOLL_CTL_ADD, s->fifo_fd, &ev) < 0)
+                        return -errno;
+        }
 
         /* Open writing side */
         r = open(s->fifo_path, O_WRONLY|O_CLOEXEC|O_NDELAY);
diff --git a/src/logind-session.h b/src/logind-session.h
index 303e61a..e58ff6f 100644
--- a/src/logind-session.h
+++ b/src/logind-session.h
@@ -92,7 +92,6 @@ int session_activate(Session *s);
 bool session_is_active(Session *s);
 int session_get_idle_hint(Session *s, dual_timestamp *t);
 void session_set_idle_hint(Session *s, bool b);
-int session_open_fifo(Session *s);
 int session_create_fifo(Session *s);
 void session_remove_fifo(Session *s);
 int session_start(Session *s);

commit 4a4b033ff285f1eed2085a87b5b0c0ad6c73d166
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jun 29 03:48:16 2011 +0200

    logind: when initializing drop sessions that are unreferenced

diff --git a/src/logind-seat.c b/src/logind-seat.c
index b8f1f60..3cf3958 100644
--- a/src/logind-seat.c
+++ b/src/logind-seat.c
@@ -446,10 +446,10 @@ int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
         return idle_hint;
 }
 
-int seat_check_gc(Seat *s) {
+int seat_check_gc(Seat *s, bool drop_not_started) {
         assert(s);
 
-        if (!s->started)
+        if (drop_not_started && !s->started)
                 return 0;
 
         if (seat_is_vtconsole(s))
diff --git a/src/logind-seat.h b/src/logind-seat.h
index 6d9c36d..5bce143 100644
--- a/src/logind-seat.h
+++ b/src/logind-seat.h
@@ -68,7 +68,7 @@ int seat_start(Seat *s);
 int seat_stop(Seat *s);
 int seat_stop_sessions(Seat *s);
 
-int seat_check_gc(Seat *s);
+int seat_check_gc(Seat *s, bool drop_not_started);
 void seat_add_to_gc_queue(Seat *s);
 
 bool seat_name_is_valid(const char *name);
diff --git a/src/logind-session.c b/src/logind-session.c
index 088e956..3521309 100644
--- a/src/logind-session.c
+++ b/src/logind-session.c
@@ -841,12 +841,12 @@ void session_remove_fifo(Session *s) {
         }
 }
 
-int session_check_gc(Session *s) {
+int session_check_gc(Session *s, bool drop_not_started) {
         int r;
 
         assert(s);
 
-        if (!s->started)
+        if (drop_not_started && !s->started)
                 return 0;
 
         if (s->fifo_fd >= 0) {
diff --git a/src/logind-session.h b/src/logind-session.h
index d0cf0ed..303e61a 100644
--- a/src/logind-session.h
+++ b/src/logind-session.h
@@ -86,7 +86,7 @@ struct Session {
 
 Session *session_new(Manager *m, User *u, const char *id);
 void session_free(Session *s);
-int session_check_gc(Session *s);
+int session_check_gc(Session *s, bool drop_not_started);
 void session_add_to_gc_queue(Session *s);
 int session_activate(Session *s);
 bool session_is_active(Session *s);
diff --git a/src/logind-user.c b/src/logind-user.c
index 3076ed1..dacf148 100644
--- a/src/logind-user.c
+++ b/src/logind-user.c
@@ -457,13 +457,13 @@ int user_get_idle_hint(User *u, dual_timestamp *t) {
         return idle_hint;
 }
 
-int user_check_gc(User *u) {
+int user_check_gc(User *u, bool drop_not_started) {
         int r;
         char *p;
 
         assert(u);
 
-        if (!u->started)
+        if (drop_not_started && !u->started)
                 return 0;
 
         if (u->sessions)
diff --git a/src/logind-user.h b/src/logind-user.h
index dd0dcad..8a8d5ed 100644
--- a/src/logind-user.h
+++ b/src/logind-user.h
@@ -63,7 +63,7 @@ struct User {
 
 User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name);
 void user_free(User *u);
-int user_check_gc(User *u);
+int user_check_gc(User *u, bool drop_not_started);
 void user_add_to_gc_queue(User *u);
 int user_start(User *u);
 int user_stop(User *u);
diff --git a/src/logind.c b/src/logind.c
index d7d04a2..9bab875 100644
--- a/src/logind.c
+++ b/src/logind.c
@@ -975,7 +975,7 @@ static int manager_connect_udev(Manager *m) {
         return 0;
 }
 
-void manager_gc(Manager *m) {
+void manager_gc(Manager *m, bool drop_not_started) {
         Seat *seat;
         Session *session;
         User *user;
@@ -986,7 +986,7 @@ void manager_gc(Manager *m) {
                 LIST_REMOVE(Seat, gc_queue, m->seat_gc_queue, seat);
                 seat->in_gc_queue = false;
 
-                if (seat_check_gc(seat) == 0) {
+                if (seat_check_gc(seat, drop_not_started) == 0) {
                         seat_stop(seat);
                         seat_free(seat);
                 }
@@ -996,7 +996,7 @@ void manager_gc(Manager *m) {
                 LIST_REMOVE(Session, gc_queue, m->session_gc_queue, session);
                 session->in_gc_queue = false;
 
-                if (session_check_gc(session) == 0) {
+                if (session_check_gc(session, drop_not_started) == 0) {
                         session_stop(session);
                         session_free(session);
                 }
@@ -1006,7 +1006,7 @@ void manager_gc(Manager *m) {
                 LIST_REMOVE(User, gc_queue, m->user_gc_queue, user);
                 user->in_gc_queue = false;
 
-                if (user_check_gc(user) == 0) {
+                if (user_check_gc(user, drop_not_started) == 0) {
                         user_stop(user);
                         user_free(user);
                 }
@@ -1090,6 +1090,9 @@ int manager_startup(Manager *m) {
         manager_enumerate_users(m);
         manager_enumerate_sessions(m);
 
+        /* Remove stale objects before we start them */
+        manager_gc(m, false);
+
         /* And start everything */
         HASHMAP_FOREACH(seat, m->seats, i)
                 seat_start(seat);
@@ -1110,12 +1113,12 @@ int manager_run(Manager *m) {
                 struct epoll_event event;
                 int n;
 
-                manager_gc(m);
+                manager_gc(m, true);
 
                 if (dbus_connection_dispatch(m->bus) != DBUS_DISPATCH_COMPLETE)
                         continue;
 
-                manager_gc(m);
+                manager_gc(m, true);
 
                 n = epoll_wait(m->epoll_fd, &event, 1, -1);
                 if (n < 0) {
diff --git a/src/logind.h b/src/logind.h
index ebf859e..8726502 100644
--- a/src/logind.h
+++ b/src/logind.h
@@ -131,7 +131,7 @@ int manager_spawn_autovt(Manager *m, int vtnr);
 
 void manager_cgroup_notify_empty(Manager *m, const char *cgroup);
 
-void manager_gc(Manager *m);
+void manager_gc(Manager *m, bool drop_not_started);
 
 int manager_get_idle_hint(Manager *m, dual_timestamp *t);
 



More information about the systemd-commits mailing list