X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudev-rules.c;h=85f78bcdefcd19bf9effbdf2eb28926a766d6470;hb=7cfa80f07e94c3e48703d145ef03a73dd6e7b983;hp=47bde618d66484a865105d998e0a22f1f08d703a;hpb=06beed6dc6abeb392b3e2ca8c46fa3169616651e;p=elogind.git diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 47bde618d..85f78bcde 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1142,7 +1142,7 @@ static int add_rule(struct udev_rules *rules, char *line, } if (startswith(key, "ATTR{")) { - attr = get_key_attribute(rules->udev, key + sizeof("ATTR")-1); + attr = get_key_attribute(rules->udev, key + strlen("ATTR")); if (attr == NULL) { log_error("error parsing ATTR attribute"); goto invalid; @@ -1156,7 +1156,7 @@ static int add_rule(struct udev_rules *rules, char *line, } if (startswith(key, "SECLABEL{")) { - attr = get_key_attribute(rules->udev, key + sizeof("SECLABEL")-1); + attr = get_key_attribute(rules->udev, key + strlen("SECLABEL")); if (!attr) { log_error("error parsing SECLABEL attribute"); goto invalid; @@ -1198,7 +1198,7 @@ static int add_rule(struct udev_rules *rules, char *line, log_error("invalid ATTRS operation"); goto invalid; } - attr = get_key_attribute(rules->udev, key + sizeof("ATTRS")-1); + attr = get_key_attribute(rules->udev, key + strlen("ATTRS")); if (attr == NULL) { log_error("error parsing ATTRS attribute"); goto invalid; @@ -1223,7 +1223,7 @@ static int add_rule(struct udev_rules *rules, char *line, } if (startswith(key, "ENV{")) { - attr = get_key_attribute(rules->udev, key + sizeof("ENV")-1); + attr = get_key_attribute(rules->udev, key + strlen("ENV")); if (attr == NULL) { log_error("error parsing ENV attribute"); goto invalid; @@ -1282,7 +1282,7 @@ static int add_rule(struct udev_rules *rules, char *line, } if (startswith(key, "IMPORT")) { - attr = get_key_attribute(rules->udev, key + sizeof("IMPORT")-1); + attr = get_key_attribute(rules->udev, key + strlen("IMPORT")); if (attr == NULL) { log_error("IMPORT{} type missing, ignoring IMPORT %s:%u", filename, lineno); continue; @@ -1328,7 +1328,7 @@ static int add_rule(struct udev_rules *rules, char *line, log_error("invalid TEST operation"); goto invalid; } - attr = get_key_attribute(rules->udev, key + sizeof("TEST")-1); + attr = get_key_attribute(rules->udev, key + strlen("TEST")); if (attr != NULL) { mode = strtol(attr, NULL, 8); rule_add_key(&rule_tmp, TK_M_TEST, op, value, &mode); @@ -1339,7 +1339,7 @@ static int add_rule(struct udev_rules *rules, char *line, } if (startswith(key, "RUN")) { - attr = get_key_attribute(rules->udev, key + sizeof("RUN")-1); + attr = get_key_attribute(rules->udev, key + strlen("RUN")); if (attr == NULL) attr = "program"; @@ -2027,7 +2027,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event case TK_M_PROGRAM: { char program[UTIL_PATH_SIZE]; char **envp; - char result[UTIL_PATH_SIZE]; + char result[UTIL_LINE_SIZE]; free(event->program_result); event->program_result = NULL; @@ -2555,10 +2555,15 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) struct stat stats; /* we assure, that the permissions tokens are sorted before the static token */ + if (mode == 0 && uid == 0 && gid == 0 && tags == NULL) goto next; strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL); + if (stat(device_node, &stats) != 0) + break; + if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode)) + break; /* export the tags to a directory as symlinks, allowing otherwise dead nodes to be tagged */ if (tags) { @@ -2588,11 +2593,6 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) if (mode == 0 && uid == 0 && gid == 0) break; - if (stat(device_node, &stats) != 0) - break; - if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode)) - break; - if (mode == 0) { if (gid > 0) mode = 0660;