libnet: Fix Coverity ID 1634803 Dereference after null check
[samba4-gss.git] / source3 / script / tests / test_open_eintr.sh
blobb40b14d65e7b14bb7bf2784a31157ac6376b009c
1 #!/usr/bin/env bash
3 # Test smbd handling when open returns EINTR
5 # Copyright (C) 2020 Volker Lendecke
7 if [ $# -lt 5 ]; then
8 echo Usage: test_open_eintr.sh \
9 --configfile=SERVERCONFFILE SMBCLIENT SMBCONTROL SERVER SHARE
10 exit 1
13 CONF=$1
14 shift 1
15 SMBCLIENT=$1
16 shift 1
17 SMBCONTROL=$1
18 shift 1
19 SERVER=$1
20 shift 1
21 SHARE=$1
22 shift 1
24 # Do not let deprecated option warnings muck this up
25 SAMBA_DEPRECATED_SUPPRESS=1
26 export SAMBA_DEPRECATED_SUPPRESS
28 error_inject_conf=$(dirname ${SERVERCONFFILE})/error_inject.conf
29 >${error_inject_conf}
31 incdir=$(dirname $0)/../../../testprogs/blackbox
32 . $incdir/subunit.sh
34 failed=0
36 cd $SELFTEST_TMPDIR || exit 1
38 rm -f smbclient-stdin smbclient-stdout smbclient-stderr
39 mkfifo smbclient-stdin smbclient-stdout smbclient-stderr
41 CLI_FORCE_INTERACTIVE=1
42 export CLI_FORCE_INTERACTIVE
44 ${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} -U${USER}%${PASSWORD} \
45 <smbclient-stdin >smbclient-stdout 2>smbclient-stderr &
46 CLIENT_PID=$!
48 sleep 1
50 exec 100>smbclient-stdin 101<smbclient-stdout 102<smbclient-stderr
52 # consume the smbclient startup messages
53 head -n 1 <&101
55 echo "error_inject:openat = EINTR" >${error_inject_conf}
56 ${SMBCONTROL} ${CONF} 0 reload-config
58 sleep 1
59 >${error_inject_conf}
61 echo 'get badnames/blank.txt -' >&100
63 sleep 1
65 >${error_inject_conf}
66 ${SMBCONTROL} ${CONF} 0 reload-config
68 head -n 1 <&102 | grep 'getting file' >/dev/null
69 GREP_RET=$?
71 kill ${CLIENT_PID}
72 rm -f smbclient-stdin smbclient-stdout smbclient-stderr
74 testit "Verify that we could get the file" \
75 test $GREP_RET -eq 0 || failed=$(expr $failed + 1)
77 testok $0 $failed