Merge 1a1eb66150ce5433fcb3986ef748fa5ea3c2a9d0 into 40b6db6a2715628aa977ed1853fe5256704010ae

This commit is contained in:
Nils Wisiol 2025-04-03 04:04:31 +02:00 committed by GitHub
commit 234b56204d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -83,20 +83,31 @@ EOF
# returns
# _domain=domain.com
_get_root() {
domain=$1
i="$(echo "$fulldomain" | tr '.' ' ' | wc -w)"
i=$(_math "$i" - 1)
ancestor="${1}."
while true; do
h=$(printf "%s" "$domain" | cut -d . -f "$i"-100)
if [ -z "$h" ]; then
while true; do # loops over all ancestors of $1
# count labels
num_labels="$(echo "$ancestor" | tr '.' ' ' | wc -w)"
# abort if empty
if [ "$num_labels" -eq "0" ]; then
# error: could not find SOA record anywhere
_debug "no SOA record found in any ancestor of $1"
return 1
fi
_domain="$h"
return 0
# query for SOA at current ancestor
if [ -n "$(dig SOA +short "${ancestor}")" ]; then
# found SOA record
_info "found SOA at $ancestor"
_domain="${ancestor%?}"
return 0
fi
# cut one label from the left
ancestor=$(printf "%s" "${ancestor}" | cut -d . -f 2-)
done
_debug "$domain not found"
return 1
}
_checkKey() {