1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 06:48:07 +00:00

Validate on removal as well

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König 2021-10-17 20:51:59 +02:00
parent bc21a7155d
commit a872fabe7d

View File

@ -731,7 +731,12 @@ RemoveCustomDNSAddress() {
host="${args[3]}" host="${args[3]}"
reload="${args[4]}" reload="${args[4]}"
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
sed -i "/^${ip} ${host}$/d" "${dnscustomfile}" sed -i "/^${ip} ${host}$/d" "${dnscustomfile}"
else
echo -e " ${CROSS} Invalid IP has been passed"
exit 1
fi
# Restart dnsmasq to load new custom DNS entries only if reload is not false # Restart dnsmasq to load new custom DNS entries only if reload is not false
if [[ ! $reload == "false" ]]; then if [[ ! $reload == "false" ]]; then
@ -772,7 +777,19 @@ RemoveCustomCNAMERecord() {
target="${args[3]}" target="${args[3]}"
reload="${args[4]}" reload="${args[4]}"
sed -i "/cname=${domain},${target}$/d" "${dnscustomcnamefile}" validDomain="$(checkDomain "${domain}")"
if [[ -n "${validDomain}" ]]; then
validTarget="$(checkDomain "${target}")"
if [[ -n "${validTarget}" ]]; then
sed -i "/cname=${validDomain},${validTarget}$/d" "${dnscustomcnamefile}"
else
echo " ${CROSS} Invalid Target Passed!"
exit 1
fi
else
echo " ${CROSS} Invalid Domain passed!"
exit 1
fi
# Restart dnsmasq to update removed custom CNAME records only if $reload not false # Restart dnsmasq to update removed custom CNAME records only if $reload not false
if [[ ! $reload == "false" ]]; then if [[ ! $reload == "false" ]]; then