3 # this runs the file serving tests that are expected to pass with samba3
7 Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD USERID LOCAL_PATH
18 SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION"
22 test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && {
24 . $incdir/test_functions.sh
29 # Test that a noninteractive smbclient does not prompt
30 test_noninteractive_no_prompt()
34 cmd='echo du | $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
45 echo "$out" | grep $prompt >/dev/null 2>&1
48 # got a prompt .. fail
49 echo matched interactive prompt in non-interactive mode
56 # Test that an interactive smbclient prompts to stdout
57 test_interactive_prompt_stdout()
60 tmpfile=/tmp/smbclient.in.$$
67 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
73 if [ $ret != 0 ] ; then
80 echo "$out" | grep $prompt >/dev/null 2>&1
83 # got a prompt .. succeed
86 echo failed to match interactive prompt on stdout
91 # Test creating a bad symlink and deleting it.
94 prompt="posix_unlink deleted file /newname"
95 tmpfile=/tmp/smbclient.in.$$
100 symlink badname newname
105 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
111 if [ $ret != 0 ] ; then
113 echo "failed create then delete bad symlink with error $ret"
118 echo "$out" | grep "$prompt" >/dev/null 2>&1
121 if [ $ret = 0 ] ; then
122 # got the correct prompt .. succeed
126 echo "failed create then delete bad symlink - grep failed with $ret"
131 # Test creating a good symlink and deleting it by path.
134 tmpfile=/tmp/smbclient.in.$$
136 touch "$LOCAL_PATH/foo"
137 ln -s "$LOCAL_PATH/foo" "$LOCAL_PATH/bar"
143 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
149 if [ $ret != 0 ] ; then
151 echo "failed delete good symlink with error $ret"
156 if [ -e "$LOCAL_PATH/bar" ] ; then
157 echo "failed delete good symlink - symlink still exists"
162 # got the correct prompt .. succeed
168 # Test writing into a read-only directory (logon as guest) fails.
171 prompt="NT_STATUS_ACCESS_DENIED making remote directory"
172 tmpfile=/tmp/smbclient.in.$$
175 ## We can't do this as non-root. We always have rights to
176 ## create the directory.
178 if [ "$USERID" != 0 ] ; then
179 echo "skipping test_read_only_dir as non-root"
185 ## We can't do this with an encrypted connection. No credentials
186 ## to set up the channel.
188 if [ "$ADDARGS" = "-e" ] ; then
189 echo "skipping test_read_only_dir with encrypted connection"
199 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
205 if [ $ret != 0 ] ; then
207 echo "failed writing into read-only directory with error $ret"
212 echo "$out" | grep "$prompt" >/dev/null 2>&1
215 if [ $ret = 0 ] ; then
216 # got the correct prompt .. succeed
220 echo "failed writing into read-only directory - grep failed with $ret"
225 # Test reading an owner-only file (logon as guest) fails.
226 test_owner_only_file()
228 prompt="NT_STATUS_ACCESS_DENIED opening remote file"
229 tmpfile=/tmp/smbclient.in.$$
232 ## We can't do this as non-root. We always have rights to
235 if [ "$USERID" != 0 ] ; then
236 echo "skipping test_owner_only_file as non-root"
242 ## We can't do this with an encrypted connection. No credentials
243 ## to set up the channel.
245 if [ "$ADDARGS" = "-e" ] ; then
246 echo "skipping test_owner_only_file with encrypted connection"
256 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
262 if [ $ret != 0 ] ; then
264 echo "failed reading owner-only file with error $ret"
269 echo "$out" | grep "$prompt" >/dev/null 2>&1
272 if [ $ret = 0 ] ; then
273 # got the correct prompt .. succeed
277 echo "failed reading owner-only file - grep failed with $ret"
282 testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
283 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
285 testit "noninteractive smbclient does not prompt" \
286 test_noninteractive_no_prompt || \
287 failed=`expr $failed + 1`
289 testit "noninteractive smbclient -l does not prompt" \
290 test_noninteractive_no_prompt -l /tmp || \
291 failed=`expr $failed + 1`
293 testit "interactive smbclient prompts on stdout" \
294 test_interactive_prompt_stdout || \
295 failed=`expr $failed + 1`
297 testit "interactive smbclient -l prompts on stdout" \
298 test_interactive_prompt_stdout -l /tmp || \
299 failed=`expr $failed + 1`
301 testit "creating a bad symlink and deleting it" \
302 test_bad_symlink || \
303 failed=`expr $failed + 1`
305 testit "creating a good symlink and deleting it by path" \
306 test_good_symlink || \
307 failed=`expr $failed + 1`
309 testit "writing into a read-only directory fails" \
310 test_read_only_dir || \
311 failed=`expr $failed + 1`
313 testit "Reading a owner-only file fails" \
314 test_owner_only_file || \
315 failed=`expr $failed + 1`