X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_rules_parse.c;h=929a5e6f4cca15e3107a1158a22462d048b5f31a;hp=121236820b8d0da1bc22d7e5abd5821c08e36999;hb=a105fe495bdc95a24eaf2db557104534f6e1db34;hpb=bd0ed2ffbec325512c3131ce0db896234e36c923 diff --git a/udev_rules_parse.c b/udev_rules_parse.c index 121236820..929a5e6f4 100644 --- a/udev_rules_parse.c +++ b/udev_rules_parse.c @@ -375,7 +375,29 @@ static int rules_parse(const char *filename) continue; } - if (strcasecmp(key, KEY_IMPORT) == 0) { + if (strncasecmp(key, KEY_IMPORT, sizeof(KEY_IMPORT)-1) == 0) { + attr = get_key_attribute(key + sizeof(KEY_IMPORT)-1); + if (attr && strstr(attr, "program")) { + dbg(KEY_IMPORT" will be executed"); + rule.import_exec = 1; + } else if (attr && strstr(attr, "file")) { + dbg(KEY_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(KEY_IMPORT" auto mode for '%s'", file); + if (!lstat(file, &stats) && (stats.st_mode & S_IXUSR)) { + dbg(KEY_IMPORT" is executable, will be executed"); + rule.import_exec = 1; + } + } strlcpy(rule.import, value, sizeof(rule.import)); rule.import_operation = operation; valid = 1; @@ -411,7 +433,6 @@ static int rules_parse(const char *filename) dbg("creation of partition nodes requested"); rule.partitions = DEFAULT_PARTITIONS_COUNT; } - /* FIXME: remove old style option and make OPTIONS= mandatory */ if (strstr(attr, OPTION_IGNORE_REMOVE) != NULL) { dbg("remove event should be ignored"); rule.ignore_remove = 1;