blob: b0199a390b089dacc6b053c99c52a7e27524e75f (
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#!/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
}
# Test creating a bad symlink and deleting it.
test_bad_symlink()
{
prompt="posix_unlink deleted file /newname"
tmpfile=/tmp/smbclient.in.$$
cat > $tmpfile <<EOF
posix
symlink badname newname
posix_unlink newname
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 "failed create then delete bad symlink"
false
return
fi
echo "$out" | grep $prompt >/dev/null 2>&1
if [ $? = 0 ] ; then
# got the correct prompt .. succeed
true
else
echo failed create then delete bad symlink
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`
testit "creating a bad symlink and deleting it" \
test_bad_symlink || \
failed=`expr $failed + 1`
testok $0 $failed
|