Skip to content

Commit

Permalink
ifupdown2-hotplug: flock and pass fd to ifupdown2
Browse files Browse the repository at this point in the history
  • Loading branch information
sohorx committed Jun 13, 2023
1 parent 56be5ec commit 1334553
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions debian/ifupdown2-hotplug
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {

Expand Down

0 comments on commit 1334553

Please sign in to comment.