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.$$
135 slink_name
="$LOCAL_PATH/slink"
136 slink_target
="$LOCAL_PATH/slink_target"
139 ln -s $slink_target $slink_name
145 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
151 if [ $ret != 0 ] ; then
153 echo "failed delete good symlink with error $ret"
160 if [ ! -e $slink_target ] ; then
161 echo "failed delete good symlink - symlink target deleted !"
168 if [ -e $slink_name ] ; then
169 echo "failed delete good symlink - symlink still exists"
174 # got the correct prompt .. succeed
180 # Test writing into a read-only directory (logon as guest) fails.
183 prompt
="NT_STATUS_ACCESS_DENIED making remote directory"
184 tmpfile
=/tmp
/smbclient.
in.$$
187 ## We can't do this as non-root. We always have rights to
188 ## create the directory.
190 if [ "$USERID" != 0 ] ; then
191 echo "skipping test_read_only_dir as non-root"
197 ## We can't do this with an encrypted connection. No credentials
198 ## to set up the channel.
200 if [ "$ADDARGS" = "-e" ] ; then
201 echo "skipping test_read_only_dir with encrypted connection"
211 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
217 if [ $ret != 0 ] ; then
219 echo "failed writing into read-only directory with error $ret"
224 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
227 if [ $ret = 0 ] ; then
228 # got the correct prompt .. succeed
232 echo "failed writing into read-only directory - grep failed with $ret"
237 # Test reading an owner-only file (logon as guest) fails.
238 test_owner_only_file
()
240 prompt
="NT_STATUS_ACCESS_DENIED opening remote file"
241 tmpfile
=/tmp
/smbclient.
in.$$
244 ## We can't do this as non-root. We always have rights to
247 if [ "$USERID" != 0 ] ; then
248 echo "skipping test_owner_only_file as non-root"
254 ## We can't do this with an encrypted connection. No credentials
255 ## to set up the channel.
257 if [ "$ADDARGS" = "-e" ] ; then
258 echo "skipping test_owner_only_file with encrypted connection"
268 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
274 if [ $ret != 0 ] ; then
276 echo "failed reading owner-only file with error $ret"
281 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
284 if [ $ret = 0 ] ; then
285 # got the correct prompt .. succeed
289 echo "failed reading owner-only file - grep failed with $ret"
294 testit
"smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed
=`expr $failed + 1`
295 testit
"smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed
=`expr $failed + 1`
297 testit
"noninteractive smbclient does not prompt" \
298 test_noninteractive_no_prompt || \
299 failed
=`expr $failed + 1`
301 testit
"noninteractive smbclient -l does not prompt" \
302 test_noninteractive_no_prompt
-l /tmp || \
303 failed
=`expr $failed + 1`
305 testit
"interactive smbclient prompts on stdout" \
306 test_interactive_prompt_stdout || \
307 failed
=`expr $failed + 1`
309 testit
"interactive smbclient -l prompts on stdout" \
310 test_interactive_prompt_stdout
-l /tmp || \
311 failed
=`expr $failed + 1`
313 testit
"creating a bad symlink and deleting it" \
314 test_bad_symlink || \
315 failed
=`expr $failed + 1`
317 testit
"creating a good symlink and deleting it by path" \
318 test_good_symlink || \
319 failed
=`expr $failed + 1`
321 testit
"writing into a read-only directory fails" \
322 test_read_only_dir || \
323 failed
=`expr $failed + 1`
325 testit
"Reading a owner-only file fails" \
326 test_owner_only_file || \
327 failed
=`expr $failed + 1`