summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2023-03-24 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2023-03-27 10:00:30 +0000
commit860e2a11154b4065691c882dcf05af3f5a14485a (patch)
tree05e4b820a2853b4654a11e73c0501c00c3db6b40 /src/udev
parentacc1954a03940b34aab4b814248e9ddf7e49a901 (diff)
downloadsystemd-860e2a11154b4065691c882dcf05af3f5a14485a.tar.gz
udev-rules: extend the check for conflicting expressions
Log an error when a rule line contains the following kind of conflicting match expressions: KEY=="foo*", KEY=="bar*"
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-rules.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index ecf5989312..c234c265ee 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1348,17 +1348,34 @@ static bool nulstr_tokens_conflict(const UdevRuleToken *a, const UdevRuleToken *
a->op == b->op &&
a->op == OP_MATCH &&
a->match_type == b->match_type &&
- a->match_type == MATCH_TYPE_PLAIN &&
a->attr_subst_type == b->attr_subst_type &&
a->attr_match_remove_trailing_whitespace == b->attr_match_remove_trailing_whitespace &&
token_type_and_data_eq(a, b)))
return false;
- NULSTR_FOREACH(i, a->value)
- if (nulstr_contains(b->value, i))
- return false;
+ if (a->match_type == MATCH_TYPE_PLAIN) {
+ NULSTR_FOREACH(i, a->value)
+ if (nulstr_contains(b->value, i))
+ return false;
+ return true;
+ }
- return true;
+ if (a->match_type == MATCH_TYPE_GLOB) {
+ NULSTR_FOREACH(i, a->value) {
+ size_t i_n = strcspn(i, GLOB_CHARS);
+ if (i_n == 0)
+ return false;
+ NULSTR_FOREACH(j, b->value) {
+ size_t j_n = strcspn(j, GLOB_CHARS);
+ if (j_n == 0 || strneq(i, j, MIN(i_n, j_n)))
+ return false;
+ }
+
+ }
+ return true;
+ }
+
+ return false;
}
static void udev_check_unused_labels(UdevRuleLine *line) {