Unbound: fix file lock race in odhcpd.sh

Signed-off-by: Ted Hess <thess@kitschensync.net>
This commit is contained in:
Ted Hess
2024-11-02 11:31:05 -04:00
parent bc14a5428b
commit 4d8c6d1869
2 changed files with 4 additions and 16 deletions

View File

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=unbound PKG_NAME:=unbound
PKG_VERSION:=1.21.0 PKG_VERSION:=1.21.0
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://nlnetlabs.nl/downloads/unbound PKG_SOURCE_URL:=https://nlnetlabs.nl/downloads/unbound

View File

@@ -78,7 +78,6 @@ odhcpd_zonedata() {
fi fi
fi fi
case $longconf in case $longconf in
freshstart) freshstart)
awk -v conffile=$UB_DHCP_CONF -v pipefile=$dns_ls_new \ awk -v conffile=$UB_DHCP_CONF -v pipefile=$dns_ls_new \
@@ -129,22 +128,11 @@ odhcpd_zonedata() {
############################################################################## ##############################################################################
UB_ODHPCD_LOCK=/tmp/unbound_odhcpd.lock UB_ODHCPD_LOCK=/var/lock/unbound_odhcpd.lock
if [ ! -f $UB_ODHPCD_LOCK ] ; then exec 1000>$UB_ODHCPD_LOCK
# imperfect but it should avoid collisions if flock -x -n 1000 ; then
touch $UB_ODHPCD_LOCK
odhcpd_zonedata odhcpd_zonedata
rm -f $UB_ODHPCD_LOCK
else
UB_ODHCPD_LOCK_AGE=$(( $( date +%s ) - $( date -r $UB_ODHPCD_LOCK +%s ) ))
if [ $UB_ODHCPD_LOCK_AGE -gt 100 ] ; then
# unlock because something likely broke but do not write this time through
rm -f $UB_ODHPCD_LOCK
fi
fi fi
############################################################################## ##############################################################################