chiark / gitweb /
fix tests and allow MODE=000
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 20 May 2010 12:51:18 +0000 (14:51 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Thu, 20 May 2010 12:51:18 +0000 (14:51 +0200)
test/udev-test.pl
udev/udev-event.c

index 24e62b4..6a0ea82 100755 (executable)
@@ -610,7 +610,7 @@ EOF
                subsys          => "tty",
                devpath         => "/devices/virtual/tty/tty33",
                exp_name        => "tty33",
-               exp_perms       => "0:0:0660",
+               exp_perms       => "0:0:0600",
                rules           => <<EOF
 KERNEL=="tty33", SYMLINK+="tty33", OWNER="bad", GROUP="name"
 EOF
@@ -620,7 +620,7 @@ EOF
                subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
-               exp_perms       => "5000::0660",
+               exp_perms       => "5000::0600",
                rules           => <<EOF
 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="5000"
 EOF
@@ -640,7 +640,7 @@ EOF
                subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
-               exp_perms       => "nobody::0660",
+               exp_perms       => "nobody::0600",
                rules           => <<EOF
 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="nobody"
 EOF
@@ -1487,7 +1487,7 @@ EOF
                subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "sda",
-               exp_perms       => "0:0:0660",
+               exp_perms       => "0:0:0600",
                exp_rem_error   => "yes",
                rules           => <<EOF
 KERNEL=="sda", MODE="440"
@@ -1499,7 +1499,7 @@ EOF
                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",
+               exp_perms       => "0:0:0600",
                rules           => <<EOF
 KERNEL=="sda", PROGRAM="/bin/true create-envp"
 KERNEL=="sda", ENV{TESTENV}="change-envp"
index ad6db83..9c2ce1d 100644 (file)
@@ -38,6 +38,7 @@ struct udev_event *udev_event_new(struct udev_device *dev)
        event = calloc(1, sizeof(struct udev_event));
        if (event == NULL)
                return NULL;
+       event->mode = 0600;
        event->dev = dev;
        event->udev = udev_device_get_udev(dev);
        udev_list_init(&event->run_list);
@@ -643,12 +644,10 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules)
                        if (event->dev_db != NULL)
                                udev_node_update_old_links(dev, event->dev_db);
 
-                       if (event->mode == 0) {
-                               if (event->gid > 0)
-                                       event->mode = 0660;
-                               else
-                                       event->mode = 0600;
-                       }
+                       /* change default 0600 to 0660 if a group is assigned */
+                       if (event->mode == 0600 && event->gid > 0)
+                               event->mode = 0660;
+
                        err = udev_node_add(dev, event->mode, event->uid, event->gid);
                }