X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_rules_parse.c;h=7c3c2e7fc252698aed9bb4be6c3d0c551a588b14;hp=2ec9348b01c55e342c1e8b20f11cdd3f32b23e90;hb=8365854ccda3d0f36333b699454238cff111e169;hpb=8bd41f36f793f7fc208ef6beb4b2b84e35a5e728 diff --git a/udev_rules_parse.c b/udev_rules_parse.c index 2ec9348b0..7c3c2e7fc 100644 --- a/udev_rules_parse.c +++ b/udev_rules_parse.c @@ -284,6 +284,12 @@ static int add_to_rules(struct udev_rules *rules, char *line) continue; } + if (strcasecmp(key, "WAIT_FOR_SYSFS") == 0) { + add_rule_key(rule, &rule->wait_for_sysfs, operation, value); + valid = 1; + continue; + } + if (strncasecmp(key, "ENV", sizeof("ENV")-1) == 0) { attr = get_key_attribute(key + sizeof("ENV")-1); if (attr == NULL) { @@ -305,9 +311,13 @@ static int add_to_rules(struct udev_rules *rules, char *line) attr = get_key_attribute(key + sizeof("IMPORT")-1); if (attr && strstr(attr, "program")) { dbg("IMPORT will be executed"); - rule->import_exec = 1; + rule->import_type = IMPORT_PROGRAM; } else if (attr && strstr(attr, "file")) { dbg("IMPORT will be included as file"); + rule->import_type = IMPORT_FILE; + } else if (attr && strstr(attr, "parent")) { + dbg("IMPORT will include the parent values"); + rule->import_type = IMPORT_PARENT; } else { /* figure it out if it is executable */ char file[PATH_SIZE]; @@ -320,8 +330,11 @@ static int add_to_rules(struct udev_rules *rules, char *line) pos[0] = '\0'; dbg("IMPORT auto mode for '%s'", file); if (!lstat(file, &stats) && (stats.st_mode & S_IXUSR)) { - dbg("IMPORT is executable, will be executed"); - rule->import_exec = 1; + dbg("IMPORT is executable, will be executed (autotype)"); + rule->import_type = IMPORT_PROGRAM; + } else { + dbg("IMPORT is not executable, will be included as file (autotype)"); + rule->import_type = IMPORT_FILE; } } add_rule_key(rule, &rule->import, operation, value); @@ -359,7 +372,12 @@ static int add_to_rules(struct udev_rules *rules, char *line) rule->ignore_remove = 1; } } - add_rule_key(rule, &rule->name, operation, value); + if (value[0] == '\0') { + dbg("name empty device should be ignored"); + rule->name.operation = operation; + rule->ignore_device = 1; + } else + add_rule_key(rule, &rule->name, operation, value); continue; } @@ -371,7 +389,7 @@ static int add_to_rules(struct udev_rules *rules, char *line) if (strcasecmp(key, "OWNER") == 0) { valid = 1; - if (rules->resolve_names) { + if (rules->resolve_names && (!strchr(value, '$') && !strchr(value, '%'))) { char *endptr; strtoul(value, &endptr, 10); if (endptr[0] != '\0') { @@ -390,7 +408,7 @@ static int add_to_rules(struct udev_rules *rules, char *line) if (strcasecmp(key, "GROUP") == 0) { valid = 1; - if (rules->resolve_names) { + if (rules->resolve_names && (!strchr(value, '$') && !strchr(value, '%'))) { char *endptr; strtoul(value, &endptr, 10); if (endptr[0] != '\0') { @@ -398,7 +416,7 @@ static int add_to_rules(struct udev_rules *rules, char *line) gid_t gid = lookup_group(value); dbg("replacing groupname='%s' by id=%i", value, gid); sprintf(group, "%li", gid); - add_rule_key(rule, &rule->owner, operation, group); + add_rule_key(rule, &rule->group, operation, group); continue; } } @@ -537,6 +555,7 @@ static int rules_map(struct udev_rules *rules, const char *filename) rules->buf = NULL; return -1; } + rules->mapped = 1; return 0; }