[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Wed Apr 18 08:54:04 MDT 2012


The branch, master has been updated
       via  2085c20 s4:torture:smb2: add a session.reauth2 test.
       via  f3ac212 s4:torture:smb2: rename the file in the session-reauth1 test more systematically
       via  361deb8 s4:torture:smb2: rename the session_reauth test to session_reauth1
      from  26b9ab2 s4-torture: notify all is empty now

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


- Log -----------------------------------------------------------------
commit 2085c20bb123edb50098a11c22c103269d2f4fd9
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 18 14:12:28 2012 +0200

    s4:torture:smb2: add a session.reauth2 test.
    
    * open a file,
    * reauth anonymously
    * try to access file via handle
    * reauth as user
    * try to access file again
    
    Autobuild-User: Michael Adam <obnox at samba.org>
    Autobuild-Date: Wed Apr 18 16:53:35 CEST 2012 on sn-devel-104

commit f3ac212d8badf9f648cffcfe5c0849be274d5c27
Author: Michael Adam <obnox at samba.org>
Date:   Mon Apr 16 14:58:48 2012 +0200

    s4:torture:smb2: rename the file in the session-reauth1 test more systematically
    
    The original name seems to have come in via copy and paste.

commit 361deb856b3596a4ae56bab36431fab011a5a79f
Author: Michael Adam <obnox at samba.org>
Date:   Mon Apr 16 14:57:18 2012 +0200

    s4:torture:smb2: rename the session_reauth test to session_reauth1
    
    More tests reauth? will follow...

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

Summary of changes:
 source4/torture/smb2/session.c |   99 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 96 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/torture/smb2/session.c b/source4/torture/smb2/session.c
index f565975..aaebf05 100644
--- a/source4/torture/smb2/session.c
+++ b/source4/torture/smb2/session.c
@@ -26,6 +26,8 @@
 #include "torture/smb2/proto.h"
 #include "../libcli/smb/smbXcli_base.h"
 #include "lib/cmdline/popt_common.h"
+#include "auth/credentials/credentials.h"
+
 
 #define CHECK_VAL(v, correct) do { \
 	if ((v) != (correct)) { \
@@ -134,7 +136,7 @@ done:
 	return ret;
 }
 
-bool test_session_reauth(struct torture_context *tctx, struct smb2_tree *tree)
+bool test_session_reauth1(struct torture_context *tctx, struct smb2_tree *tree)
 {
 	NTSTATUS status;
 	TALLOC_CTX *mem_ctx = talloc_new(tctx);
@@ -146,7 +148,76 @@ bool test_session_reauth(struct torture_context *tctx, struct smb2_tree *tree)
 	union smb_fileinfo qfinfo;
 
 	/* Add some random component to the file name. */
-	snprintf(fname, 256, "session_reconnect_%s.dat",
+	snprintf(fname, 256, "session_reauth1_%s.dat",
+		 generate_random_str(tctx, 8));
+
+	smb2_util_unlink(tree, fname);
+
+	smb2_oplock_create_share(&io1, fname,
+				 smb2_util_share_access(""),
+				 smb2_util_oplock_level("b"));
+
+	status = smb2_create(tree, mem_ctx, &io1);
+	CHECK_STATUS(status, NT_STATUS_OK);
+	_h1 = io1.out.file.handle;
+	h1 = &_h1;
+	CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+	CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b"));
+
+	status = smb2_session_setup_spnego(tree->session,
+					   cmdline_credentials,
+					   0 /* previous_session_id */);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
+	/* try to access the file via the old handle */
+
+	ZERO_STRUCT(qfinfo);
+	qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+	qfinfo.generic.in.file.handle = _h1;
+	status = smb2_getinfo_file(tree, mem_ctx, &qfinfo);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
+	status = smb2_session_setup_spnego(tree->session,
+					   cmdline_credentials,
+					   0 /* previous_session_id */);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
+	/* try to access the file via the old handle */
+
+	ZERO_STRUCT(qfinfo);
+	qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+	qfinfo.generic.in.file.handle = _h1;
+	status = smb2_getinfo_file(tree, mem_ctx, &qfinfo);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
+done:
+	if (h1 != NULL) {
+		smb2_util_close(tree, *h1);
+	}
+
+	smb2_util_unlink(tree, fname);
+
+	talloc_free(tree);
+
+	talloc_free(mem_ctx);
+
+	return ret;
+}
+
+bool test_session_reauth2(struct torture_context *tctx, struct smb2_tree *tree)
+{
+	NTSTATUS status;
+	TALLOC_CTX *mem_ctx = talloc_new(tctx);
+	char fname[256];
+	struct smb2_handle _h1;
+	struct smb2_handle *h1 = NULL;
+	struct smb2_create io1;
+	bool ret = true;
+	union smb_fileinfo qfinfo;
+	struct cli_credentials *anon_creds = NULL;
+
+	/* Add some random component to the file name. */
+	snprintf(fname, 256, "session_reauth2_%s.dat",
 		 generate_random_str(tctx, 8));
 
 	smb2_util_unlink(tree, fname);
@@ -162,6 +233,26 @@ bool test_session_reauth(struct torture_context *tctx, struct smb2_tree *tree)
 	CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE);
 	CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b"));
 
+	/* re-authenticate as anonymous */
+
+	anon_creds = cli_credentials_init_anon(mem_ctx);
+	torture_assert(tctx, (anon_creds != NULL), "talloc error");
+
+	status = smb2_session_setup_spnego(tree->session,
+					   anon_creds,
+					   0 /* previous_session_id */);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
+	/* try to access the file via the old handle */
+
+	ZERO_STRUCT(qfinfo);
+	qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+	qfinfo.generic.in.file.handle = _h1;
+	status = smb2_getinfo_file(tree, mem_ctx, &qfinfo);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
+	/* re-authenticate as original user again */
+
 	status = smb2_session_setup_spnego(tree->session,
 					   cmdline_credentials,
 					   0 /* previous_session_id */);
@@ -189,13 +280,15 @@ done:
 	return ret;
 }
 
+
 struct torture_suite *torture_smb2_session_init(void)
 {
 	struct torture_suite *suite =
 	    torture_suite_create(talloc_autofree_context(), "session");
 
 	torture_suite_add_1smb2_test(suite, "reconnect", test_session_reconnect);
-	torture_suite_add_1smb2_test(suite, "reauth", test_session_reauth);
+	torture_suite_add_1smb2_test(suite, "reauth1", test_session_reauth1);
+	torture_suite_add_1smb2_test(suite, "reauth2", test_session_reauth2);
 
 	suite->description = talloc_strdup(suite, "SMB2-SESSION tests");
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list