[PATCH] Allow empty DNS variable in s390 CMS conf file (#465175)

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

 



If the DNS variable contains an empty space or a colon, anaconda
gives a traceback.
---
 loader2/linuxrc.s390 |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/loader2/linuxrc.s390 b/loader2/linuxrc.s390
index 0400ede..7b8fcde 100644
--- a/loader2/linuxrc.s390
+++ b/loader2/linuxrc.s390
@@ -60,6 +60,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
@@ -457,13 +475,29 @@ route add default gw $GATEWAY dev $DEVICE 2>/dev/null
 # 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 (:):"
+# DNS is optional, but if specified it must be correct
+if [ -n "$DNS" ]; then
+   checkdns $DNS
+   ret=$?
+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"
-	echo $"with FTP installs"
+	echo $"WARNING: You might encounter problems without a nameserver,"
+	echo $"especially with FTP installs"
 fi
 
 if [ -n "$DNS" -a -z "$SEARCHDNS" ]; then
-- 
1.6.0.3

_______________________________________________
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