[systemd-commits] 4 commits - src/71-seat.rules src/73-seat-late.rules src/logind-dbus.c src/logind.h src/org.freedesktop.login1.conf

Lennart Poettering lennart at kemper.freedesktop.org
Tue Jun 28 14:04:19 PDT 2011


 src/71-seat.rules               |    1 
 src/73-seat-late.rules          |    2 -
 src/logind-dbus.c               |   50 +++++++++++++++++++++++++++++++----
 src/logind.h                    |    7 ++++
 src/org.freedesktop.login1.conf |   57 +++++++++++++++++++++++++++++++++++++++-
 5 files changed, 110 insertions(+), 7 deletions(-)

New commits:
commit a0a0c7f18c5d4f157f471b6b2824b8e0653491ab
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 28 23:03:56 2011 +0200

    logind: retrigger devices when we reassign them

diff --git a/src/logind-dbus.c b/src/logind-dbus.c
index 57ee2ee..5997fb5 100644
--- a/src/logind-dbus.c
+++ b/src/logind-dbus.c
@@ -557,6 +557,8 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
         char *rule = NULL, *file = NULL;
         const char *id_for_seat;
         int r;
+        struct udev_enumerate *e;
+        struct udev_list_entry *first, *item;
 
         assert(m);
         assert(seat);
@@ -589,6 +591,38 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
 
         mkdir_p("/etc/udev/rules.d", 0755);
         r = write_one_line_file(file, rule);
+        if (r < 0)
+                goto finish;
+
+        e = udev_enumerate_new(m->udev);
+        if (!e) {
+                r = -ENOMEM;
+                goto finish;
+        }
+
+        if (udev_enumerate_scan_devices(e) < 0) {
+                r = -EIO;
+                goto finish;
+        }
+
+        first = udev_enumerate_get_list_entry(e);
+        udev_list_entry_foreach(item, first) {
+                char *t;
+                const char *p;
+
+                p = udev_list_entry_get_name(item);
+                if (!startswith(p, sysfs))
+                        continue;
+
+                t = strappend(p, "/uevent");
+                if (!t) {
+                        r = -ENOMEM;
+                        goto finish;
+                }
+
+                write_one_line_file(t, "change");
+                free(t);
+        }
 
 finish:
         free(rule);
@@ -597,6 +631,9 @@ finish:
         if (d)
                 udev_device_unref(d);
 
+        if (e)
+                udev_enumerate_unref(e);
+
         return r;
 }
 
diff --git a/src/logind.h b/src/logind.h
index 8702d1a..3095414 100644
--- a/src/logind.h
+++ b/src/logind.h
@@ -39,6 +39,13 @@
  * add configuration file
  * D-Bus method: AttachDevices(seat, devices[]);
  * use named pipes to detect when a session dies
+ * verify access to SetIdleHint
+ * drop redundant udev_device_get_is_initialized() use as soon as libudev is fixed
+ * properly escape/remove : and . from seat names in udev rules
+ * use device_has_tag() as soon as it is available
+ * trigger based on libudev if available
+ * enumerate recursively with libudev when triggering
+ * make sure IMPORT{parent}="ID_SEAT" works between usb hub and sound card
  *
  * non-local X11 server
  * reboot/shutdown halt management

commit 88bb8d215aa0f5576eb3f9c77c30cdc4b17783fe
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 28 23:02:38 2011 +0200

    logind: call udev_device_get_is_initialized() to trigger lazy loading, as a temporary work-around for broken libudev

diff --git a/src/logind-dbus.c b/src/logind-dbus.c
index 91f3032..57ee2ee 100644
--- a/src/logind-dbus.c
+++ b/src/logind-dbus.c
@@ -542,6 +542,8 @@ static bool device_has_tag(struct udev_device *d, const char *tag) {
         assert(d);
         assert(tag);
 
+        udev_device_get_is_initialized(d);
+
         first = udev_device_get_tags_list_entry(d);
         udev_list_entry_foreach(item, first)
                 if (streq(udev_list_entry_get_name(item), tag))

commit 72d8c4afcea592b53dcfb4d8f026cb5cb0fdb64c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 28 21:56:41 2011 +0200

    logind: supply default bus policy with minimal access

diff --git a/src/org.freedesktop.login1.conf b/src/org.freedesktop.login1.conf
index ebc499d..dc6a01c 100644
--- a/src/org.freedesktop.login1.conf
+++ b/src/org.freedesktop.login1.conf
@@ -20,7 +20,62 @@
         </policy>
 
         <policy context="default">
-                <allow send_destination="org.freedesktop.login1"/>
+                <deny send_destination="org.freedesktop.login1"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.DBus.Introspectable"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.DBus.Peer"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.DBus.Properties"
+                       send_member="Get"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.DBus.Properties"
+                       send_member="GetAll"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Manager"
+                       send_member="GetSession"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Manager"
+                       send_member="GetUser"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Manager"
+                       send_member="GetSeat"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Manager"
+                       send_member="ListSessions"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Manager"
+                       send_member="ListUsers"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Manager"
+                       send_member="ListSeats"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Manager"
+                       send_member="SetUserLinger"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Manager"
+                       send_member="ActivateSession"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Seat"
+                       send_member="ActivateSession"/>
+
+                <allow send_destination="org.freedesktop.login1"
+                       send_interface="org.freedesktop.login1.Session"
+                       send_member="Activate"/>
+
                 <allow receive_sender="org.freedesktop.login1"/>
         </policy>
 

commit c28fa3d32fe0989c286d04406414bb7ef58dab9a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 28 21:54:52 2011 +0200

    logind: include subsystem name in device id for assigning seats

diff --git a/src/71-seat.rules b/src/71-seat.rules
index d6437b0..c564bac 100644
--- a/src/71-seat.rules
+++ b/src/71-seat.rules
@@ -16,5 +16,6 @@ SUBSYSTEM=="usb", ATTR{bDeviceClass}=="09", TAG+="seat"
 SUBSYSTEM=="usb", ATTR{idVendor}=="2230", ATTR{idProduct}=="0001", ENV{ID_AUTOSEAT}="1"
 
 TAG=="seat", ENV{ID_PATH}=="", IMPORT{program}="path_id %p"
+TAG=="seat", ENV{ID_FOR_SEAT}=="", ENV{ID_PATH}!="", ENV{ID_FOR_SEAT}="$env{SUBSYSTEM}-$env{ID_PATH}"
 
 LABEL="seat_end"
diff --git a/src/73-seat-late.rules b/src/73-seat-late.rules
index f9436d0..2b4bed2 100644
--- a/src/73-seat-late.rules
+++ b/src/73-seat-late.rules
@@ -8,7 +8,7 @@
 ACTION=="remove", GOTO="seat_late_end"
 TAG!="seat", GOTO="seat_late_end"
 
-ENV{ID_SEAT}=="", ENV{ID_AUTOSEAT}=="1", ENV{ID_PATH}!="", ENV{ID_SEAT}="seat-$env{ID_PATH}"
+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}"
diff --git a/src/logind-dbus.c b/src/logind-dbus.c
index 1ed99c0..91f3032 100644
--- a/src/logind-dbus.c
+++ b/src/logind-dbus.c
@@ -553,7 +553,7 @@ static bool device_has_tag(struct udev_device *d, const char *tag) {
 static int attach_device(Manager *m, const char *seat, const char *sysfs) {
         struct udev_device *d;
         char *rule = NULL, *file = NULL;
-        const char *path;
+        const char *id_for_seat;
         int r;
 
         assert(m);
@@ -569,22 +569,23 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
                 goto finish;
         }
 
-        path = udev_device_get_property_value(d, "ID_PATH");
-        if (!path) {
+        id_for_seat = udev_device_get_property_value(d, "ID_FOR_SEAT");
+        if (!id_for_seat) {
                 r = -ENODEV;
                 goto finish;
         }
 
-        if (asprintf(&file, "/etc/udev/rules.d/72-seat-%s.rules", path) < 0) {
+        if (asprintf(&file, "/etc/udev/rules.d/72-seat-%s.rules", id_for_seat) < 0) {
                 r = -ENOMEM;
                 goto finish;
         }
 
-        if (asprintf(&rule, "TAG==\"seat\", ID_PATH==\"%s\", ID_SEAT=\"%s\"", path, seat) < 0) {
+        if (asprintf(&rule, "TAG==\"seat\", ENV{ID_FOR_SEAT}==\"%s\", ENV{ID_SEAT}=\"%s\"", id_for_seat, seat) < 0) {
                 r = -ENOMEM;
                 goto finish;
         }
 
+        mkdir_p("/etc/udev/rules.d", 0755);
         r = write_one_line_file(file, rule);
 
 finish:



More information about the systemd-commits mailing list