not_exp_name => "node",
exp_add_error => "yes",
rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", OPTIONS="ignore"
+SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", OPTIONS="ignore_device"
EOF
},
{
subsys => "tty",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
exp_name => "<none>",
+ not_exp_name => "ttyACM0",
+ exp_add_error => "yes",
+ rules => <<EOF
+KERNEL=="ttyACM[0-9]*", NAME=""
+EOF
+ },
+ {
+ desc => "test empty NAME (empty override)",
+ subsys => "tty",
+ devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
+ exp_name => "<none>",
not_exp_name => "wrong",
exp_add_error => "yes",
rules => <<EOF
EOF
},
{
- desc => "test empty NAME 2",
+ desc => "test empty NAME (non-empty override)",
subsys => "tty",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
exp_name => "right",
rules => <<EOF
TEST=="/etc/hosts", NAME="there"
TEST!="/etc/hosts", NAME="notthere"
-EOF
- },
- {
- desc => "TEST invalid NAME= only (skip invalid rule)",
- subsys => "block",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "yes",
- rules => <<EOF
-SUBSYSTEM=="block", NAME="yes"
-NAME="no"
EOF
},
{
udev("add", $rules->{subsys}, $rules->{devpath}, \$rules->{rules});
+ if (defined($rules->{not_exp_name})) {
+ if ((-e "$PWD/$udev_root$rules->{not_exp_name}") ||
+ (-l "$PWD/$udev_root$rules->{not_exp_name}")) {
+ print "nonexistent: error \'$rules->{not_exp_name}\' not expected to be there\n";
+ $error++
+ }
+ }
+
if ((-e "$PWD/$udev_root$rules->{exp_name}") ||
(-l "$PWD/$udev_root$rules->{exp_name}")) {
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$rules->{exp_name}");
- if (defined($rules->{not_exp_name})) {
- if ((-e "$PWD/$udev_root$rules->{not_exp_name}") ||
- (-l "$PWD/$udev_root$rules->{not_exp_name}")) {
- print "nonexistent: error \'$rules->{not_exp_name}\' not expected to be there\n";
- $error++
- }
- }
if (defined($rules->{exp_perms})) {
permissions_test($rules, $uid, $gid, $mode);
}
static int add_rule(struct udev_rules *rules, char *line,
const char *filename, unsigned int filename_off, unsigned int lineno)
{
- int valid = 0;
char *linepos;
char *attr;
int physdev = 0;
goto invalid;
}
rule_add_key(&rule_tmp, TK_M_ACTION, op, value, NULL);
- valid = 1;
continue;
}
goto invalid;
}
rule_add_key(&rule_tmp, TK_M_DEVPATH, op, value, NULL);
- valid = 1;
continue;
}
goto invalid;
}
rule_add_key(&rule_tmp, TK_M_KERNEL, op, value, NULL);
- valid = 1;
continue;
}
rule_add_key(&rule_tmp, TK_M_SUBSYSTEM, op, "subsystem|class|bus", NULL);
} else
rule_add_key(&rule_tmp, TK_M_SUBSYSTEM, op, value, NULL);
- valid = 1;
continue;
}
goto invalid;
}
rule_add_key(&rule_tmp, TK_M_DRIVER, op, value, NULL);
- valid = 1;
continue;
}
} else {
rule_add_key(&rule_tmp, TK_A_ATTR, op, value, attr);
}
- valid = 1;
continue;
}
goto invalid;
}
rule_add_key(&rule_tmp, TK_M_KERNELS, op, value, NULL);
- valid = 1;
continue;
}
goto invalid;
}
rule_add_key(&rule_tmp, TK_M_SUBSYSTEMS, op, value, NULL);
- valid = 1;
continue;
}
goto invalid;
}
rule_add_key(&rule_tmp, TK_M_DRIVERS, op, value, NULL);
- valid = 1;
continue;
}
err(rules->udev, "do not reference parent sysfs directories directly, "
"it may break with a future kernel, please fix it in %s:%u", filename, lineno);
rule_add_key(&rule_tmp, TK_M_ATTRS, op, value, attr);
- valid = 1;
continue;
}
if (rule_add_key(&rule_tmp, TK_A_ENV, op, value, attr) != 0)
goto invalid;
}
- valid = 1;
continue;
}
if (strcasecmp(key, "PROGRAM") == 0) {
rule_add_key(&rule_tmp, TK_M_PROGRAM, op, value, NULL);
- valid = 1;
continue;
}
goto invalid;
}
rule_add_key(&rule_tmp, TK_M_RESULT, op, value, NULL);
- valid = 1;
continue;
}
if (attr != NULL && strstr(attr, "program")) {
dbg(rules->udev, "IMPORT will be executed\n");
rule_add_key(&rule_tmp, TK_M_IMPORT_PROG, op, value, NULL);
- valid = 1;
} else if (attr != NULL && strstr(attr, "file")) {
dbg(rules->udev, "IMPORT will be included as file\n");
rule_add_key(&rule_tmp, TK_M_IMPORT_FILE, op, value, NULL);
- valid = 1;
} else if (attr != NULL && strstr(attr, "parent")) {
dbg(rules->udev, "IMPORT will include the parent values\n");
rule_add_key(&rule_tmp, TK_M_IMPORT_PARENT, op, value, NULL);
- valid = 1;
} else {
/* figure it out if it is executable */
char file[UTIL_PATH_SIZE];
if (!lstat(file, &statbuf) && (statbuf.st_mode & S_IXUSR)) {
dbg(rules->udev, "IMPORT will be executed (autotype)\n");
rule_add_key(&rule_tmp, TK_M_IMPORT_PROG, op, value, NULL);
- valid = 1;
} else {
dbg(rules->udev, "IMPORT will be included as file (autotype)\n");
rule_add_key(&rule_tmp, TK_M_IMPORT_FILE, op, value, NULL);
- valid = 1;
}
}
continue;
} else {
rule_add_key(&rule_tmp, TK_M_TEST, op, value, NULL);
}
- valid = 1;
continue;
}
if (attr != NULL && strstr(attr, "ignore_error"))
flag = 1;
rule_add_key(&rule_tmp, TK_A_RUN, op, value, &flag);
- valid = 1;
continue;
}
if (strcasecmp(key, "WAIT_FOR") == 0 || strcasecmp(key, "WAIT_FOR_SYSFS") == 0) {
rule_add_key(&rule_tmp, TK_M_WAITFOR, 0, value, NULL);
- valid = 1;
waitfor = 1;
continue;
}
if (strcasecmp(key, "LABEL") == 0) {
rule_tmp.rule.rule.label_off = add_string(rules, value);
- valid = 1;
continue;
}
if (strcasecmp(key, "GOTO") == 0) {
rule_add_key(&rule_tmp, TK_A_GOTO, 0, value, NULL);
- valid = 1;
continue;
}
rule_add_key(&rule_tmp, TK_M_NAME, op, value, NULL);
} else {
if (value[0] == '\0')
- dbg(rules->udev, "name empty, node creation suppressed\n");
+ info(rules->udev, "name empty, node creation suppressed\n");
rule_add_key(&rule_tmp, TK_A_NAME, op, value, NULL);
attr = get_key_attribute(rules->udev, key + sizeof("NAME")-1);
if (attr != NULL) {
else
rule_add_key(&rule_tmp, TK_A_DEVLINK, op, value, NULL);
rule_tmp.rule.rule.flags = 1;
- valid = 1;
continue;
}
rule_add_key(&rule_tmp, TK_A_OWNER, op, value, NULL);
}
rule_tmp.rule.rule.flags = 1;
- valid = 1;
continue;
}
rule_add_key(&rule_tmp, TK_A_GROUP, op, value, NULL);
}
rule_tmp.rule.rule.flags = 1;
- valid = 1;
continue;
}
else
rule_add_key(&rule_tmp, TK_A_MODE, op, value, NULL);
rule_tmp.rule.rule.flags = 1;
- valid = 1;
continue;
}
rule_add_key(&rule_tmp, TK_A_NUM_FAKE_PART, 0, NULL, &num);
dbg(rules->udev, "creation of partition nodes requested\n");
}
- valid = 1;
continue;
}
err(rules->udev, "unknown key '%s' in %s:%u\n", key, filename, lineno);
err(rules->udev, "PHYSDEV* values are deprecated and not available on recent kernels, "
"please fix it in %s:%u\n", filename, lineno);
- /* skip line if no valid key was found */
- if (!valid)
- goto invalid;
-
/* add rule token */
rule_tmp.rule.rule.token_count = 1 + rule_tmp.token_cur;
if (add_token(rules, &rule_tmp.rule) != 0)
break;
if (cur->key.op == OP_ASSIGN_FINAL)
event->name_final = 1;
- if (name[0] == '\0') {
- free(event->name);
- event->name = NULL;
- break;
- }
util_strlcpy(name_str, name, sizeof(name_str));
udev_event_apply_format(event, name_str, sizeof(name_str));
if (esc == ESCAPE_UNSET || esc == ESCAPE_REPLACE) {