Re: [rhel5-branch 2/3] Include /sbin/ipcalc for IP address validation (#460579)

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

 



Looks ok,

Regards,

Hans

David Cantrell wrote:
linuxrc.s390 needs /sbin/ipcalc to perform IPv4 and IPv6 address
validation.  initscripts-8.45.26.1.el5 and later builds include a patch
to ipcalc that supports IPv6.

Modify checkipv4() and checkipv6() in linuxrc.s390 to use ipcalc.
---
 loader2/linuxrc.s390 |   29 +++--------------------------
 scripts/mk-images    |    1 +
 scripts/upd-instroot |    1 +
 3 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/loader2/linuxrc.s390 b/loader2/linuxrc.s390
index 1db4167..d9ccca6 100644
--- a/loader2/linuxrc.s390
+++ b/loader2/linuxrc.s390
@@ -61,42 +61,19 @@ function tv() {
     fi
 }
-# for checkipv6 / checkipv4 see also:
-# https://bugzilla.redhat.com/show_bug.cgi?id=234152#c11
-# https://enterprise.redhat.com/issue-tracker/?module=issues&action=view&tid=115847
-
-# see also RFC4291,sec.2.2
-# the following check is incomplete, but sufficient to distinguish from IPv4
 function checkipv6()
 {
     local ip=$1
     [ -z "$ip" ] && return 1
-    echo $ip | awk -F':' '
-        BEGIN {
-          error = 0
-        }
-
-        {
-          if (NF > 8) {
-            error = 1
-            exit error
-          }
-          for (i = 1; i <= NF; i++) {
-            if ( ! match(toupper($i), "^[0-9A-F]{0,4}$") ) {
-              error = 1
-              break
-            }
-          }
-          exit error
-        }
-    '
+    /sbin/ipcalc -c -6 "$ip" >/dev/null 2>&1
     return $?
 }
function checkipv4()
 {
     local ip=$1
-    echo $ip | awk -F'.' '{ if (NF != 4) { exit 1 } i=1; while (i<=NF) { if ($i>255 || $i<0) { exit 1 }; i=i+1; } exit 0 }'
+    [ -z "$ip" ] && return 1
+    /sbin/ipcalc -c -4 "$ip" >/dev/null 2>&1
     return $?
 }
diff --git a/scripts/mk-images b/scripts/mk-images
index 37c765a..ad27b84 100755
--- a/scripts/mk-images
+++ b/scripts/mk-images
@@ -641,6 +641,7 @@ EOF
 	install -m 755 $IMGPATH/usr/sbin/dasdfmt $MBD_DIR/sbin/dasdfmt
 	install -m 755 $IMGPATH/usr/sbin/udevsettle $MBD_DIR/sbin/udevsettle
 	install -m 755 $IMGPATH/usr/sbin/udevd $MBD_DIR/sbin/udevd
+	install -m 755 $IMGPATH/usr/sbin/ipcalc $MBD_DIR/sbin/ipcalc
 	mkdir -p $MBD_DIR/etc/udev
 	echo "# udev.conf" > $MBD_DIR/etc/udev/udev.conf
     fi
diff --git a/scripts/upd-instroot b/scripts/upd-instroot
index d1f3cb2..946a2ab 100755
--- a/scripts/upd-instroot
+++ b/scripts/upd-instroot
@@ -547,6 +547,7 @@ sbin/cmsfslst
 sbin/cmsfscat
 sbin/busybox.anaconda
 sbin/ifconfig
+sbin/ipcalc
 sbin/route
 sbin/portmap
 sbin/fdasd

_______________________________________________
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