• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3#   Copyright (c) International Business Machines  Corp., 2003, 2005
4#
5#   This program is free software;  you can redistribute it and/or modify
6#   it under the terms of the GNU General Public License as published by
7#   the Free Software Foundation; either version 2 of the License, or
8#   (at your option) any later version.
9#
10#   This program is distributed in the hope that it will be useful,
11#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13#   the 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, write to the Free Software
17#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18#
19#
20#
21#  FILE   : ftp
22#
23#  PURPOSE: Ftp into a remote hosts successfully as a vaild user (other than root)
24#
25#  HISTORY:
26#     03/03  Jerone Young (jeroney@us.ibm.com)
27#     04/03  Dustin Kirkland (k1rkland@us.ibm.com)
28#     09/05  Kris Wilson (krisw@us.ibm.com) Check if vsftpd is on system.
29#
30#  NOTE:
31#	This version is intended for EAL certification, it will need modification
32#	to conform with LTP standards in the offical LTP tree.
33#
34# DESCRIPTION:
35#	The anonymous user will ftp in and create a directory in his/her
36#	home directory on the remote host.
37#
38
39setup()
40{
41	TEST_USER="anonymous"
42}
43
44do_test()
45{
46	FAIL_530="==> TEST : FAIL (ftp rejected login attempt)"
47	PASS_230="==> TEST : PASS (ftp allowed login attempt)"
48	FAIL_230="==> TEST : FAIL (ftp allowed login attempt)"
49	PASS_500="==> TEST : PASS (ftp rejected login attempt)"
50	PASS_530="==> TEST : PASS (ftp rejected login attempt)"
51
52	echo "Ftp into a remote host as anonymous user;"
53	echo "ANONYMOUS_ENABLE=$ANONYMOUS_ENABLE"
54
55	if [ "$ANONYMOUS_ENABLE" = "YES" ]; then
56	expect -c "
57		spawn ftp $RHOST
58		sleep 1
59		expect -re \": \"
60		send \"$TEST_USER\r\"
61		expect -re \"Password:\"
62		send \"$TEST_USER_PASSWD\r\"
63		expect {
64			# 530 - Login failed
65			\"530\" {send_user \"$FAIL_530\n\";exit 1}
66			# 230 - Login successful
67			\"230\" {send_user \"$PASS_230\n\";exit 0}
68		}
69		expect \"ftp> \"
70		send \"quit\r\"
71	"
72	else
73	expect -c "
74		spawn ftp $RHOST
75		sleep 1
76		expect -re \": \"
77		send \"$TEST_USER\r\"
78		expect -re \"Password:\"
79		send \"$TEST_USER_PASSWD\r\"
80		expect {
81			# 230 - Login successful
82			\"230\" {send_user \"$FAIL_230\n\";exit 1}
83			# 500 - Login failed
84			\"500\" {send_user \"$PASS_500\n\";exit 0}
85			# 530 - Login failed
86			\"530\" {send_user \"$PASS_530\n\";exit 0}
87		}
88		expect \"ftp> \"
89		send \"quit\r\"
90	"
91	fi
92}
93
94TCID="ftp05"
95TST_TOTAL=1
96
97. test.sh
98. ftp_setup
99
100setup
101do_setup
102
103do_test
104if [ $? -ne 0 ]; then
105	tst_resm TFAIL "Test $TCID FAIL"
106else
107	tst_resm TPASS "Test $TCID PASS"
108fi
109
110tst_exit
111