From 268de90f821633b49b29b2d6a259fa29a62c0023 Mon Sep 17 00:00:00 2001 From: Philippe Seewer Date: Tue, 16 Jun 2009 10:52:21 +0200 Subject: [PATCH] netroot handlers: Add argument checking This is probably not necessary, but paranoia dictates that the actual netroot handlers should check if all three required arguments (netif, root, NEWROOT) are there and useable. --- modules.d/95iscsi/iscsiroot | 10 ++++++++++ modules.d/95nbd/nbdroot | 9 +++++++++ modules.d/95nfs/nfsroot | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/modules.d/95iscsi/iscsiroot b/modules.d/95iscsi/iscsiroot index 8e20fda..277c129 100755 --- a/modules.d/95iscsi/iscsiroot +++ b/modules.d/95iscsi/iscsiroot @@ -17,6 +17,16 @@ for conf in conf/conf.d/*; do [ -f ${conf} ] && . ${conf} done +# Huh? Empty $1? +[ -z "$1" ] && exit 1 + +# Huh? Empty $2? +[ -z "$2" ] && exit 1 + +# Huh? Empty $3? This isn't really necessary, since NEWROOT isn't +# used here. But let's be consistent +[ -z "$3" ] && exit 1 + # root is in the form root=iscsi:[]:[]:[]:[]: netif="$1" root="$2" diff --git a/modules.d/95nbd/nbdroot b/modules.d/95nbd/nbdroot index 2302696..91f6192 100755 --- a/modules.d/95nbd/nbdroot +++ b/modules.d/95nbd/nbdroot @@ -12,6 +12,15 @@ if getarg rdnetdebug; then set -x fi +# Huh? Empty $1? +[ -z "$1" ] && exit 1 + +# Huh? Empty $2? +[ -z "$2" ] && exit 1 + +# Huh? Empty $3? +[ -z "$3" ] && exit 1 + # root is in the form root=nbd:server:port:fstype:fsopts:nbdopts netif="$1" root="$2" diff --git a/modules.d/95nfs/nfsroot b/modules.d/95nfs/nfsroot index 849fadf..ec094b3 100755 --- a/modules.d/95nfs/nfsroot +++ b/modules.d/95nfs/nfsroot @@ -12,6 +12,15 @@ getarg rdnetdebug && { set -x } +# Huh? Empty $1? +[ -z "$1" ] && exit 1 + +# Huh? Empty $2? +[ -z "$2" ] && exit 1 + +# Huh? Empty $3? +[ -z "$3" ] && exit 1 + # root is in the form root=nfs[4]:server:path:[options] netif="$1" root="$2" -- 2.7.4