Procházet zdrojové kódy

Fix quoting when adding CAA dns records (#304)

- use correct <flags> <tag> order
Zollner Robert před 6 roky
rodič
revize
d6ec14cc02
2 změnil soubory, kde provedl 10 přidání a 12 odebrání
  1. 8 10
      bin/v-add-dns-record
  2. 2 2
      bin/v-add-letsencrypt-domain

+ 8 - 10
bin/v-add-dns-record

@@ -45,18 +45,16 @@ if [[ $rtype =~ NS|CNAME|MX|PTR|SRV ]]; then
     fi
 fi
 
-if [ $rtype != "CAA" ]; then
-    dvalue=${dvalue//\"/}
-    # Exclude CAA records for ' enclosure
-    if [[ "$dvalue" =~ [\;[:space:]] ]]; then
-        dvalue='"'"$dvalue"'"'
-    fi
-fi
+# Cleanup quotes on dvalue
+# - [CAA] records will be left unchanged
+# - [SRV] will be  stripped of double quotes even when  containg spaces
+# - Rest of record types will be striped of quotes and the final string
+#   will be enclosed in double quotes if  containg spaces or semicolons 
 
-if [[ "$dvalue" =~ [\;[:space:]] ]]; then
+if [ "$rtype" != "CAA" ]; then
     dvalue=${dvalue//\"/}
-    # Exclude SRV records for ' enclosure
-    if [ "$rtype" != 'SRV' ]; then
+
+    if [ "$rtype" != 'SRV' ] && [[ "$dvalue" =~ [\;[:space:]] ]]; then
         dvalue='"'"$dvalue"'"'
     fi
 fi

+ 2 - 2
bin/v-add-letsencrypt-domain

@@ -132,10 +132,10 @@ if [ ! -z "$DNS_SYSTEM" ]; then
     if [ "$dns_domain" = "$domain" ]; then
         # Replace DNS domain CAA records with Let's Encrypt values
         if [ -z "$caa_record" ]; then
-            $BIN/v-add-dns-record $user $domain '@' 'CAA' 'issue 0 "letsencrypt.org"'
+            $BIN/v-add-dns-record $user $domain '@' 'CAA' '0 issue "letsencrypt.org"'
         else
             $BIN/v-delete-dns-record $user $domain $caa_record
-            $BIN/v-add-dns-record $user $domain '@' 'CAA' 'issue 0 "letsencrypt.org"'
+            $BIN/v-add-dns-record $user $domain '@' 'CAA' '0 issue "letsencrypt.org"'
         fi
     fi
 fi