[systemd-devel] [PATCH] logind-multi-seat issues

Oleg Samarin osamarin68 at gmail.com
Fri Dec 14 11:31:07 PST 2012


i1. Capability of making seats without framebuffer devices
    logind.c: The seat is now activated by any device with udev tag
"seat-master"
    71-seat.rules.in: All framebuffer devices have this tag
    multi-seat-x.c: if the seat does not have a framebuffer device, runs X
as a proxy, adding -sharevts only
    if the seat has a framebuffer device, makes a special config for X
(like it did before)

i2. Supporting of acls on devices shared between all seats (like
/dev/snd/seq)
    These devices have "shared" udev tag in addition to "uaccess"

    A user gets permitions on it when he activates a session on any seat.
    He/she losses the permitions when no his/her active sessions more exist

    71-seat.rules.in: sets "ONE_SEAT" env var to "Y" for all devices with
"seat" tag
    73-seat-late.rules.in: inherits "ONE_SEAT" env from the parent device.
    sets "shared" tag to all devices with "uaccess" tag with neither
"ONE_SEAT" nor "ID_SEAT" env
    logind-acl.c: changes acl on shared devices regardless to their seats
    logind-seat.c: when a user removes an active sessions, checks are other
active sessions of this user (on other seats) exists

diff -Naur systemd.old/src/login/71-seat.rules.in systemd.new/src/login/
71-seat.rules.in
--- systemd.old/src/login/71-seat.rules.in    2012-12-14 22:51:19.361720536
+0400
+++ systemd.new/src/login/71-seat.rules.in    2012-12-14 23:07:14.116893094
+0400
@@ -11,6 +11,7 @@
 SUBSYSTEM=="sound", KERNEL=="card*", TAG+="seat"
 SUBSYSTEM=="input", KERNEL=="input*", TAG+="seat"
 SUBSYSTEM=="graphics", KERNEL=="fb[0-9]*", TAG+="seat"
+SUBSYSTEM=="graphics", KERNEL=="fb[0-9]*", TAG+="seat-master"
 SUBSYSTEM=="usb", ATTR{bDeviceClass}=="09", TAG+="seat"

 # 'Plugable' USB hub, sound, network, graphics adapter
@@ -42,6 +43,7 @@

 TAG=="seat", ENV{ID_PATH}=="", IMPORT{builtin}="path_id"
 TAG=="seat", ENV{ID_FOR_SEAT}=="", ENV{ID_PATH_TAG}!="",
ENV{ID_FOR_SEAT}="$env{SUBSYSTEM}-$env{ID_PATH_TAG}"
+TAG=="seat", ENV{ONE_SEAT}="Y"

 SUBSYSTEM=="input", ATTR{name}=="Wiebetech LLC Wiebetech",
RUN+="@rootbindir@/loginctl lock-sessions"

diff -Naur systemd.old/src/login/73-seat-late.rules.insystemd.new/src/login/
73-seat-late.rules.in
--- systemd.old/src/login/73-seat-late.rules.in    2012-12-14
22:51:19.361720536 +0400
+++ systemd.new/src/login/73-seat-late.rules.in    2012-12-14
23:08:22.548039895 +0400
@@ -14,4 +14,7 @@

 TAG=="uaccess", ENV{MAJOR}!="", RUN{builtin}+="uaccess"

+ENV{ONE_SEAT}=="", IMPORT{parent}="ONE_SEAT"
+TAG=="uaccess", ENV{ONE_SEAT}!="Y", ENV{ID_SEAT}=="", TAG+="shared"
+
 LABEL="seat_late_end"
diff -Naur systemd.old/src/login/logind-acl.c
systemd.new/src/login/logind-acl.c
--- systemd.old/src/login/logind-acl.c    2012-12-14 22:51:19.361720536
+0400
+++ systemd.new/src/login/logind-acl.c    2012-12-14 23:10:59.457079493
+0400
@@ -174,7 +174,7 @@
 int devnode_acl_all(struct udev *udev,
                     const char *seat,
                     bool flush,
-                    bool del, uid_t old_uid,
+                    bool del, bool del_shared, uid_t old_uid,
                     bool add, uid_t new_uid) {

         struct udev_list_entry *item = NULL, *first = NULL;
@@ -208,6 +208,7 @@
         udev_list_entry_foreach(item, first) {
                 struct udev_device *d;
                 const char *node, *sn;
+                bool is_shared;

                 d = udev_device_new_from_syspath(udev,
udev_list_entry_get_name(item));
                 if (!d) {
@@ -215,13 +216,20 @@
                         goto finish;
                 }

-                sn = udev_device_get_property_value(d, "ID_SEAT");
-                if (isempty(sn))
-                        sn = "seat0";
-
-                if (!streq(seat, sn)) {
-                        udev_device_unref(d);
-                        continue;
+                // all devices with shared tag are accessible with all
seats
+                is_shared = udev_device_has_tag(d, "shared");
+
+                if (is_shared) {
+                    sn = "shared";
+                } else {
+                    sn = udev_device_get_property_value(d, "ID_SEAT");
+                    if (isempty(sn))
+                            sn = "seat0";
+
+                    if (!streq(seat, sn)) {
+                            udev_device_unref(d);
+                            continue;
+                    }
                 }

                 node = udev_device_get_devnode(d);
@@ -233,7 +241,7 @@

                 log_debug("Fixing up %s for seat %s...", node, sn);

-                r = devnode_acl(node, flush, del, old_uid, add, new_uid);
+                r = devnode_acl(node, flush, is_shared ? del_shared : del,
old_uid, add, new_uid);
                 udev_device_unref(d);

                 if (r < 0)
diff -Naur systemd.old/src/login/logind-acl.h
systemd.new/src/login/logind-acl.h
--- systemd.old/src/login/logind-acl.h    2012-12-14 22:51:19.361720536
+0400
+++ systemd.new/src/login/logind-acl.h    2012-12-14 23:11:39.936573058
+0400
@@ -35,7 +35,7 @@
 int devnode_acl_all(struct udev *udev,
                     const char *seat,
                     bool flush,
-                    bool del, uid_t old_uid,
+                    bool del, bool del_shared, uid_t old_uid,
                     bool add, uid_t new_uid);
 #else

diff -Naur systemd.old/src/login/logind.c systemd.new/src/login/logind.c
--- systemd.old/src/login/logind.c    2012-12-14 22:51:19.362720524 +0400
+++ systemd.new/src/login/logind.c    2012-12-14 23:13:03.296530203 +0400
@@ -450,11 +450,7 @@
                 goto finish;
         }

-        r = udev_enumerate_add_match_subsystem(e, "graphics");
-        if (r < 0)
-                goto finish;
-
-        r = udev_enumerate_add_match_tag(e, "seat");
+        r = udev_enumerate_add_match_tag(e, "seat-master");
         if (r < 0)
                 goto finish;

@@ -1286,11 +1282,7 @@
         if (!m->udev_seat_monitor)
                 return -ENOMEM;

-        r = udev_monitor_filter_add_match_tag(m->udev_seat_monitor,
"seat");
-        if (r < 0)
-                return r;
-
-        r =
udev_monitor_filter_add_match_subsystem_devtype(m->udev_seat_monitor,
"graphics", NULL);
+        r = udev_monitor_filter_add_match_tag(m->udev_seat_monitor,
"seat-master");
         if (r < 0)
                 return r;

diff -Naur systemd.old/src/login/logind-seat.c
systemd.new/src/login/logind-seat.c
--- systemd.old/src/login/logind-seat.c    2012-12-14 22:51:19.362720524
+0400
+++ systemd.new/src/login/logind-seat.c    2012-12-14 23:15:16.307860909
+0400
@@ -225,7 +225,10 @@
         r = devnode_acl_all(s->manager->udev,
                             s->id,
                             false,
-                            !!old_active, old_active ?
old_active->user->uid : 0,
+                            !!old_active,
+                            // delete acl on shared devices only if no
other active sessions
+                            old_active && user_get_state(old_active->user)
!= USER_ACTIVE,
+                            old_active ? old_active->user->uid : 0,
                             !!s->active, s->active ? s->active->user->uid
: 0);

         if (r < 0)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20121214/553091a2/attachment.html>


More information about the systemd-devel mailing list