- if (strcasecmp(key, KEY_ID) == 0) {
- strlcpy(rule.id, value, sizeof(rule.id));
- rule.id_operation = operation;
- valid = 1;
- 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")) {
+ dbg("IMPORT will be executed");
+ 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];
+ 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 (autotype)");
+ rule->import_type = IMPORT_PROGRAM;
+ } else {
+ dbg("IMPORT is not executable, will be included as file (autotype)");
+ rule->import_type = IMPORT_FILE;
+ }