blob: f60c7d7c0b8237b6ccf4c022cbb19b70038124bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/bin/sh
# this runs the file serving tests that are expected to pass with samba3
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD
EOF
exit 1;
fi
SERVER="$1"
SERVER_IP="$2"
USERNAME="$3"
PASSWORD="$4"
SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION"
shift 4
ADDARGS="$*"
test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && {
incdir=`dirname $0`
. $incdir/test_functions.sh
}
failed=0
# Test that a noninteractive smbclient does not prompt
test_noninteractive_no_prompt()
{
prompt="smb"
cmd='echo du | $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
eval echo "$cmd"
out=`eval $cmd`
if [ $? != 0 ] ; then
echo "$out"
echo "command failed"
false
return
fi
echo "$out" | grep $prompt >/dev/null 2>&1
if [ $? = 0 ] ; then
# got a prompt .. fail
echo matched interactive prompt in non-interactive mode
false
else
true
fi
}
# Test that an interactive smbclient prompts to stdout
test_interactive_prompt_stdout()
{
prompt="smb"
tmpfile=/tmp/smbclient.in.$$
cat > $tmpfile <<EOF
du
quit
EOF
cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
eval echo "$cmd"
out=`eval $cmd`
ret=$?
rm -f $tmpfile
if [ $ret != 0 ] ; then
echo "$out"
echo "command failed"
false
return
fi
echo "$out" | grep $prompt >/dev/null 2>&1
if [ $? = 0 ] ; then
# got a prompt .. succeed
true
else
echo failed to match interactive prompt on stdout
false
fi
}
testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
testit "noninteractive smbclient does not prompt" \
test_noninteractive_no_prompt || \
failed=`expr $failed + 1`
testit "noninteractive smbclient -l does not prompt" \
test_noninteractive_no_prompt -l /tmp || \
failed=`expr $failed + 1`
testit "interactive smbclient prompts on stdout" \
test_interactive_prompt_stdout || \
failed=`expr $failed + 1`
testit "interactive smbclient -l prompts on stdout" \
test_interactive_prompt_stdout -l /tmp || \
failed=`expr $failed + 1`
testok $0 $failed
|