systemd/1053-better-checks-in-write_net_rules.patch

30 lines
1.1 KiB
Diff

Index: systemd-210/src/udev/rule_generator/write_net_rules
===================================================================
--- systemd-210.orig/src/udev/rule_generator/write_net_rules
+++ systemd-210/src/udev/rule_generator/write_net_rules
@@ -89,6 +89,12 @@ choose_rules_file
# the DRIVERS key is needed to not match bridges and VLAN sub-interfaces
if [ "$MATCHADDR" ]; then
+ # Check if MACADDR doesn't exist already in the generated rules
+ MAC="$(/usr/bin/grep -w -o -C1 -m1 "$MATCHADDR" "$RULES_FILE" 2>/dev/null || true)"
+ if [ "$MAC" = "$MATCHADDR" ]; then
+ unlock_rules_file
+ exit 0
+ fi
match="$match, DRIVERS==\"?*\", ATTR{address}==\"$MATCHADDR\""
fi
@@ -101,8 +107,9 @@ if [ "$MATCHDEVID" ]; then
fi
if [ "$MATCHID" ]; then
- ID="$(find_all_rules 'KERNELS==' "$MATCHID")"
- if [ "$ID" == "$MATCHID" ]; then
+ # Check if KERNEL doesn't exist already in the generated rules
+ KERNEL="$(find_all_rules 'KERNELS==' "$MATCHID")"
+ if [ "$KERNEL" = "$MATCHID" ]; then
unlock_rules_file
exit 0
fi