[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Oct 21 02:49:02 UTC 2016


The branch, master has been updated
       via  ad60b8c s3: selftest: Add test for orphan 'lost-XXX' directories in streams_depot.
       via  b17c9fd s3: vfs: Remove files/directories after the streams are deleted.
       via  4e93ea2 s3: torture: vfstest. unlink cmd must be stream aware.
      from  beda6d3 torture: Fix uninitialized variables

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ad60b8cc48b1095ce97170eed3d09fca7181a3bc
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Oct 19 16:33:52 2016 -0700

    s3: selftest: Add test for orphan 'lost-XXX' directories in streams_depot.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Oct 21 04:48:52 CEST 2016 on sn-devel-144

commit b17c9fdc51c10313eed32d6e078ed7050a342d0f
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Oct 19 11:56:49 2016 -0700

    s3: vfs: Remove files/directories after the streams are deleted.
    
    By the time we get to SMB_VFS_UNLINK/SMB_VFS_RMDIR the ACL
    checks have already been done.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>

commit 4e93ea2340b7589769d55085aaa71070a2d7e416
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Oct 20 13:33:09 2016 -0700

    s3: torture: vfstest. unlink cmd must be stream aware.
    
    Otherwise the following patch breaks vfstest stream-depot test.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_streams_depot.c       | 18 +++++++++++---
 source3/script/tests/test_smbclient_s3.sh | 41 +++++++++++++++++++++++++++++++
 source3/torture/cmd_vfs.c                 |  8 ++++++
 3 files changed, 63 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index 83c9d97..d874514 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -725,8 +725,12 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
 		return -1;
 	}
 
-	ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
-	if (ret == 0) {
+	/*
+	 * We know the unlink should succeed as the ACL
+	 * check is already done in the caller. Remove the
+	 * file *after* the streams.
+	 */
+	{
 		char *dirname = stream_dir(handle, smb_fname_base,
 					   &smb_fname_base->st, false);
 
@@ -749,6 +753,7 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
 		TALLOC_FREE(dirname);
 	}
 
+	ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
 	TALLOC_FREE(smb_fname_base);
 	return ret;
 }
@@ -787,8 +792,12 @@ static int streams_depot_rmdir(vfs_handle_struct *handle,
 		return -1;
 	}
 
-	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
-	if (ret == 0) {
+	/*
+	 * We know the rmdir should succeed as the ACL
+	 * check is already done in the caller. Remove the
+	 * directory *after* the streams.
+	 */
+	{
 		char *dirname = stream_dir(handle, smb_fname_base,
 					   &smb_fname_base->st, false);
 
@@ -811,6 +820,7 @@ static int streams_depot_rmdir(vfs_handle_struct *handle,
 		TALLOC_FREE(dirname);
 	}
 
+	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
 	TALLOC_FREE(smb_fname_base);
 	return ret;
 }
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index 5e3db5d..22849bd 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -1060,6 +1060,43 @@ EOF
     fi
 }
 
+# Test creating then deleting a stream file doesn't leave a lost-XXXXX directory.
+test_streams_depot_delete()
+{
+    tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+    rm -rf "$LOCAL_PATH/lost-*"
+
+    cat > $tmpfile <<EOF
+put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
+del foo
+ls lost*
+quit
+EOF
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP -mSMB3 $ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    rm -f $tmpfile
+
+    if [ $ret != 0 ] ; then
+	echo "$out"
+	echo "failed creating then deleting foo:bar with error $ret"
+	false
+	return
+    fi
+
+    echo "$out" | grep 'NT_STATUS_NO_SUCH_FILE listing \\lost\*'
+    ret=$?
+    if [ $ret != 0 ] ; then
+	echo "$out"
+	echo "deleting foo:bar left lost-XXX directory"
+	rm -rf "$LOCAL_PATH/lost-*"
+	false
+	return
+    fi
+}
+
+
 LOGDIR_PREFIX=test_smbclient_s3
 
 # possibly remove old logdirs:
@@ -1155,6 +1192,10 @@ testit "Ensure widelinks are restricted" \
     test_widelinks || \
     failed=`expr $failed + 1`
 
+testit "streams_depot can delete correctly" \
+    test_streams_depot_delete || \
+    failed=`expr $failed + 1`
+
 testit "rm -rf $LOGDIR" \
     rm -rf $LOGDIR || \
     failed=`expr $failed + 1`
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 12610cf..b57a061 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -442,6 +442,14 @@ static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg
 		ret = SMB_VFS_RMDIR(vfs->conn, smb_fname);
 		TALLOC_FREE(smb_fname);
 	} else if (strcmp("unlink", argv[0]) == 0 ) {
+		TALLOC_FREE(smb_fname);
+		/* unlink can be a stream:name */
+		smb_fname = synthetic_smb_fname_split(talloc_tos(),
+					argv[1],
+					lp_posix_pathnames());
+		if (smb_fname == NULL) {
+			return NT_STATUS_NO_MEMORY;
+		}
 		ret = SMB_VFS_UNLINK(vfs->conn, smb_fname);
 		TALLOC_FREE(smb_fname);
 	} else if (strcmp("chdir", argv[0]) == 0 ) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list