From 7b39f7b42b8286aff2cb0dcf0020baecb61f56b8 Mon Sep 17 00:00:00 2001 From: Tomas Pavlic Date: Mon, 9 Mar 2026 15:35:51 +0100 Subject: [PATCH] Use unique config key names --- dnsapi/dns_subreg.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dnsapi/dns_subreg.sh b/dnsapi/dns_subreg.sh index 22d59786..5e10b3d8 100644 --- a/dnsapi/dns_subreg.sh +++ b/dnsapi/dns_subreg.sh @@ -46,7 +46,7 @@ dns_subreg_add() { _subreg_soap "Add_DNS_Record" "$_domain$_sub_domainTXT$txtvalue0120" if _subreg_ok; then _record_id="$(_subreg_map_get record_id)" - _savedomainconf "SUBREG_RECORD_ID" "$_record_id" + _savedomainconf "$(_subreg_record_id_key "$txtvalue")" "$_record_id" return 0 fi _err "Failed to add TXT record." @@ -78,12 +78,12 @@ dns_subreg_rm() { _debug _sub_domain "$_sub_domain" _debug _domain "$_domain" - _record_id="$(_readdomainconf "SUBREG_RECORD_ID")" + _record_id="$(_readdomainconf "$(_subreg_record_id_key "$txtvalue")")" if [ -z "$_record_id" ]; then _err "Could not find saved record ID for $fulldomain" return 1 fi - _cleardomainconf "SUBREG_RECORD_ID" + _cleardomainconf "$(_subreg_record_id_key "$txtvalue")" _debug "Deleting record ID: $_record_id" _subreg_soap "Delete_DNS_Record" "$_domain$_record_id" @@ -97,6 +97,12 @@ dns_subreg_rm() { #################### Private functions ##################### +# Build a domain-conf key for storing the record ID of a given TXT value. +# Base64url chars include '-' which is invalid in shell variable names, so replace with '_'. +_subreg_record_id_key() { + printf 'SUBREG_RECORD_ID_%s' "$(printf '%s' "$1" | tr -- '-' '_')" +} + # Check if the current $response contains a successful status in the ns2:Map format: # statusok _subreg_ok() {