3 # Test smbcontrol close-share command.
5 # Copyright (C) 2020 Volker Lendecke
6 # Copyright (C) 2020 Jeremy Allison
8 # Note this is designed to be run against
9 # the aio_delay_inject share which is preconfigured
10 # with 2 second delays on pread/pwrite.
13 echo Usage
: $0 SERVERCONFFILE SMBCLIENT SMBCONTROL IP aio_delay_inject_sharename PREFIX
25 # Do not let deprecated option warnings muck this up
26 SAMBA_DEPRECATED_SUPPRESS
=1
27 export SAMBA_DEPRECATED_SUPPRESS
29 incdir
=$
(dirname $0)/..
/..
/..
/testprogs
/blackbox
31 .
$incdir/common_test_fns.inc
35 mkdir
-p $PREFIX/private
37 FIFO_STDIN
="$PREFIX/smbclient-stdin"
38 FIFO_STDOUT
="$PREFIX/smbclient-stdout"
39 FIFO_STDERR
="$PREFIX/smbclient-stderr"
40 TESTFILE
="$PREFIX/testfile"
42 rm -f $FIFO_STDIN $FIFO_STDOUT $FIFO_STDERR $TESTFILE 2>/dev
/null
44 # Create the smbclient communication pipes.
45 mkfifo $FIFO_STDIN $FIFO_STDOUT $FIFO_STDERR
47 echo "Failed to create fifos"
51 # Create a large-ish testfile
52 head -c 100MB
/dev
/zero
>$TESTFILE
54 CLI_FORCE_INTERACTIVE
=1
55 export CLI_FORCE_INTERACTIVE
57 ${smbclient} //${SERVER}/${SHARE} ${CONFIGURATION} -U${USER}%${PASSWORD} \
58 <$FIFO_STDIN >$FIFO_STDOUT 2>$FIFO_STDERR &
63 if [ $count -ge 20 ]; then
64 echo "Failed to start smbclient"
75 exec 100>$FIFO_STDIN 101<$FIFO_STDOUT 102<$FIFO_STDERR
77 # consume the smbclient startup messages
80 # Ensure we're putting a fresh file.
81 echo "lcd $(dirname $TESTFILE)" >&100
82 echo "del testfile" >&100
83 echo "put testfile" >&100
87 # Close the aio_delay_inject share whilst we have outstanding writes.
89 testit
"smbcontrol" ${SMBCONTROL} ${CONFIGURATION} smbd close-share ${SHARE} ||
90 failed
=$
(expr $failed + 1)
94 # If we get one or more NT_STATUS_NETWORK_NAME_DELETED
95 # or NT_STATUS_INVALID_HANDLE on stderr from the writes we
96 # know the server stayed up and didn't crash when the
97 # close-share removed the share.
99 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301
101 COUNT
=$
(head -n 2 <&102 |
102 grep -e NT_STATUS_NETWORK_NAME_DELETED
-e NT_STATUS_INVALID_HANDLE |
105 testit
"Verify close-share did cancel the file put" \
106 test $COUNT -ge 1 || failed
=$
(expr $failed + 1)
110 # Remove the testfile from the server
111 test_smbclient
"remove_testfile" \
112 'del testfile; quit' //${SERVER}/${SHARE} -U${USER}%${PASSWORD} ||
113 failed
=$
(expr $failed + 1)