@@ -16,7 +16,7 @@ domain=$2
1616domain_idn=$2
1717id=$3
1818record=$4
19- type =$5
19+ rtype =$5
2020dvalue=$( idn -t --quiet -u " $6 " )
2121priority=$7
2222restart=$8
@@ -42,7 +42,7 @@ format_domain_idn
4242# ----------------------------------------------------------#
4343
4444check_args ' 6' " $# " ' USER DOMAIN ID RECORD TYPE VALUE [PRIORITY] [RESTART] [TTL]'
45- is_format_valid ' user' ' domain' ' id' ' record' ' type ' ' dvalue '
45+ is_format_valid ' user' ' domain' ' id' ' record'
4646is_system_enabled " $DNS_SYSTEM " ' DNS_SYSTEM'
4747is_object_valid ' user' ' USER' " $user "
4848is_object_unsuspended ' user' ' USER' " $user "
@@ -66,31 +66,47 @@ unset TTL
6666line=$( grep " ID='$id '" $USER_DATA /dns/$domain .conf)
6767parse_object_kv_list " $line "
6868
69- if [ -z " $type " ]; then
70- type=$TYPE
69+ if [ -z " $rtype " ]; then
70+ rtype=$TYPE
71+ fi
72+
73+ if [ -z " $priority " ]; then
74+ priority=$PRIORITY
7175fi
7276
7377# Null priority for none MX/SRV records
74- if [ " $type " != ' MX' ] && [ " $TYPE " != ' SRV' ]; then
78+ if [ " $rtype " != ' MX' ] && [ " $rtype " != ' SRV' ]; then
7579 priority=' '
7680fi
7781
7882# Add trailing dot at the end of NS/CNAME/MX/PTR/SRV record
79- if [[ $type =~ NS| CNAME| MX| PTR| SRV ]]; then
83+ if [[ $rtype =~ NS| CNAME| MX| PTR| SRV ]]; then
8084 trailing_dot=$( echo " $dvalue " | grep " \.$" )
8185 if [ -z " $trailing_dot " ]; then
8286 dvalue=" $dvalue ."
8387 fi
8488fi
8589
90+ if [ " $rtype " != " CAA" ]; then
91+ dvalue=${dvalue// \" / }
92+
93+ if [ " $rtype " != ' SRV' ] && [[ " $dvalue " =~ [\; [:space:]] ]]; then
94+ dvalue= ' "' " $dvalue " ' "'
95+ fi
96+ fi
97+
98+
99+ # RTYPE wasn't checked make sure to do it now correctly
100+ is_format_valid ' user' ' domain' ' id' ' record' ' rtype' ' dvalue'
101+
86102# Additional verifications
87103is_dns_fqnd " $TYPE " " $dvalue "
88104is_dns_nameserver_valid " $domain " " $TYPE " " $dvalue "
89105
90- if [[ " $RECORD " == " $record " ]] && [[ " $TYPE " == " $type " ]] && [[ " $PRIORITY " -eq " $priority " ]] \
106+ if [[ " $RECORD " == " $record " ]] && [[ " $TYPE " == " $rtype " ]] && [[ " $PRIORITY " -eq " $priority " ]] \
91107 && [[ " $VALUE " == " $dvalue " ]] && [[ " $SUSPENDED " == ' no' ]] && [[ " $TTL " -eq " $ttl " ]]; then
92108 echo " No pending changes in DNS entry."
93- exit " $E_EXSIST "
109+ exit " $E_EXISTS "
94110fi
95111
96112# Generating timestamp
@@ -99,7 +115,7 @@ time=$(echo "$time_n_date" |cut -f 1 -d \ )
99115date= $( echo " $time_n_date " | cut -f 2 -d \ )
100116
101117# Adding record
102- dns_rec=" ID='$id ' RECORD='$record ' TYPE='$type ' PRIORITY='$priority '"
118+ dns_rec= " ID='$id ' RECORD='$record ' TYPE='$rtype ' PRIORITY='$priority '"
103119dns_rec= " $dns_rec VALUE='$dvalue ' SUSPENDED='no' TIME='$time ' DATE='$date '"
104120[ -n " $ttl " ] && dns_rec= " $dns_rec TTL='$ttl '"
105121# Deleting old record
@@ -135,7 +151,7 @@ $BIN/v-restart-dns "$restart"
135151check_result $? " DNS restart failed" > /dev/null
136152
137153# Logging
138- $BIN /v-log-action " $user " " Info" " DNS" " DNS record value changed (Type: $type , Record: $record , Value: $dvalue , Domain: $domain )."
154+ $BIN /v-log-action " $user " " Info" " DNS" " DNS record value changed (Type: $rtype , Record: $record , Value: $dvalue , Domain: $domain )."
139155log_event " $OK " " $ARGUMENTS "
140156
141157exit
0 commit comments