2021-08-09 13:31:07 +03:00
#!/usr/bin/env bash
#
# Test deadtime parameter
#
if [ $# -lt 1 ] ; then
2022-04-22 16:34:08 +03:00
echo Usage: test_deadtime.sh IP
exit 1
2021-08-09 13:31:07 +03:00
fi
server = $1
2022-04-22 16:34:08 +03:00
incdir = $( dirname $0 ) /../../../testprogs/blackbox
2021-08-09 13:31:07 +03:00
. $incdir /subunit.sh
. $incdir /common_test_fns.inc
failed = 0
smbclient = " $BINDIR /smbclient "
smbcontrol = " $BINDIR /smbcontrol "
global_inject_conf = $( dirname $SMB_CONF_PATH ) /global_inject.conf
2022-04-22 16:34:08 +03:00
echo "deadtime = 1" >$global_inject_conf
2021-08-09 13:31:07 +03:00
$smbcontrol smbd reload-config
cd $SELFTEST_TMPDIR || exit 1
# Create the smbclient communication pipes.
rm -f smbclient-stdin smbclient-stdout smbclient-stderr
mkfifo smbclient-stdin smbclient-stdout smbclient-stderr
export CLI_FORCE_INTERACTIVE = 1
export SAMBA_DEPRECATED_SUPPRESS = 1
# This gets inherited by smbclient and is required to smbclient doesn't get
# killed by an unhandled SIGPIPE when writing an SMB2 KEEPALIVE packet to the
# connection fd that was already closed by the server.
trap "" SIGPIPE
$smbclient //$server /tmp -U${ USER } %${ PASSWORD } \
2022-04-22 16:34:08 +03:00
<smbclient-stdin >smbclient-stdout 2>smbclient-stderr &
2021-08-09 13:31:07 +03:00
client_pid = $!
sleep 1
2022-04-22 16:34:08 +03:00
exec 100>smbclient-stdin 101<smbclient-stdout 102<smbclient-stderr
2021-08-09 13:31:07 +03:00
# consume the smbclient startup message
head -n 1 <& 101
sleep 70
err = $( head -n 1 <& 102)
echo " err: $err "
kill $client_pid
echo " $err " | grep NT_STATUS_CONNECTION_DISCONNECTED
testit "deadtime" test $? -eq 0 || failed = $( expr $failed + 1)
2022-04-22 16:34:08 +03:00
echo "" >$global_inject_conf
2021-08-09 13:31:07 +03:00
$smbcontrol smbd reload-config
rm -f smbclient-stdin smbclient-stdout smbclient-stderr
testok $0 $failed