Changeset 740 for vendor/current/source3/script/tests/test_smbclient_s3.sh
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/script/tests/test_smbclient_s3.sh
r414 r740 3 3 # this runs the file serving tests that are expected to pass with samba3 4 4 5 if [ $# -lt 4]; then5 if [ $# -lt ]; then 6 6 cat <<EOF 7 Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD 7 Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD 8 8 EOF 9 9 exit 1; … … 14 14 USERNAME="$3" 15 15 PASSWORD="$4" 16 SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION" 17 shift 4 16 USERID="$5" 17 LOCAL_PATH="$6" 18 PREFIX="$7" 19 SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient}" 20 WBINFO="$VALGRIND ${WBINFO:-$BINDIR/wbinfo}" 21 shift 7 18 22 ADDARGS="$*" 19 23 20 24 test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { 21 incdir=`dirname $0` 22 . $incdir/ test_functions.sh25 incdir=`dirname $0` 26 . $incdir/.sh 23 27 } 24 28 … … 30 34 prompt="smb" 31 35 32 cmd='echo du | $SMBCLIENT $CONFIGURATION"$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'36 cmd='echo du | $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1' 33 37 eval echo "$cmd" 34 38 out=`eval $cmd` … … 56 60 { 57 61 prompt="smb" 58 tmpfile= /tmp/smbclient.in.$$62 tmpfile= 59 63 60 64 cat > $tmpfile <<EOF … … 63 67 EOF 64 68 65 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION"$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'69 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' 66 70 eval echo "$cmd" 67 71 out=`eval $cmd` … … 91 95 { 92 96 prompt="posix_unlink deleted file /newname" 93 tmpfile= /tmp/smbclient.in.$$97 tmpfile= 94 98 95 99 cat > $tmpfile <<EOF … … 101 105 EOF 102 106 103 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION"$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'107 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' 104 108 eval echo "$cmd" 105 109 out=`eval $cmd` … … 127 131 } 128 132 129 130 testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1` 131 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1` 133 # Test creating a good symlink and deleting it by path. 134 test_good_symlink() 135 { 136 tmpfile=/tmp/smbclient.in.$$ 137 slink_name="$LOCAL_PATH/slink" 138 slink_target="$LOCAL_PATH/slink_target" 139 140 touch $slink_target 141 ln -s $slink_target $slink_name 142 cat > $tmpfile <<EOF 143 del slink 144 quit 145 EOF 146 147 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' 148 eval echo "$cmd" 149 out=`eval $cmd` 150 ret=$? 151 rm -f $tmpfile 152 153 if [ $ret != 0 ] ; then 154 echo "$out" 155 echo "failed delete good symlink with error $ret" 156 rm $slink_target 157 rm $slink_name 158 false 159 return 160 fi 161 162 if [ ! -e $slink_target ] ; then 163 echo "failed delete good symlink - symlink target deleted !" 164 rm $slink_target 165 rm $slink_name 166 false 167 return 168 fi 169 170 if [ -e $slink_name ] ; then 171 echo "failed delete good symlink - symlink still exists" 172 rm $slink_target 173 rm $slink_name 174 false 175 else 176 # got the correct prompt .. succeed 177 rm $slink_target 178 true 179 fi 180 } 181 182 # Test writing into a read-only directory (logon as guest) fails. 183 test_read_only_dir() 184 { 185 prompt="NT_STATUS_ACCESS_DENIED making remote directory" 186 tmpfile=/tmp/smbclient.in.$$ 187 188 ## 189 ## We can't do this as non-root. We always have rights to 190 ## create the directory. 191 ## 192 if [ "$USERID" != 0 ] ; then 193 echo "skipping test_read_only_dir as non-root" 194 true 195 return 196 fi 197 198 ## 199 ## We can't do this with an encrypted connection. No credentials 200 ## to set up the channel. 201 ## 202 if [ "$ADDARGS" = "-e" ] ; then 203 echo "skipping test_read_only_dir with encrypted connection" 204 true 205 return 206 fi 207 208 cat > $tmpfile <<EOF 209 mkdir a_test_dir 210 quit 211 EOF 212 213 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' 214 eval echo "$cmd" 215 out=`eval $cmd` 216 ret=$? 217 rm -f $tmpfile 218 219 if [ $ret != 0 ] ; then 220 echo "$out" 221 echo "failed writing into read-only directory with error $ret" 222 false 223 return 224 fi 225 226 echo "$out" | grep "$prompt" >/dev/null 2>&1 227 228 ret=$? 229 if [ $ret = 0 ] ; then 230 # got the correct prompt .. succeed 231 true 232 else 233 echo "$out" 234 echo "failed writing into read-only directory - grep failed with $ret" 235 false 236 fi 237 } 238 239 # Test reading an owner-only file (logon as guest) fails. 240 test_owner_only_file() 241 { 242 prompt="NT_STATUS_ACCESS_DENIED opening remote file" 243 tmpfile=/tmp/smbclient.in.$$ 244 245 ## 246 ## We can't do this as non-root. We always have rights to 247 ## read the file. 248 ## 249 if [ "$USERID" != 0 ] ; then 250 echo "skipping test_owner_only_file as non-root" 251 true 252 return 253 fi 254 255 ## 256 ## We can't do this with an encrypted connection. No credentials 257 ## to set up the channel. 258 ## 259 if [ "$ADDARGS" = "-e" ] ; then 260 echo "skipping test_owner_only_file with encrypted connection" 261 true 262 return 263 fi 264 265 cat > $tmpfile <<EOF 266 get unreadable_file 267 quit 268 EOF 269 270 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' 271 eval echo "$cmd" 272 out=`eval $cmd` 273 ret=$? 274 rm -f $tmpfile 275 276 if [ $ret != 0 ] ; then 277 echo "$out" 278 echo "failed reading owner-only file with error $ret" 279 false 280 return 281 fi 282 283 echo "$out" | grep "$prompt" >/dev/null 2>&1 284 285 ret=$? 286 if [ $ret = 0 ] ; then 287 # got the correct prompt .. succeed 288 true 289 else 290 echo "$out" 291 echo "failed reading owner-only file - grep failed with $ret" 292 false 293 fi 294 } 295 296 # Test accessing an msdfs path. 297 test_msdfs_link() 298 { 299 tmpfile=/tmp/smbclient.in.$$ 300 prompt=" msdfs-target " 301 302 cat > $tmpfile <<EOF 303 ls 304 cd \\msdfs-src1 305 ls msdfs-target 306 quit 307 EOF 308 309 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' 310 eval echo "$cmd" 311 out=`eval $cmd` 312 ret=$? 313 rm -f $tmpfile 314 315 if [ $ret != 0 ] ; then 316 echo "$out" 317 echo "failed accessing \\msdfs-src1 link with error $ret" 318 false 319 return 320 fi 321 322 echo "$out" | grep "$prompt" >/dev/null 2>&1 323 324 ret=$? 325 if [ $ret != 0 ] ; then 326 echo "$out" 327 echo "failed listing \\msdfs-src1 - grep failed with $ret" 328 false 329 fi 330 331 cat > $tmpfile <<EOF 332 ls 333 cd \\deeppath\\msdfs-src2 334 ls msdfs-target 335 quit 336 EOF 337 338 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' 339 eval echo "$cmd" 340 out=`eval $cmd` 341 ret=$? 342 rm -f $tmpfile 343 344 if [ $ret != 0 ] ; then 345 echo "$out" 346 echo "failed accessing \\deeppath\\msdfs-src2 link with error $ret" 347 false 348 return 349 fi 350 351 echo "$out" | grep "$prompt" >/dev/null 2>&1 352 353 ret=$? 354 if [ $ret != 0 ] ; then 355 echo "$out" 356 echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret" 357 false 358 return 359 else 360 true 361 return 362 fi 363 } 364 365 # Test authenticating using the winbind ccache 366 test_ccache_access() 367 { 368 $WBINFO --ccache-save="${USERNAME}%${PASSWORD}" 369 $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}%" \ 370 -c quit 2>&1 371 ret=$? 372 373 if [ $ret != 0 ] ; then 374 echo "smbclient failed to use cached credentials" 375 false 376 return 377 fi 378 379 $WBINFO --ccache-save="${USERNAME}%GarBage" 380 $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}%" \ 381 -c quit 2>&1 382 ret=$? 383 384 if [ $ret -eq 0 ] ; then 385 echo "smbclient succeeded with wrong cached credentials" 386 false 387 return 388 fi 389 390 $WBINFO --logoff 391 } 392 393 LOGDIR_PREFIX=test_smbclient_s3 394 395 # possibly remove old logdirs: 396 397 for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do 398 echo "removing old directory ${OLDDIR}" 399 rm -rf ${OLDDIR} 400 done 401 402 LOGDIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX) 403 404 405 testit "smbclient -L $SERVER_IP" $SMBCLIENT -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1` 406 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT -L $SERVER -I $SERVER_IP -N -p 139 -c quit || failed=`expr $failed + 1` 132 407 133 408 testit "noninteractive smbclient does not prompt" \ … … 136 411 137 412 testit "noninteractive smbclient -l does not prompt" \ 138 test_noninteractive_no_prompt -l /tmp|| \413 test_noninteractive_no_prompt -l || \ 139 414 failed=`expr $failed + 1` 140 415 … … 144 419 145 420 testit "interactive smbclient -l prompts on stdout" \ 146 test_interactive_prompt_stdout -l /tmp|| \421 test_interactive_prompt_stdout -l || \ 147 422 failed=`expr $failed + 1` 148 423 … … 151 426 failed=`expr $failed + 1` 152 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 153 452 testok $0 $failed
Note:
See TracChangeset
for help on using the changeset viewer.
