From 7187a92fcf96d16fc2cf4337f715d55a9d6bcc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Correa=20Rodr=C3=ADguez?= Date: Fri, 25 Aug 2023 10:28:17 +0200 Subject: [PATCH] Changed regex to fetch DNS --- unattended_installer/cert_tool/certFunctions.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/unattended_installer/cert_tool/certFunctions.sh b/unattended_installer/cert_tool/certFunctions.sh index cb910e5ca9..b97a9322a6 100644 --- a/unattended_installer/cert_tool/certFunctions.sh +++ b/unattended_installer/cert_tool/certFunctions.sh @@ -99,7 +99,7 @@ function cert_generateCertificateconfiguration() { sed -i '/IP.1/d' "${cert_tmp_path}/${1}.conf" for (( i=2; i<=${#@}; i++ )); do isIP=$(echo "${!i}" | grep -P "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$") - isDNS=$(echo "${!i}" | grep -P "^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z-]{2,})+$" ) + isDNS=$(echo "${!i}" | grep -P "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\.([A-Za-z]{2,})$" ) j=$((i-1)) if [ "${isIP}" ]; then printf '%s\n' " IP.${j} = ${!i}" >> "${cert_tmp_path}/${1}.conf" @@ -330,9 +330,12 @@ function cert_readConfig() { all_ips=("${indexer_node_ips[@]}" "${server_node_ips[@]}" "${dashboard_node_ips[@]}") for ip in "${all_ips[@]}"; do - if ! cert_checkPrivateIp "$ip"; then - common_logger -e "The IP ${ip} is public." - exit 1 + isIP=$(echo "${ip}" | grep -P "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$") + if [[ -n "${isIP}" ]]; then + if ! cert_checkPrivateIp "$ip"; then + common_logger -e "The IP ${ip} is public." + exit 1 + fi fi done