mirror of
https://github.com/samba-team/samba.git
synced 2025-01-27 14:04:05 +03:00
079575d80f
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
80 lines
1.6 KiB
Bash
Executable File
80 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
prog="rpcinfo"
|
|
|
|
usage ()
|
|
{
|
|
cat >&2 <<EOF
|
|
Usage: $prog -T tcp host program [version]
|
|
|
|
A fake rpcinfo stub that succeeds for items in FAKE_RPCINFO_SERVICES,
|
|
depending on command-line options.
|
|
|
|
EOF
|
|
exit 1
|
|
}
|
|
|
|
parse_options ()
|
|
{
|
|
_temp=$(getopt -n "$prog" -o "T:h" -- "$@")
|
|
|
|
[ $? != 0 ] && usage
|
|
|
|
eval set -- "$_temp"
|
|
|
|
while true ; do
|
|
case "$1" in
|
|
-T) netid="$2"; shift 2 ;;
|
|
--) shift ; break ;;
|
|
-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"
|
|
v="$2"
|
|
}
|
|
|
|
parse_options "$@"
|
|
|
|
for i in ${FAKE_RPCINFO_SERVICES} ; do
|
|
# This is stupidly cummulative, but needs to happen after the
|
|
# initial split of the list above.
|
|
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
|
|
echo "program ${p} version ${v} ready and waiting"
|
|
exit 0
|
|
else
|
|
echo "rpcinfo: RPC: Program/version mismatch; low version = ${2}, high version = ${3}" >&2
|
|
echo "program ${p} version ${v} is not available"
|
|
exit 1
|
|
fi
|
|
else
|
|
for j in $(seq $2 $3) ; do
|
|
echo "program ${p} version ${j} ready and waiting"
|
|
done
|
|
exit 0
|
|
fi
|
|
fi
|
|
done
|
|
|
|
echo "rpcinfo: RPC: Program not registered" >&2
|
|
if [ -n "$v" ] ; then
|
|
echo "program ${p} version ${v} is not available"
|
|
else
|
|
echo "program ${p} is not available"
|
|
fi
|
|
|
|
exit 1
|