Home | History | Annotate | Download | only in rpcinfo
      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 
     18 TCID="rpcinfo01"
     19 TST_TOTAL=16
     20 TST_CLEANUP=tst_rmdir
     21 
     22 . test_net.sh
     23 
     24 do_setup()
     25 {
     26 	tst_resm TINFO "Checking for portmap or rpcbind"
     27 
     28 	if pgrep portmap > /dev/null; then
     29 		PORTMAPPER="portmap"
     30 	else
     31 		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
     32 			tst_brkm TCONF "portmap or rpcbind is not running"
     33 	fi
     34 
     35 	tst_tmpdir
     36 
     37 	# Create file with 1 tcp and 1 udp line. Use for variable assignments.
     38 	rpcinfo -p $(tst_ipaddr) | grep tcp | sed -n 2p > rpc_out
     39 	rpcinfo -p $(tst_ipaddr) | grep udp | sed -n 2p >> rpc_out
     40 
     41 	wc -l rpc_out | grep "2" > /dev/null || \
     42 		tst_brkm TBROK "Not enough programs registered on $(tst_ipaddr)"
     43 
     44 	# Using "rpc_out" file created above, assign variables for rpcinfo opts
     45 	TPNUM=`grep tcp rpc_out | awk '{print $1}'`
     46 	TVNUM=`grep tcp rpc_out | awk '{print $2}'`
     47 	TCPNAME=`grep tcp rpc_out | awk '{print $5}'`
     48 	UPNUM=`grep udp rpc_out | awk '{print $1}'`
     49 	UVNUM=`grep udp rpc_out | awk '{print $2}'`
     50 	UDPNAME=`grep udp rpc_out | awk '{print $5}'`
     51 }
     52 
     53 do_test()
     54 {
     55 	local thost="$(tst_ipaddr)"
     56 
     57 	EXPECT_RHOST_PASS rpcinfo -p $thost | grep -q portmapper
     58 	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM
     59 	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM $TVNUM
     60 	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME
     61 	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME $TVNUM
     62 	EXPECT_RHOST_PASS rpcinfo -u $thost 100000
     63 	EXPECT_RHOST_PASS rpcinfo -u $thost 100000 2
     64 	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper
     65 	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper 2
     66 
     67 	tst_resm TINFO "Test rpcinfo with missing or bad options"
     68 	EXPECT_RHOST_FAIL rpcinfo -p bogushost
     69 	EXPECT_RHOST_FAIL rpcinfo -bogusflag
     70 	EXPECT_RHOST_FAIL rpcinfo -t $thost
     71 	EXPECT_RHOST_FAIL rpcinfo -u $thost
     72 	EXPECT_RHOST_FAIL rpcinfo -u $thost bogusprog
     73 	EXPECT_RHOST_FAIL rpcinfo -u $thost 11579
     74 	EXPECT_RHOST_FAIL rpcinfo -u $thost 100000 5
     75 }
     76 
     77 do_setup
     78 do_test
     79 
     80 tst_exit
     81