]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-device: chase sysattr and refuse to read/write files outside of sysfs
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 11 Jan 2025 22:03:49 +0000 (07:03 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Jan 2025 13:54:11 +0000 (22:54 +0900)
commit8d89667abaa8b569c2ac9e37752c404cebdfaaaa
treed6fb400d6e02309b0dc23472f5b4ff6db0ff4f27
parent06503dd0dfda6348b60dee4cf16054d84a25577a
sd-device: chase sysattr and refuse to read/write files outside of sysfs

This makes sd_device_get_sysattr_value()/sd_device_set_sysattr_value()
refuse to read/write files outside of sysfs for safety.

Also this makes
- use chase() to resolve and open the symlink in path to sysfs attribute,
- use delete_trailing_chars(),
- include error code in cache entry, so we can cache more error cases,
- refuse caching value written to uevent file of any devices, i.e.
  sd_device_set_sysattr_value(dev, "../uevent", "add") will also not
  cache the value "add".
src/libsystemd/sd-device/device-private.h
src/libsystemd/sd-device/sd-device.c