}
if (strncasecmp(key, "SYSFS", sizeof("SYSFS")-1) == 0) {
+ if (operation != KEY_OP_MATCH &&
+ operation != KEY_OP_NOMATCH) {
+ err("invalid SYSFS operation");
+ goto invalid;
+ }
attr = get_key_attribute(key + sizeof("SYSFS")-1);
if (attr == NULL) {
err("error parsing SYSFS attribute in '%s'", line);
continue;
}
- if (strcasecmp(key, "MODALIAS") == 0) {
- add_rule_key(rule, &rule->modalias, operation, value);
- valid = 1;
- continue;
- }
-
if (strncasecmp(key, "IMPORT", sizeof("IMPORT")-1) == 0) {
attr = get_key_attribute(key + sizeof("IMPORT")-1);
if (attr && strstr(attr, "program")) {
}
if (strcasecmp(key, "DRIVER") == 0) {
+ if (operation != KEY_OP_MATCH &&
+ operation != KEY_OP_NOMATCH) {
+ err("invalid DRIVER operation");
+ goto invalid;
+ }
add_rule_key(rule, &rule->driver, operation, value);
valid = 1;
continue;
}
if (strcasecmp(key, "RESULT") == 0) {
+ if (operation != KEY_OP_MATCH &&
+ operation != KEY_OP_NOMATCH) {
+ err("invalid RESULT operation");
+ goto invalid;
+ }
add_rule_key(rule, &rule->result, operation, value);
valid = 1;
continue;
continue;
}
- err("unknown key '%s'", key);
+ err("unknown key '%s' in %s:%u", key, filename, lineno);
}
/* skip line if not any valid key was found */
cur += count+1;
lineno++;
- if (count >= sizeof(line)) {
- err("line too long, rule skipped '%s:%u'", filename, lineno);
- continue;
- }
-
/* eat the whitespace */
while ((count > 0) && isspace(bufline[0])) {
bufline++;
if (bufline[0] == COMMENT_CHARACTER)
continue;
- /* skip backslash and newline from multi line rules */
+ if (count >= sizeof(line)) {
+ err("line too long, rule skipped '%s:%u'", filename, lineno);
+ continue;
+ }
+
+ /* skip backslash and newline from multiline rules */
for (i = j = 0; i < count; i++) {
if (bufline[i] == '\\' && bufline[i+1] == '\n')
continue;