tests: Switch to tcp check in rpcinfo stub
authorAmitay Isaacs <amitay@gmail.com>
Fri, 27 Mar 2015 01:00:56 +0000 (12:00 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 17 Apr 2015 01:18:56 +0000 (11:18 +1000)
Use -T tcp instead of deprecated options -u and -t.  Also, check for
localhost.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Mar 27 09:16:50 CET 2015 on sn-devel-104

(Imported from commit 079575d80f5b28e452abf80efc4d005fb6dac270)

tests/eventscripts/stubs/rpcinfo

index dd175f3d9cb9d0ba377357dfec24c400296ea4a5..1866b59560e08f24035154568e80868a141c3053 100755 (executable)
@@ -5,23 +5,18 @@ prog="rpcinfo"
 usage ()
 {
     cat >&2 <<EOF
-Usage: $prog -u host program [version]
+Usage: $prog -T tcp host program [version]
 
 A fake rpcinfo stub that succeeds for items in FAKE_RPCINFO_SERVICES,
 depending on command-line options.
 
-Note that "-u host" is ignored.
-
 EOF
     exit 1
 }
 
 parse_options ()
 {
-    # $POSIXLY_CORRECT means that the command passed to onnode can
-    # take options and getopt won't reorder things to make them
-    # options to this script.
-    _temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "u:h" -l unix -l help -- "$@")
+    _temp=$(getopt -n "$prog" -o "T:h" -- "$@")
 
     [ $? != 0 ] && usage
 
@@ -29,12 +24,17 @@ parse_options ()
 
     while true ; do
        case "$1" in
-           -u) shift 2 ;;  # ignore
+           -T) netid="$2"; shift 2 ;;
            --) shift ; break ;;
-           -h|--help|*) usage ;; # * shouldn't happen, so this is reasonable.
+           -h|*) usage ;; # * shouldn't happen, so this is reasonable.
        esac
     done
 
+    [ "$netid" = "tcp" ] || usage
+
+    host="$1" ; shift
+    [ "$host" = "localhost" -o "$host" = "127.0.0.1" ] || usage
+
     [ 1 -le $# -a $# -le 2 ] || usage
 
     p="$1"
@@ -49,7 +49,7 @@ for i in ${FAKE_RPCINFO_SERVICES} ; do
     IFS="${IFS}:"
     set -- $i
     # $1 = program, $2 = low version, $3 = high version
-    
+
     if [ "$1" = "$p" ] ; then
        if [ -n "$v" ] ; then
            if [ "$2" -le "$v" -a "$v" -le "$3" ] ; then