summaryrefslogtreecommitdiffstats
path: root/loader/linuxrc.s390
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-06-08 15:15:12 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-06-09 09:52:03 -1000
commited9ab0664f2cad8f7ec6f43b253d2926240796c4 (patch)
treedbb29056f8e8eba29f070355df3acb17647208ee /loader/linuxrc.s390
parent9b53a3e529e46f0573f2fe750491f521cf099d18 (diff)
downloadanaconda-ed9ab0664f2cad8f7ec6f43b253d2926240796c4.tar.gz
anaconda-ed9ab0664f2cad8f7ec6f43b253d2926240796c4.tar.xz
anaconda-ed9ab0664f2cad8f7ec6f43b253d2926240796c4.zip
Use /sbin/ipcalc for IP address validation (#460579)
Modify checkipv4() and checkipv6() in linuxrc.s390 to run /sbin/ipcalc for address validation. We were already including the ipcalc program, we just weren't using it.
Diffstat (limited to 'loader/linuxrc.s390')
-rw-r--r--loader/linuxrc.s39029
1 files changed, 3 insertions, 26 deletions
diff --git a/loader/linuxrc.s390 b/loader/linuxrc.s390
index 1db416771..d9ccca671 100644
--- a/loader/linuxrc.s390
+++ b/loader/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 $?
}