X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_rules_parse.c;h=929a5e6f4cca15e3107a1158a22462d048b5f31a;hp=4979feddc1da4d264fad75c70cf3cf8c708d0a7b;hb=ffd5c6893756af43daf2a9a30bdcff13784a1ec4;hpb=319c6700165dc38d7f813ff646bff0196f2aafe6 diff --git a/udev_rules_parse.c b/udev_rules_parse.c index 4979feddc..929a5e6f4 100644 --- a/udev_rules_parse.c +++ b/udev_rules_parse.c @@ -377,9 +377,26 @@ static int rules_parse(const char *filename) if (strncasecmp(key, KEY_IMPORT, sizeof(KEY_IMPORT)-1) == 0) { attr = get_key_attribute(key + sizeof(KEY_IMPORT)-1); - if (attr && strstr(attr, "exec")) { + 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;