1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-06 12:58:22 +03:00

udev-rules: fix negative match rule for SYMLINK and TAG

Fixes #27396.

(cherry picked from commit 2b43ab00b08a052fc0077dd20f111c474730ad52)
This commit is contained in:
Yu Watanabe 2023-04-25 19:09:55 +09:00 committed by Luca Boccassi
parent a25e2ef992
commit cd795f9abc
2 changed files with 11 additions and 8 deletions

View File

@ -186,10 +186,10 @@
<varlistentry>
<term><varname>SYMLINK</varname></term>
<listitem>
<para>Match the name of a symlink targeting the node. It can
be used once a SYMLINK key has been set in one of the preceding
rules. There may be multiple symlinks; only one needs to match.
</para>
<para>Match the name of a symlink targeting the node. It can be used once a SYMLINK key has
been set in one of the preceding rules. There may be multiple symlinks; only one needs to
match. If the operator is <literal>!=</literal>, the token returns true only if there is no
symlink matched.</para>
</listitem>
</varlistentry>
@ -287,14 +287,17 @@
<varlistentry>
<term><varname>TAG</varname></term>
<listitem>
<para>Match against a device tag.</para>
<para>Match against one of device tags. It can be used once a TAG key has been set in one of
the preceding rules. There may be multiple tags; only one needs to match. If the operator is
<literal>!=</literal>, the token returns true only if there is no tag matched.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>TAGS</varname></term>
<listitem>
<para>Search the devpath upwards for a device with matching tag.</para>
<para>Search the devpath upwards for a device with matching tag. If the operator is
<literal>!=</literal>, the token returns true only if there is no tag matched.</para>
</listitem>
</varlistentry>

View File

@ -1607,7 +1607,7 @@ static int udev_rule_apply_token_to_event(
const char *val;
FOREACH_DEVICE_DEVLINK(dev, val)
if (token_match_string(token, strempty(startswith(val, "/dev/"))))
if (token_match_string(token, strempty(startswith(val, "/dev/"))) == (token->op == OP_MATCH))
return token->op == OP_MATCH;
return token->op == OP_NOMATCH;
}
@ -1637,7 +1637,7 @@ static int udev_rule_apply_token_to_event(
const char *val;
FOREACH_DEVICE_CURRENT_TAG(dev, val)
if (token_match_string(token, val))
if (token_match_string(token, val) == (token->op == OP_MATCH))
return token->op == OP_MATCH;
return token->op == OP_NOMATCH;
}