From 0320d850288b5994ae1393ed260d7711d31379b5 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 13 Jun 2020 20:57:57 +0100 Subject: [PATCH] Additionally source the install script in webpage.sh to validate IP entered on `pihole -a setdns` Signed-off-by: Adam Warner --- advanced/Scripts/webpage.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 0fabdeb4..b7e9c60f 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -10,18 +10,21 @@ # This file is copyright under the latest version of the EUPL. # Please see LICENSE file for your rights under this license. -readonly setupVars="/etc/pihole/setupVars.conf" readonly dnsmasqconfig="/etc/dnsmasq.d/01-pihole.conf" readonly dhcpconfig="/etc/dnsmasq.d/02-pihole-dhcp.conf" readonly FTLconf="/etc/pihole/pihole-FTL.conf" # 03 -> wildcards readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf" -readonly PI_HOLE_BIN_DIR="/usr/local/bin" readonly dnscustomfile="/etc/pihole/custom.list" readonly dnscustomcnamefile="/etc/dnsmasq.d/05-pihole-custom-cname.conf" readonly gravityDBfile="/etc/pihole/gravity.db" +# Source install script for ${setupVars}, ${PI_HOLE_BIN_DIR} and valid_ip() +readonly PI_HOLE_FILES_DIR="/etc/.pihole" +PH_TEST="true" +source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" + coltable="/opt/pihole/COL_TABLE" if [[ -f ${coltable} ]]; then source ${coltable} @@ -227,7 +230,15 @@ SetDNSServers() { for index in "${!array[@]}" do # Replace possible "\#" by "#". This fixes AdminLTE#1427 - add_setting "PIHOLE_DNS_$((index+1))" "${array[index]//\\#/#}" + local ip + ip="${array[index]//\\#/#}" + + if valid_ip "${ip}" ; then + add_setting "PIHOLE_DNS_$((index+1))" "${ip}" + else + echo -e " ${CROSS} Invalid IP has been passed" + exit 1 + fi done if [[ "${args[3]}" == "domain-needed" ]]; then