• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
3# Copyright (c) International Business Machines  Corp., 2000
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation; either version 2 of
8# the License, or (at your option) any later version.
9#
10# This program is distributed in the hope that it would be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18TCID="rpcinfo01"
19TST_TOTAL=16
20TST_CLEANUP=tst_rmdir
21
22TST_USE_LEGACY_API=1
23. tst_net.sh
24
25do_setup()
26{
27	tst_resm TINFO "Checking for portmap or rpcbind"
28
29	if pgrep portmap > /dev/null; then
30		PORTMAPPER="portmap"
31	else
32		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
33			tst_brkm TCONF "portmap or rpcbind is not running"
34	fi
35
36	tst_tmpdir
37
38	# Create file with 1 tcp and 1 udp line. Use for variable assignments.
39	rpcinfo -p $(tst_ipaddr) | grep tcp | sed -n 2p > rpc_out
40	rpcinfo -p $(tst_ipaddr) | grep udp | sed -n 2p >> rpc_out
41
42	wc -l rpc_out | grep "2" > /dev/null || \
43		tst_brkm TBROK "Not enough programs registered on $(tst_ipaddr)"
44
45	# Using "rpc_out" file created above, assign variables for rpcinfo opts
46	TPNUM=`grep tcp rpc_out | awk '{print $1}'`
47	TVNUM=`grep tcp rpc_out | awk '{print $2}'`
48	TCPNAME=`grep tcp rpc_out | awk '{print $5}'`
49	UPNUM=`grep udp rpc_out | awk '{print $1}'`
50	UVNUM=`grep udp rpc_out | awk '{print $2}'`
51	UDPNAME=`grep udp rpc_out | awk '{print $5}'`
52}
53
54do_test()
55{
56	local thost="$(tst_ipaddr)"
57
58	EXPECT_RHOST_PASS rpcinfo -p $thost | grep -q portmapper
59	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM
60	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM $TVNUM
61	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME
62	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME $TVNUM
63	EXPECT_RHOST_PASS rpcinfo -u $thost 100000
64	EXPECT_RHOST_PASS rpcinfo -u $thost 100000 2
65	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper
66	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper 2
67
68	tst_resm TINFO "Test rpcinfo with missing or bad options"
69	EXPECT_RHOST_FAIL rpcinfo -p bogushost
70	EXPECT_RHOST_FAIL rpcinfo -bogusflag
71	EXPECT_RHOST_FAIL rpcinfo -t $thost
72	EXPECT_RHOST_FAIL rpcinfo -u $thost
73	EXPECT_RHOST_FAIL rpcinfo -u $thost bogusprog
74	EXPECT_RHOST_FAIL rpcinfo -u $thost 11579
75	EXPECT_RHOST_FAIL rpcinfo -u $thost 100000 5
76}
77
78do_setup
79do_test
80
81tst_exit
82