]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: do not save e.g., DEVPATH or INTERFACE properties to udev database
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Jan 2019 02:45:40 +0000 (11:45 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Jan 2019 05:51:02 +0000 (14:51 +0900)
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.

src/libsystemd/sd-device/device-private.c
src/libsystemd/sd-device/device-private.h
src/libsystemd/sd-device/sd-device.c

index 36beb3e7dfa0a2fe07e8ef95697e9b9b06dbb952..2daf4ddd57afaca48df312d03c7ee549145917d2 100644 (file)
@@ -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;
         }
index 56558b38c6fd0bc07b74c763b58cb865134cd319..062bfd651c106972312794d093de03993f545284 100644 (file)
@@ -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);
 
index b8a5dcc1a6b7b096b4d0d55b1029363446e91b04..2a69f2e94b2108f60a5b1ca34e62ebcacc5037d5 100644 (file)
@@ -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);