1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-24 02:04:21 +03:00
samba-mirror/source3/script/tests/test_force_user_unlink.sh
Andreas Schneider f1e40238e4 s3:tests: Reformat test_force_user_unlink.sh
shfmt -f source3/script/| xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-05-05 11:00:35 +00:00

42 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
#
# Test unlink on share with "force user"
#
# Copyright (C) 2021 Ralph Boehme
incdir=$(dirname $0)/../../../testprogs/blackbox
. $incdir/subunit.sh
. $incdir/common_test_fns.inc
smbclient="$BINDIR/smbclient"
error_inject_conf=$(dirname ${SMB_CONF_PATH})/error_inject.conf
failed=0
test_forced_user_can_delete()
{
out=$($smbclient -U $DOMAIN/$USERNAME%$PASSWORD //$SERVER_IP/force_user_error_inject -c "rm dir/file")
if [ $? -ne 0 ]; then
echo $out
return 1
fi
tmp=$(echo $out | grep NT_STATUS_)
if [ $? -eq 0 ]; then
return 1
fi
return 0
}
echo "error_inject:unlinkat = EACCES" >${error_inject_conf}
$smbclient -U $DOMAIN/$USERNAME%$PASSWORD //$SERVER_IP/force_user_error_inject -c "mkdir dir" || failed=$(expr $failed + 1)
$smbclient -U $DOMAIN/$USERNAME%$PASSWORD //$SERVER_IP/force_user_error_inject -c "put WHATSNEW.txt dir/file" || failed=$(expr $failed + 1)
testit "test_forced_user_can_delete" test_forced_user_can_delete || failed=$(expr $failed + 1)
rm ${error_inject_conf}
# Clean up after ourselves.
$smbclient -U $DOMAIN/$USERNAME%$PASSWORD //$SERVER_IP/force_user_error_inject -c "del dir/file; rmdir dir"
testok $0 $failed