From: Yu Watanabe Date: Mon, 8 Jan 2024 17:54:43 +0000 (+0900) Subject: udev: split out check that udev property can be updated X-Git-Tag: v256-rc1~1212^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=513ca8b6f084a3d189039765c304b9addcaa41f6;p=thirdparty%2Fsystemd.git udev: split out check that udev property can be updated --- diff --git a/src/libsystemd/sd-device/device-util.h b/src/libsystemd/sd-device/device-util.h index a9a9b7ad988..534a296715b 100644 --- a/src/libsystemd/sd-device/device-util.h +++ b/src/libsystemd/sd-device/device-util.h @@ -10,6 +10,7 @@ #include "alloc-util.h" #include "log.h" #include "macro.h" +#include "strv.h" #define device_unref_and_replace(a, b) \ unref_and_replace_full(a, b, sd_device_ref, sd_device_unref) @@ -105,3 +106,10 @@ char** device_make_log_fields(sd_device *device); bool device_in_subsystem(sd_device *device, const char *subsystem); bool device_is_devtype(sd_device *device, const char *devtype); + +static inline bool device_property_can_set(const char *property) { + return property && + !STR_IN_SET(property, + "ACTION", "DEVLINKS", "DEVNAME", "DEVPATH", "DEVTYPE", "DRIVER", + "IFINDEX", "MAJOR", "MINOR", "SEQNUM", "SUBSYSTEM", "TAGS"); +} diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 9d01e5866c4..3ec675746bc 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -691,9 +691,7 @@ static int parse_token(UdevRuleLine *rule_line, const char *key, char *attr, Ude } if (!is_match) { - if (STR_IN_SET(attr, - "ACTION", "DEVLINKS", "DEVNAME", "DEVPATH", "DEVTYPE", "DRIVER", - "IFINDEX", "MAJOR", "MINOR", "SEQNUM", "SUBSYSTEM", "TAGS")) + if (!device_property_can_set(attr)) return log_line_error_errno(rule_line, SYNTHETIC_ERRNO(EINVAL), "Invalid ENV attribute. '%s' cannot be set.", attr);