mirror of
https://github.com/openwrt/packages.git
synced 2026-12-02 18:05:31 +04:00
kea: replace resolv.conf.d/resolv.conf atomically
When the dhcp4 importer writes the zones, it removes /tmp/resolv.conf and appends a new one line by line, so a lookup in between finds no or a partial file. The file also lies outside /tmp/resolv.conf.d, where jails sharing the host network cannot follow its replacement. Write the resolver configuration to a temporary file in /tmp/resolv.conf.d and rename it over resolv.conf there, as dnsmasq does. After the importers ran, the init script points /tmp/resolv.conf at that file if it exists and is not already linked. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
1 parent
806bc20808
commit
afc34ca089
3 files changed
+14
-5
No files matched your search
+1
-1
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=kea
|
||||
PKG_VERSION:=3.2.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=https://ftp.isc.org/isc/kea/$(PKG_VERSION)
|
||||
|
||||
@@ -9,6 +9,7 @@ prog="$(basename $0)"
|
||||
|
||||
dyndir=/var/run/dhcp
|
||||
keadir=/var/lib/kea
|
||||
resolv_file=/tmp/resolv.conf.d/resolv.conf
|
||||
|
||||
session_key_name=local-ddns
|
||||
|
||||
@@ -908,10 +909,10 @@ write_zones() {
|
||||
rndc thaw
|
||||
fi
|
||||
|
||||
rm -f /tmp/resolv.conf
|
||||
echo "# This file is generated by the DHCPD service" > /tmp/resolv.conf
|
||||
[ -n "$g_domain" ] && echo "domain $g_domain" >> /tmp/resolv.conf
|
||||
echo "nameserver 127.0.0.1" >> /tmp/resolv.conf
|
||||
echo "# This file is generated by the DHCPD service" > $resolv_file.kea
|
||||
[ -n "$g_domain" ] && echo "domain $g_domain" >> $resolv_file.kea
|
||||
echo "nameserver 127.0.0.1" >> $resolv_file.kea
|
||||
mv -f $resolv_file.kea $resolv_file
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -7,6 +7,13 @@ STOP=85
|
||||
LIB_PATH="/usr/lib/kea"
|
||||
BIN_PATH="/usr/sbin"
|
||||
CONF_PATH="/etc/kea"
|
||||
RESOLV_FILE="/tmp/resolv.conf.d/resolv.conf"
|
||||
|
||||
kea_resolv_link() {
|
||||
[ -e "$RESOLV_FILE" ] || return 0
|
||||
[ "$(readlink /tmp/resolv.conf)" = "$RESOLV_FILE" ] ||
|
||||
ln -sf "$RESOLV_FILE" /tmp/resolv.conf
|
||||
}
|
||||
|
||||
start_service() {
|
||||
mkdir --mode=0750 -p /var/lib/kea /var/run/kea
|
||||
@@ -43,6 +50,7 @@ start_kea() {
|
||||
echo "Error: Importer '$importer' failed; aborting." >&2
|
||||
return 1
|
||||
fi
|
||||
kea_resolv_link
|
||||
fi
|
||||
|
||||
procd_open_instance "$name"
|
||||
|
||||
Reference in new issue
Block a user