]> err.no Git - systemd/commitdiff
fix $attr{[<subsystem>/<sysname>]<attribute>} substitution
authorKay Sievers <kay.sievers@vrfy.org>
Sun, 26 Oct 2008 01:48:14 +0000 (02:48 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Sun, 26 Oct 2008 01:48:14 +0000 (02:48 +0100)
test/udev-test.pl
udev/udev-event.c

index f630b74a9d859247ed96ab3ed38e282e15d0577d..767f6adeb4e10f6bac23e8ddd1eb2fe5077cca5e 100755 (executable)
@@ -1654,6 +1654,16 @@ EOF
                rules           => <<EOF
 KERNEL=="sda", MODE="440"
 KERNEL=="sda", PROGRAM=="/bin/echo 0 0 0400letsdoabuffferoverflow0123456789012345789012345678901234567890", OWNER="%c{1}", GROUP="%c{2}", MODE="%c{3}"
+EOF
+       },
+       {
+               desc            => "magic [subsys/sysname] attribute substitution",
+               subsys          => "block",
+               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+               exp_name        => "sda-8741C4G-end",
+               exp_perms       => "0:0:0660",
+               rules           => <<EOF
+KERNEL=="sda", NAME="%k-%s{[dmi/id]product_name}-end"
 EOF
        },
 
index e297df03834a62c94ae29cca47208bf1c0a51c53..02c5c99dc1b4b6cfc2b7b46497c3ac1bb2dbc435 100644 (file)
@@ -295,13 +295,17 @@ found:
                                size_t size;
 
                                value[0] = '\0';
+                               /* read the value specified by [usb/]*/
                                util_resolve_subsys_kernel(event->udev, attr, value, sizeof(value), 1);
 
-                               val = udev_device_get_sysattr_value(event->dev, attr);
-                               if (val != NULL)
-                                       util_strlcpy(value, val, sizeof(value));
+                               /* try to read attribute of the current device */
+                               if (value[0] == '\0') {
+                                       val = udev_device_get_sysattr_value(event->dev, attr);
+                                       if (val != NULL)
+                                               util_strlcpy(value, val, sizeof(value));
+                               }
 
-                               /* try the current device, other matches may have selected */
+                               /* try to read the attribute of the parent device, other matches have selected */
                                if (value[0] == '\0' && event->dev_parent != NULL && event->dev_parent != event->dev) {
                                        val = udev_device_get_sysattr_value(event->dev_parent, attr);
                                        if (val != NULL)