From 1334553121f1e6a218e8d334d4ed51e9fc2746cc Mon Sep 17 00:00:00 2001 From: Adrien Banlin Date: Tue, 13 Jun 2023 17:33:35 +0200 Subject: [PATCH] ifupdown2-hotplug: flock and pass fd to ifupdown2 --- debian/ifupdown2-hotplug | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/debian/ifupdown2-hotplug b/debian/ifupdown2-hotplug index a2b18115..d0150d6c 100755 --- a/debian/ifupdown2-hotplug +++ b/debian/ifupdown2-hotplug @@ -13,6 +13,8 @@ else unset LOGGER fi +LOCKFILE=/run/network/.lock + # for diagnostics if [ -t 1 -a -z "$LOGGER" ] || [ ! -e '/dev/log' ]; then mesg() { @@ -48,24 +50,23 @@ wait_for_interface() { } net_ifup() { - + flock 9 wait_for_interface lo - - if $(ifquery -l --allow=hotplug 2>/dev/null | grep -w -q "^$INTERFACE$"); then - exec ifup $INTERFACE --systemd + if $(ifquery -L 9 -l --allow=hotplug 2>/dev/null | grep -w -q "^$INTERFACE$"); then + exec ifup $INTERFACE -L 9 --systemd else mesg "NET $INTERFACE not a hotplug interface" fi -} +} 9>$LOCKFILE net_ifdown() { - - if $(ifquery -l --allow=hotplug 2>/dev/null | grep -w -q "^$INTERFACE$"); then - exec ifdown $INTERFACE --systemd + flock 9 + if $(ifquery -L 9 -l --allow=hotplug 2>/dev/null | grep -w -q "^$INTERFACE$"); then + exec ifdown $INTERFACE -L 9 --systemd else mesg "NET $INTERFACE not a hotplug interface" fi -} +} 9>$LOCKFILE do_everything() {