dns: fix dns-update fqdn() double-appending zone to FQDN records #481

Merged
benvin merged 1 commits from benvin/dns-update-fqdn-fix into develop 2026-07-17 22:50:29 +10:00
@@ -20,7 +20,15 @@ applied="$(grep -vE '^[[:space:]]*(#|$)' "$STATE" 2>/dev/null | sort -u || true)
[ "$desired" = "$applied" ] && exit 0 [ "$desired" = "$applied" ] && exit 0
fqdn() { # name zone fqdn() { # name zone
if [ -z "$1" ] || [ "$1" = "@" ]; then printf '%s.' "$2"; else printf '%s.%s.' "$1" "$2"; fi # $1 may be relative to the zone, "@"/empty for the apex, or already a FQDN
# (trailing dot). Only append the zone in the relative case; appending it to
# an already-qualified name yields a "..", which nsupdate rejects as an
# "invalid owner name: empty label".
case "$1" in
''|'@') printf '%s.' "$2" ;;
*.) printf '%s' "$1" ;;
*) printf '%s.%s.' "$1" "$2" ;;
esac
} }
msg="$(mktemp)" msg="$(mktemp)"