+ pair = &rule.sysfs_pair[rule.sysfs_pair_count];
+ attr = get_key_attribute(key + sizeof("SYSFS")-1);
+ if (attr == NULL) {
+ err("error parsing SYSFS attribute");
+ goto error;
+ }
+ strlcpy(pair->name, attr, sizeof(pair->name));
+ strlcpy(pair->value, value, sizeof(pair->value));
+ pair->operation = operation;
+ rule.sysfs_pair_count++;
+ valid = 1;
+ continue;
+ }
+
+ if (strncasecmp(key, "ENV", sizeof("ENV")-1) == 0) {
+ struct key_pair *pair;
+
+ if (rule.env_pair_count >= KEY_ENV_PAIRS_MAX) {
+ err("skip rule, to many ENV keys in a single rule");
+ goto error;
+ }
+ pair = &rule.env_pair[rule.env_pair_count];
+ attr = get_key_attribute(key + sizeof("ENV")-1);
+ if (attr == NULL) {
+ err("error parsing ENV attribute");
+ continue;
+ }
+ strlcpy(pair->name, attr, sizeof(pair->name));
+ strlcpy(pair->value, value, sizeof(pair->value));
+ pair->operation = operation;
+ rule.env_pair_count++;
+ valid = 1;
+ continue;
+ }
+
+ if (strcasecmp(key, "MODALIAS") == 0) {
+ strlcpy(rule.modalias, value, sizeof(rule.modalias));
+ rule.modalias_operation = operation;
+ valid = 1;
+ continue;
+ }
+
+ if (strncasecmp(key, "IMPORT", sizeof("IMPORT")-1) == 0) {
+ attr = get_key_attribute(key + sizeof("IMPORT")-1);
+ if (attr && strstr(attr, "program")) {
+ dbg("IMPORT will be executed");
+ rule.import_exec = 1;
+ } else if (attr && strstr(attr, "file")) {
+ dbg("IMPORT will be included as file");
+ } else {
+ /* figure it out if it is executable */
+ char file[PATH_SIZE];
+ char *pos;
+ struct stat stats;
+
+ strlcpy(file, value, sizeof(file));
+ pos = strchr(file, ' ');
+ if (pos)
+ 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;