Re: [PATCH] Check for DNS validity. (465174)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks good,

Regards,

Hans


On 03/31/2009 06:01 PM, Joel Granados Moreno wrote:
---
  loader2/linuxrc.s390 |   44 +++++++++++++++++++++++++++++++++++++++++---
  1 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/loader2/linuxrc.s390 b/loader2/linuxrc.s390
index e22d4ac..a401986 100644
--- a/loader2/linuxrc.s390
+++ b/loader2/linuxrc.s390
@@ -59,6 +59,24 @@ checkipv4()
      return $?
  }

+checkdns()
+{
+    dns=$1
+    # DNS syntax is addr1:addr2:addr3 so first split by ":"
+    dnslist=$(echo $dns |  awk -F ':' '{i=1; while (i<=NF) {print $i; i=i+1}}')
+    found=0
+    for i in $dnslist; do
+        # note: only support ipv4 DNS currently,
+        # since both ipv6 address and DNS= parameter can contain ":"
+        checkipv4 $i
+        [ $? -eq 1 ]&&  return 1
+        # track whether we've found at least one valid IP
+        found=1
+    done
+    [ $found -eq 1 ]&&  return 0
+    return 1
+}
+
  doshutdown()
  {
  	 exec /sbin/shutdown
@@ -531,9 +549,29 @@ fi
  	# BH FIXME: Workaround for manual MACADDR, need ping to update arp table
  	ping -c 1 $GATEWAY>  /dev/null
  	
-	if [ -z "$DNS" ]; then
-		echo $"Enter your DNS server(s), separated by colons (:):"
-		read DNS
+
+	# DNS is optional, but if specified it must be correct
+	if [ -n "$DNS" ]; then
+	   checkdns $DNS
+	   ret=$?
+	   if [ $ret -ne 0 ]; then
+	     echo $"You have an invalid predefined DNS list"
+	   fi
+	fi
+	if [ -z "$DNS" ] || [ $ret -ne 0 ]; then
+	    echo $"Enter your DNS server(s), separated by colons (:)"
+	    echo $"Leave this blank and press enter to skip"
+	    read DNS
+	    checkdns $DNS
+	    ret=$?
+	    while [ -n "$DNS" ]&&  [ $ret -ne 0 ]; do
+	        echo -n "Invalid DNS address format. "
+	        echo $"Enter your DNS server(s), separated by colons (:)"
+	        echo $"Leave this blank and press enter to skip"
+	        read DNS
+	        checkdns $DNS
+	     ret=$?
+	    done
  	fi
  	if [ -z "$DNS" ]; then
  		echo $"You might encounter problems without a nameserver, especially"

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux