]> err.no Git - systemd/commitdiff
allow setting of MODE="0000"
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 18 Apr 2008 19:07:29 +0000 (21:07 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 18 Apr 2008 19:07:29 +0000 (21:07 +0200)
test/udev-test.pl
udev_rules.c
udev_rules.h
udev_rules_parse.c

index 2621e2b13ae6baad2feb9245ff5aae9c058e2d86..fee62a64060e155b6d5ba722514a2dbe66c8e01a 100755 (executable)
@@ -1605,6 +1605,16 @@ EOF
                exp_name        => "found-subdir",
                rules           => <<EOF
 KERNEL=="sda", TEST=="*/nr_requests", NAME="found-subdir"
+EOF
+       },
+       {
+               desc            => "TEST MODE=0000",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "sda",
+               exp_perms       => "0:0:0000",
+               rules           => <<EOF
+KERNEL=="sda", MODE="0000"
 EOF
        },
 );
index 6565a2e51d17fa63d7cc516abe9e712284fce8e7..8a793ffded484552bcdf1bca23bb10f4f044379d 100644 (file)
@@ -1385,11 +1385,11 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev)
                        }
 
                        /* apply permissions */
-                       if (!udev->mode_final && rule->mode != 0000) {
-                               if (rule->mode_operation == KEY_OP_ASSIGN_FINAL)
+                       if (!udev->mode_final && rule->mode.operation != KEY_OP_UNSET) {
+                               if (rule->mode.operation == KEY_OP_ASSIGN_FINAL)
                                        udev->mode_final = 1;
-                               udev->mode = rule->mode;
-                               dbg("applied mode=%#o to '%s'", rule->mode, udev->dev->kernel);
+                               udev->mode = strtol(key_val(rule, &rule->mode), NULL, 8);
+                               dbg("applied mode=%#o to '%s'", udev->mode, udev->dev->kernel);
                        }
                        if (!udev->owner_final && rule->owner.operation != KEY_OP_UNSET) {
                                if (rule->owner.operation == KEY_OP_ASSIGN_FINAL)
@@ -1534,7 +1534,7 @@ int udev_rules_get_run(struct udev_rules *rules, struct udevice *udev)
                    rule->symlink.operation == KEY_OP_ASSIGN ||
                    rule->symlink.operation == KEY_OP_ASSIGN_FINAL ||
                    rule->symlink.operation == KEY_OP_ADD ||
-                   rule->mode_operation != KEY_OP_UNSET ||
+                   rule->mode.operation != KEY_OP_UNSET ||
                    rule->owner.operation != KEY_OP_UNSET || rule->group.operation != KEY_OP_UNSET) {
                        dbg("skip rule that names a device");
                        continue;
index 0ad4ec3271b4446465c37b0d1dde2d721802487b..a84b0de83760fdf57fb92dc2e5312d084e18eff0 100644 (file)
@@ -93,8 +93,7 @@ struct udev_rule {
        struct key symlink_match;
        struct key owner;
        struct key group;
-       mode_t mode;
-       enum key_operation mode_operation;
+       struct key mode;
        enum escape_type string_escape;
 
        unsigned int link_priority;
index ce659d73ce8eb815d2cd3b0baad4ec7df5e47e81..6d88354dbddbb5337355eefb234f2455d9f2fbd6 100644 (file)
@@ -579,8 +579,7 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena
                }
 
                if (strcasecmp(key, "MODE") == 0) {
-                       rule->mode = strtol(value, NULL, 8);
-                       rule->mode_operation = operation;
+                       add_rule_key(rule, &rule->mode, operation, value);
                        valid = 1;
                        continue;
                }