diff options
author | Jeremy Allison <jra@samba.org> | 2012-10-29 14:49:36 -0700 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2012-10-31 03:21:37 +0100 |
commit | 59e9661de2dd19808295002f1329b27d5dca09e6 (patch) | |
tree | 7fe0fce55160cef9a6ec401f548759ca56d59cdb /source3/script | |
parent | a71ad96bd046f1199e67b4fe8fc7783cbd8dd771 (diff) | |
download | samba-59e9661de2dd19808295002f1329b27d5dca09e6.tar.gz samba-59e9661de2dd19808295002f1329b27d5dca09e6.tar.bz2 samba-59e9661de2dd19808295002f1329b27d5dca09e6.zip |
Add regression test for bug #9329 - Directory listing with SeBackup can crash smbd.
Ensure we exercise the SeBackup code path on directory listings.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Oct 31 03:21:38 CET 2012 on sn-devel-104
Diffstat (limited to 'source3/script')
-rwxr-xr-x | source3/script/tests/test_smbclient_s3.sh | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 3341c62f4b..fb518c58c7 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -2,9 +2,9 @@ # this runs the file serving tests that are expected to pass with samba3 -if [ $# -lt 7 ]; then +if [ $# -lt 11 ]; then cat <<EOF -Usage: test_smbclient_s3.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD USERID LOCAL_PATH PREFIX SMBCLIENT WBINFO +Usage: test_smbclient_s3.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD USERID LOCAL_PATH PREFIX SMBCLIENT WBINFO NET EOF exit 1; fi @@ -19,9 +19,10 @@ LOCAL_PATH="${7}" PREFIX="${8}" SMBCLIENT="${9}" WBINFO="${10}" +NET="${11}" SMBCLIENT="$VALGRIND ${SMBCLIENT}" WBINFO="$VALGRIND ${WBINFO}" -shift 10 +shift 11 ADDARGS="$*" incdir=`dirname $0`/../../../testprogs/blackbox @@ -489,6 +490,57 @@ EOF fi } +# Test doing a directory listing with backup privilege. +test_backup_privilege_list() +{ + tmpfile=$PREFIX/smbclient_backup_privilege_list + + # If we don't have a DOMAIN component to the username, add it. + echo "$USERNAME" | grep '\\' 2>&1 + ret=$? + if [ $ret != 0 ] ; then + priv_username="$DOMAIN\\$USERNAME" + else + priv_username=$USERNAME + fi + + $NET sam rights grant $priv_username SeBackupPrivilege 2>&1 + ret=$? + if [ $ret != 0 ] ; then + echo "Failed to add SeBackupPrivilege to user $priv_username - $ret" + false + return + fi + + cat > $tmpfile <<EOF +backup +ls +quit +EOF + + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + rm -f $tmpfile + + if [ $ret != 0 ] ; then + echo "$out" + echo "failed backup privilege list $ret" + false + return + fi + +# Now remove all privileges from this SID. + $NET sam rights revoke $priv_username SeBackupPrivilege 2>&1 + ret=$? + if [ $ret != 0 ] ; then + echo "failed to remove SeBackupPrivilege from user $priv_username - $ret" + false + return + fi +} + LOGDIR_PREFIX=test_smbclient_s3 # possibly remove old logdirs: @@ -552,6 +604,10 @@ testit "using an authentication file" \ test_auth_file || \ failed=`expr $failed + 1` +testit "list with backup privilege" \ + test_backup_privilege_list || \ + failed=`expr $failed + 1` + testit "rm -rf $LOGDIR" \ rm -rf $LOGDIR || \ failed=`expr $failed + 1` |