From 83f4c6a65fa3951121ea7ff2481dd5a617552169 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Fri, 11 Mar 2016 11:34:03 +0100 Subject: [PATCH] [fix] Validate IP addresses returned by ipX.yunohost.org --- data/hooks/conf_regen/43-dnsmasq | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/data/hooks/conf_regen/43-dnsmasq b/data/hooks/conf_regen/43-dnsmasq index 897adf19b..31c75d778 100644 --- a/data/hooks/conf_regen/43-dnsmasq +++ b/data/hooks/conf_regen/43-dnsmasq @@ -3,6 +3,8 @@ set -e force=$1 +. /usr/share/yunohost/apps/helpers + function safe_copy () { if [[ "$force" == "True" ]]; then sudo yunohost service safecopy \ @@ -16,10 +18,12 @@ function safe_copy () { cd /usr/share/yunohost/templates/dnsmasq # Get IPv4 address -ip=$(curl -s -4 https://ip.yunohost.org 2>/dev/null || echo '0.0.0.0') +ip=$(curl -s -4 https://ip.yunohost.org 2>/dev/null) +ynh_validate_ip4 $ip || ip='0.0.0.0' # Get IPv6 IP address -ipv6=$(curl -s -6 http://ip6.yunohost.org 2>/dev/null || echo '') +ipv6=$(curl -s -6 http://ip6.yunohost.org 2>/dev/null) +ynh_validate_ip6 $ipv6 || ipv6='' sudo mkdir -p /etc/dnsmasq.d