summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-01-22 11:45:40 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-01-22 14:51:02 +0900
commita3ce813697bcc1c4644e097a2f1cd0459326d6ee (patch)
tree45a9f98044b5edb87fe4602369ae5569cb88c5c9
parent61a38e02650b8e7f097cadaa40aab0847605a383 (diff)
downloadsystemd-a3ce813697bcc1c4644e097a2f1cd0459326d6ee.tar.gz
sd-device: do not save e.g., DEVPATH or INTERFACE properties to udev database
Previously, device_copy_properties() copies all properties to both sd_device::properties and ::properties_db. Thus, on move uevent, also tentative properties, e.g. DEVPATH or INTERFACE, are stored to ::properties_db, and saved to udev database. This makes such tentative properties be copied to only ::properties, and thus not saved to udev database. Fixes #9426.
-rw-r--r--src/libsystemd/sd-device/device-private.c15
-rw-r--r--src/libsystemd/sd-device/device-private.h1
-rw-r--r--src/libsystemd/sd-device/sd-device.c2
3 files changed, 15 insertions, 3 deletions
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
index 36beb3e7df..2daf4ddd57 100644
--- a/src/libsystemd/sd-device/device-private.c
+++ b/src/libsystemd/sd-device/device-private.c
@@ -702,13 +702,24 @@ int device_new_from_stat_rdev(sd_device **ret, const struct stat *st) {
int device_copy_properties(sd_device *device_dst, sd_device *device_src) {
const char *property, *value;
+ Iterator i;
int r;
assert(device_dst);
assert(device_src);
- FOREACH_DEVICE_PROPERTY(device_src, property, value) {
- r = device_add_property(device_dst, property, value);
+ r = device_properties_prepare(device_src);
+ if (r < 0)
+ return r;
+
+ ORDERED_HASHMAP_FOREACH_KEY(property, value, device_src->properties_db, i) {
+ r = device_add_property_aux(device_dst, property, value, true);
+ if (r < 0)
+ return r;
+ }
+
+ ORDERED_HASHMAP_FOREACH_KEY(property, value, device_src->properties, i) {
+ r = device_add_property_aux(device_dst, property, value, false);
if (r < 0)
return r;
}
diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h
index 56558b38c6..062bfd651c 100644
--- a/src/libsystemd/sd-device/device-private.h
+++ b/src/libsystemd/sd-device/device-private.h
@@ -37,6 +37,7 @@ uint64_t device_get_properties_generation(sd_device *device);
uint64_t device_get_tags_generation(sd_device *device);
uint64_t device_get_devlinks_generation(sd_device *device);
+int device_properties_prepare(sd_device *device);
int device_get_properties_nulstr(sd_device *device, const uint8_t **nulstr, size_t *len);
int device_get_properties_strv(sd_device *device, char ***strv);
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index b8a5dcc1a6..2a69f2e94b 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -1453,7 +1453,7 @@ _public_ const char *sd_device_get_devlink_next(sd_device *device) {
return v;
}
-static int device_properties_prepare(sd_device *device) {
+int device_properties_prepare(sd_device *device) {
int r;
assert(device);