New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
udevadm verify: add more checks #26980
Conversation
ldv-alt
commented
Mar 25, 2023
- extend the check for conflicting expressions
- check token delimiters
The failures are caused by c5ba7a2, maybe missing space before the line continuation? |
|
centos8 error |
|
jammy-ppc64el errors are also unrelated: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Several coding style comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, two suggestions about wording.
Move udev_rules_parse_file() after udev_check_rule_line() as the former us going to use the latter.
Move udev_check_rule_line() invocation from udev_rule_file_get_issues() to udev_rules_parse_file(), invoke udev_check_rule_line() only when udev_rules_parse_file() is called by udevadm verify. Subsequent commits are going to perform more checks invoked from udev_rules_parse_file().
When udev_rules_parse_file() is called by udevadm verify, issue warnings about the following conditions in udev rules: * the first token in the rule is preceded with a comma * the last token in the rule is followed by a comma * there is no comma between tokens * there is no whitespace between tokens * there is more than a single comma between tokens * there is whitespace between a token and a comma * there is no whitespace after comma
Log an error when a rule line contains the following kind of conflicting match expressions: KEY=="foo*", KEY=="bar*"
Fixes: 25de7aa ("udev: modernize udev-rules.c")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM.
|
LGTM too.
That's a bit too strong ;) It was grammatically correct, it was just a bit off semantically. But it's fine, let's merge this. |
|
I just received a multipath-tools PR for this. I have to say I'm irritated. This PR introduces new syntax restrictions to udev rules that didn't exist before, in particular the rule to add whitespace after a comma. The multipath-tools PR tries to enforce this rule for commas before a line continuation, where it's non-obvious to me that the readability of the rules is improved at all. I have nothing against systemd improving the readability of its own rules files, and using a test tool for verifying the added syntax rules. But I find it questionable to enforce such additional restrictions on other projects without even mentioning that they are new. Side note: I did a quick test and actually found that (contrary to what the man page says) the tokenizer doesn't even enforce a comma, as it uses the required closing quote of the "value" part of the token as token delimiter: works (just a remark; I know that the man page demands the comma). |
|
We're trying to make the rules as readable as possible for humans. The rules on what is actually accepted haven't changed. The changes that the verifier is suggesting should make the rules more readable. That said, I think we could relax the check to accept a line continuation without a space. There is whitespace there, we just completely strip it off when consuming the continuation symbol. @ldv-alt could we make the second patch in opensvc/multipath-tools#66 not necessary? |
Ok. I agree, of course, that human-readable rules are a good thing. But from the multipath-tools PR, it was neither obvious that this syntax verification was a new feature, nor that it was stricter than the parser itself, and mainly targeted at improving readability. Also, past experience would at least make me suspect that a future change might actually change what the parser accepts. If that isn't the case, fine with me. |
|
For the sake of completeness, here is the message I sent earlier to the mailing list: |
@keszybz, I thought about this before. Unfortunately, this issue is not as obvious as it looks from the first glance. as an equivalent to Both line continuations and leading whitespace removal are processed by the parser before parsing the line itself, I'd rather not step into these murky waters unnecessarily. |
Fix warnings reported by udevadm verify: multipath/11-dm-mpath.rules:18 Whitespace after comma is expected. ... multipath/11-dm-mpath.rules: udev rules check failed Note (mwilck): technically, the syntax of the udev rules was correct; they are parsed and executed by udev correctly, and this is unlikely to change. But systemd has enabled stricter checks in "udevadm verify" to ensure better readability of udev rules files (systemd/systemd#26980). This commit makes sure the multipath-tools rules comply with these checks. Signed-off-by: Dmitry V. Levin <ldv@strace.io> Reviewed-by: Martin Wilck <mwilck@suse.com>