From: Dmitry V. Levin Date: Fri, 10 Mar 2023 08:00:00 +0000 (+0000) Subject: udev_rules_parse_file: issue diagnostics about duplicate LABEL tokens X-Git-Tag: v254-rc1~1062^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b2f7bb760ac75820ee82a7dbaa23b7c21c08e2de;p=thirdparty%2Fsystemd.git udev_rules_parse_file: issue diagnostics about duplicate LABEL tokens When a rules contains several LABEL tokens, the parser used to silently discard all of them besides the last one without any diagnostics at all. It's time to break the vow of silence and let the parser issue a warning. --- diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 9d831a60047..5e7d8d390e4 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1014,6 +1014,9 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp return log_token_invalid_attr(rules, key); if (op != OP_ASSIGN) return log_token_invalid_op(rules, key); + if (FLAGS_SET(rule_line->type, LINE_HAS_LABEL)) + log_token_warning(rules, "Contains multiple LABEL keys, ignoring LABEL=\"%s\".", + rule_line->label); rule_line->label = value; SET_FLAG(rule_line->type, LINE_HAS_LABEL, true); diff --git a/test/units/testsuite-17.11.sh b/test/units/testsuite-17.11.sh index 9a404781e7d..363040c28c9 100755 --- a/test/units/testsuite-17.11.sh +++ b/test/units/testsuite-17.11.sh @@ -262,6 +262,19 @@ ${rules}: udev rules check failed EOF assert_1 "${rules}" +cat >"${rules}" <<'EOF' +GOTO="a" +LABEL="a", LABEL="b" +EOF +cat >"${exp}" <"${workdir}/${exp}" cd -