1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

udev: drop ID_RENAMING from UdevEvent.dev_db_clone instead of UdevEvent.dev

As the properties loaded from the database are stored to UdevEvent.dev_db_clone,
instead of UdevEvent.dev.

This also makes the removal done unconditionally, for safety.
This commit is contained in:
Yu Watanabe 2022-10-26 04:37:24 +09:00
parent bcf04e9b27
commit 7137f2f3a7

View File

@ -906,7 +906,7 @@ static int rename_netif(UdevEvent *event) {
return 0;
}
/* Set ID_RENAMING boolean property here, and drop it in the corresponding move uevent later. */
/* Set ID_RENAMING boolean property here. It will be dropped when the corresponding move uevent is processed. */
r = device_add_property(dev, "ID_RENAMING", "1");
if (r < 0)
return log_device_warning_errno(dev, r, "Failed to add 'ID_RENAMING' property: %m");
@ -1008,17 +1008,6 @@ static int event_execute_rules_on_remove(
return r;
}
static int udev_event_on_move(sd_device *dev) {
int r;
/* Drop previously added property */
r = device_add_property(dev, "ID_RENAMING", NULL);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to remove 'ID_RENAMING' property: %m");
return 0;
}
static int copy_all_tags(sd_device *d, sd_device *s) {
const char *tag;
int r;
@ -1074,11 +1063,13 @@ int udev_event_execute_rules(
if (r < 0)
log_device_warning_errno(dev, r, "Failed to copy all tags from old database entry, ignoring: %m");
if (action == SD_DEVICE_MOVE) {
r = udev_event_on_move(event->dev);
if (r < 0)
return r;
}
/* Drop previously added property for safety to make IMPORT{db}="ID_RENAMING" not work. This is
* mostly for 'move' uevent, but let's do unconditionally. Why? If a network interface is renamed in
* initrd, then udevd may lose the 'move' uevent during switching root. Usually, we do not set the
* persistent flag for network interfaces, but user may set it. Just for safety. */
r = device_add_property(event->dev_db_clone, "ID_RENAMING", NULL);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to remove 'ID_RENAMING' property: %m");
DEVICE_TRACE_POINT(rules_start, dev);