summaryrefslogtreecommitdiffstats
path: root/src/udev/udev-rules.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-04-07 01:45:35 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-04-07 21:49:46 +0200
commit0b4c70b47a6dea1841a3be5c132d562d71efe182 (patch)
treed0a07493b709df40058960c1672f2326b8a3046c /src/udev/udev-rules.c
parentsd-device,udev: refuse invalid devlink and store in normalized form (diff)
downloadsystemd-0b4c70b47a6dea1841a3be5c132d562d71efe182.tar.xz
systemd-0b4c70b47a6dea1841a3be5c132d562d71efe182.zip
sd-device,udev: tag must be a valid filename
All tags are managed under /run/udev/tags, and the directories there are named with tags. Hence, each tag must be a valid filename. This also makes all validity check moved to sd-device side, and makes failure caused by setting invalid tags non-critical. With this change, an empty string cannot be assigned to TAG=, hence the test cases are adjusted.
Diffstat (limited to 'src/udev/udev-rules.c')
-rw-r--r--src/udev/udev-rules.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 68f0a363be..e3d2adbafd 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2487,16 +2487,14 @@ static int udev_rule_apply_token_to_event(
if (token->op == OP_ASSIGN)
device_cleanup_tags(dev);
- if (buf[strspn(buf, ALPHANUMERICAL "-_")] != '\0') {
- log_event_error(dev, token, "Invalid tag name '%s', ignoring", buf);
- break;
- }
if (token->op == OP_REMOVE)
device_remove_tag(dev, buf);
else {
r = device_add_tag(dev, buf, true);
+ if (r == -ENOMEM)
+ return log_oom();
if (r < 0)
- return log_event_error_errno(dev, token, r, "Failed to add tag '%s': %m", buf);
+ log_event_warning_errno(dev, token, r, "Failed to add tag '%s', ignoring: %m", buf);
}
break;
}