[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Sat Oct 5 07:57:02 MDT 2013


The branch, master has been updated
       via  9110c07 smbd:smb2: clarify and comment code treating dh2c blob check.
       via  dd25679 smbd:smb2: ignore an dhnq blob along with a dhnc in create
       via  ea51681 smbd:smb2_create: fix return code for durable handle create blob combinations
       via  7b624cf s4:torture:smb2: add durable-v2-open.reopen2c
       via  ba05f70 s4:torture:smb2: add durable-v2-open.reopen2b
       via  0ecfe17 s4:torture:smb2: add durable-v2-open.create-blob
       via  bd3b922 s4:torture:smb2: extend the durable-open.reopen2 test
       via  6fc5661 s4:torture:smb2: extend the durable-v2-open.reopen2 test
       via  1bd2ab4 smbd:smb2: successfully answer a DHnC request when the initial create was DH2Q
       via  9769f06 smbd:smb2_create: add comment about validity of check reconnect blob being only one
       via  d8cd549 s4:torture:smb2: add a durable-open.reopen-lease-v2 test
       via  43c4a65 s4:torture:smb2: add durable-v2-open.reopen2-lease-v2
       via  5647287 s4:torture:smb2: add smb2_lease_v2_create() wrapper to smb2_lease_v2_create_share()
       via  d4f4d08 s4:torture:smb2: add durable-v2-open.reopen2-lease
       via  1f14747 s4:torture:smb2: add durable-open.reopen2-lease test
       via  6c6643c s4:torture:smb2: fix durable-open lease tests to pass against windows.
       via  a31ea15 s4:torture:smb2: add smbcli_options argument to torture_smb2_connection_ext()
       via  596f802 s4:libcli:smb2: make smbcli_options argument to smb2_connect_(send|ext) const
       via  5736f13 s4:libcli:smb2: add the smb2_capabilities to the smbcli_options
       via  4e99a0f s4:libcli:smb2: add the client_guid to the smbcli_options
       via  39a965a s4:torture:spoolss: use smb2_connect() instead of smb2_connet_ext()
       via  14e3f4b s4:torture:smb2: fix a comment in the durable-open.lock-oplock test
      from  8fe1f40 samba_backup: fix bug, add command line parameter, improve error messages

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


- Log -----------------------------------------------------------------
commit 9110c079f1aa504bc114d8c00a5a48f58dce5459
Author: Michael Adam <obnox at samba.org>
Date:   Fri Oct 4 12:39:57 2013 +0200

    smbd:smb2: clarify and comment code treating dh2c blob check.
    
    This makes the code that checks for extra create blobs in the
    case of the dh2c blob look very similar to the corresponding
    (slightly mode complex) code for the dhnc blob.
    
    With this preparation it will be easier and more obvious how
    to add proper treatment of the lease request blobs when leases
    get implemented.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Sat Oct  5 15:56:11 CEST 2013 on sn-devel-104

commit dd256792568d96c4a8dba5ea28cd3274ed1c040b
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 26 07:48:42 2013 +0200

    smbd:smb2: ignore an dhnq blob along with a dhnc in create
    
    This is according to MS-SMB2, 3.3.5.9.7
    "Handling the SMB2_CREATE_DURABLE_HANDLE_RECONNECT Create Context"
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit ea51681cc21f6e84af2f71309875c6692efcbc6e
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 20:39:17 2013 +0200

    smbd:smb2_create: fix return code for durable handle create blob combinations
    
    According to MS-SMB2:
    
    3.3.5.9.7 Handling the SMB2_CREATE_DURABLE_HANDLE_RECONNECT Create Context
    3.3.5.9.12 Handling the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 Create Context
    
    and verified by test results.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 7b624cf856816851882d00d82658b756c0c29c1e
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 26 07:00:33 2013 +0200

    s4:torture:smb2: add durable-v2-open.reopen2c
    
    - create durable with v1 request
    - reconnect with v2 reconnect request
    ==> fails
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit ba05f705a192a8f20ba1cc488016e58eebce2013
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 26 06:06:01 2013 +0200

    s4:torture:smb2: add durable-v2-open.reopen2b
    
    - connect with durable v2
    - reconnect with durable v1
    => succeeds
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 0ecfe1755e5e402188c9fa18f81561da248e3e12
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 26 05:47:47 2013 +0200

    s4:torture:smb2: add durable-v2-open.create-blob
    
    test various combinations of durable create and reconnect
    request blobs, according to
    MS-SMB2, 3.3.5.9.12:
    "Handling the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 Create Context"
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit bd3b922a45906ff1a98a892c2f045405f8fe8374
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 26 05:35:19 2013 +0200

    s4:torture:smb2: extend the durable-open.reopen2 test
    
    Add tests for:
    - filename and many other things don't matter in reconnect
    - additionally specified DHnQ request blob is ignored.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 6fc56616404e55cf6bd60b0fbfd190ddcccb0b0f
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 26 05:12:02 2013 +0200

    s4:torture:smb2: extend the durable-v2-open.reopen2 test
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 1bd2ab41611fc66386d8d7d0e4c7d4f948177eab
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 23:20:18 2013 +0200

    smbd:smb2: successfully answer a DHnC request when the initial create was DH2Q
    
    I.e. the durable reconnect attempt is v1 while the original create was durable
    v2 including the create guid.
    
    Implement this by skipping the create_guid verification when
    the reconnect request is v1.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9769f0697714dcd7835b1c5692a5352e176c9418
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 20:40:11 2013 +0200

    smbd:smb2_create: add comment about validity of check reconnect blob being only one
    
    With leases this will not be true any more.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit d8cd54962b158527e61e82a79eb49ee6da12c5a4
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 18:31:10 2013 +0200

    s4:torture:smb2: add a durable-open.reopen-lease-v2 test
    
    like durable-open.reopen2-lease but with v2 lease requets
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 43c4a65f91d3c9ea9941393d970af33a2aa2aa95
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 24 23:21:37 2013 +0200

    s4:torture:smb2: add durable-v2-open.reopen2-lease-v2
    
    lease v2 variant of the reopen2 test.
    Test various success and failure cases.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 5647287a42b528c2b7f52f94f9f722e09a146d8d
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 24 23:09:18 2013 +0200

    s4:torture:smb2: add smb2_lease_v2_create() wrapper to smb2_lease_v2_create_share()
    
    that sets share all. similar to smb2_lease_create()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit d4f4d08d6c373f65ba917b563d6b00949ab586d8
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 24 23:20:39 2013 +0200

    s4:torture:smb2: add durable-v2-open.reopen2-lease
    
    lease v1 variant of the reopen2 test
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 1f14747094302794ca81a96d68d05629663628ef
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 24 23:08:24 2013 +0200

    s4:torture:smb2: add durable-open.reopen2-lease test
    
    lease-variant of the reopen2 test
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 6c6643c36496f6ab691efaf818d0538e6f1b0de2
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 01:25:49 2013 +0200

    s4:torture:smb2: fix durable-open lease tests to pass against windows.
    
    Fix is: reconnect with same client-guid as on the first connection.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a31ea152036fb7750fd071da67e171d16a78474b
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 07:20:30 2013 +0200

    s4:torture:smb2: add smbcli_options argument to torture_smb2_connection_ext()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 596f802d5d56a446cb911fcb776ce84d6b44ea39
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 07:16:39 2013 +0200

    s4:libcli:smb2: make smbcli_options argument to smb2_connect_(send|ext) const
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5736f134003f426530040e732a6acc1c86b33f5f
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 06:57:23 2013 +0200

    s4:libcli:smb2: add the smb2_capabilities to the smbcli_options
    
    and initialize them in lpcfg_smbcli_options() instead of
    in smb2_transport_init() as previously.
    
    This will allow us to control them from callers later.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4e99a0fbfeb1330f67059caaef25669410510617
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 06:46:47 2013 +0200

    s4:libcli:smb2: add the client_guid to the smbcli_options
    
    and initialize it in lpcfg_smbcli_options() instead of
    in smb2_transport_init() as previously.
    
    Having the client guid in the smbcli_options will allow
    us to control them from callers later.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 39a965ac83ed8c6ad48c77519b47f6ca544ec713
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 25 06:21:38 2013 +0200

    s4:torture:spoolss: use smb2_connect() instead of smb2_connet_ext()
    
    in print_test_smbd: we don't need to pass the previous_session_id.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 14e3f4bd3b451eaefb6bbf67d58b000adacd462e
Author: Michael Adam <obnox at samba.org>
Date:   Mon Sep 23 22:55:55 2013 +0200

    s4:torture:smb2: fix a comment in the durable-open.lock-oplock test
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

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

Summary of changes:
 source3/smbd/globals.h                 |    2 +-
 source3/smbd/smb2_create.c             |   91 +++-
 source3/smbd/smbXsrv_open.c            |   12 +-
 source4/libcli/raw/libcliraw.h         |    2 +
 source4/libcli/smb2/connect.c          |    4 +-
 source4/libcli/smb2/transport.c        |   10 +-
 source4/param/loadparm.c               |    3 +
 source4/torture/rpc/spoolss.c          |   23 +-
 source4/torture/smb2/durable_open.c    |  632 +++++++++++++++++++++++--
 source4/torture/smb2/durable_v2_open.c |  814 +++++++++++++++++++++++++++++++-
 source4/torture/smb2/session.c         |    5 +-
 source4/torture/smb2/util.c            |   27 +-
 12 files changed, 1542 insertions(+), 83 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 9ea5e25..6beee59 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -457,7 +457,7 @@ NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
 NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn,
 			       struct auth_session_info *session_info,
 			       uint64_t persistent_id,
-			       struct GUID create_guid,
+			       const struct GUID *create_guid,
 			       NTTIME now,
 			       struct smbXsrv_open **_open);
 struct smbXsrv_open_global0;
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index 4f2edfc..140c81b 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -421,6 +421,8 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 	int requested_oplock_level;
 	struct smb2_create_blob *dhnc = NULL;
 	struct smb2_create_blob *dh2c = NULL;
+	struct smb2_create_blob *dhnq = NULL;
+	struct smb2_create_blob *dh2q = NULL;
 	struct smbXsrv_open *op = NULL;
 
 	ZERO_STRUCT(out_context_blobs);
@@ -459,34 +461,86 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 			in_name ));
 	}
 
+	dhnq = smb2_create_blob_find(&in_context_blobs,
+				     SMB2_CREATE_TAG_DHNQ);
 	dhnc = smb2_create_blob_find(&in_context_blobs,
 				     SMB2_CREATE_TAG_DHNC);
+	dh2q = smb2_create_blob_find(&in_context_blobs,
+				     SMB2_CREATE_TAG_DH2Q);
+	dh2c = smb2_create_blob_find(&in_context_blobs,
+				     SMB2_CREATE_TAG_DH2C);
+
+	if ((dhnc && dh2c) || (dhnc && dh2q) || (dh2c && dhnq) ||
+	    (dh2q && dh2c))
+	{
+		/* not both are allowed at the same time */
+		tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+		return tevent_req_post(req, ev);
+	}
 
 	if (dhnc) {
+		uint32_t num_blobs_allowed;
+
 		if (dhnc->data.length != 16) {
 			tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
 			return tevent_req_post(req, ev);
 		}
-		if (in_context_blobs.num_blobs != 1) {
-			/*
-			 * DHNC should be the only one.
-			 */
+
+		/*
+		 * According to MS-SMB2: 3.3.5.9.7, "Handling the
+		 * SMB2_CREATE_DURABLE_HANDLE_RECONNECT Create Context",
+		 * we should ignore an additional dhnq blob, but fail
+		 * the request (with status OBJECT_NAME_NOT_FOUND) if
+		 * any other extra create blob has been provided.
+		 *
+		 * (Note that the cases of an additional dh2q or dh2c blob
+		 *  which require a different error code, have been treated
+		 *  above.)
+		 *
+		 * TODO:
+		 * This is only true for the oplock case:
+		 * For leases, lease request is required additionally.
+		 */
+
+		if (dhnq) {
+			num_blobs_allowed = 2;
+		} else {
+			num_blobs_allowed = 1;
+		}
+
+		if (in_context_blobs.num_blobs != num_blobs_allowed) {
 			tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
 			return tevent_req_post(req, ev);
 		}
 	}
 
-	dh2c = smb2_create_blob_find(&in_context_blobs,
-				     SMB2_CREATE_TAG_DH2C);
 	if (dh2c) {
+		uint32_t num_blobs_allowed;
+
 		if (dh2c->data.length != 36) {
 			tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
 			return tevent_req_post(req, ev);
 		}
-		if (in_context_blobs.num_blobs != 1) {
-			/*
-			 * DH2C should be the only one.
-			 */
+
+		/*
+		 * According to MS-SMB2: 3.3.5.9.12, "Handling the
+		 * SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 Create Context",
+		 * we should fail the request with status
+		 * OBJECT_NAME_NOT_FOUND if any other create blob has been
+		 * provided.
+		 *
+		 * (Note that the cases of an additional dhnq, dhnc or dh2q
+		 *  blob which require a different error code, have been
+		 *  treated above.)
+		 *
+		 * TODO:
+		 * This is only true for the oplock case:
+		 * For leases, lease request is required additionally!
+		 */
+
+		num_blobs_allowed = 1;
+
+		if (in_context_blobs.num_blobs != num_blobs_allowed) {
 			tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
 			return tevent_req_post(req, ev);
 		}
@@ -541,17 +595,16 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 		NTTIME max_access_time = 0;
 		struct smb2_create_blob *secd = NULL;
 		struct security_descriptor *sec_desc = NULL;
-		struct smb2_create_blob *dhnq = NULL;
 		struct smb2_create_blob *alsi = NULL;
 		uint64_t allocation_size = 0;
 		struct smb2_create_blob *twrp = NULL;
 		struct smb2_create_blob *qfid = NULL;
-		struct GUID create_guid = GUID_zero();
+		struct GUID _create_guid = GUID_zero();
+		struct GUID *create_guid = NULL;
 		bool update_open = false;
 		bool durable_requested = false;
 		uint32_t durable_timeout_msec = 0;
 		bool do_durable_reconnect = false;
-		struct smb2_create_blob *dh2q = NULL;
 		uint64_t persistent_id = 0;
 
 		exta = smb2_create_blob_find(&in_context_blobs,
@@ -560,16 +613,12 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 					     SMB2_CREATE_TAG_MXAC);
 		secd = smb2_create_blob_find(&in_context_blobs,
 					     SMB2_CREATE_TAG_SECD);
-		dhnq = smb2_create_blob_find(&in_context_blobs,
-					     SMB2_CREATE_TAG_DHNQ);
 		alsi = smb2_create_blob_find(&in_context_blobs,
 					     SMB2_CREATE_TAG_ALSI);
 		twrp = smb2_create_blob_find(&in_context_blobs,
 					     SMB2_CREATE_TAG_TWRP);
 		qfid = smb2_create_blob_find(&in_context_blobs,
 					     SMB2_CREATE_TAG_QFID);
-		dh2q = smb2_create_blob_find(&in_context_blobs,
-					     SMB2_CREATE_TAG_DH2Q);
 
 		fname = talloc_strdup(state, in_name);
 		if (tevent_req_nomem(fname, req)) {
@@ -664,10 +713,11 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 			create_guid_blob = data_blob_const(p + 16, 16);
 
 			status = GUID_from_ndr_blob(&create_guid_blob,
-						    &create_guid);
+						    &_create_guid);
 			if (tevent_req_nterror(req, status)) {
 				return tevent_req_post(req, ev);
 			}
+			create_guid = &_create_guid;
 			/*
 			 * we need to store the create_guid later
 			 */
@@ -702,10 +752,11 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 			create_guid_blob = data_blob_const(p + 16, 16);
 
 			status = GUID_from_ndr_blob(&create_guid_blob,
-						    &create_guid);
+						    &_create_guid);
 			if (tevent_req_nterror(req, status)) {
 				return tevent_req_post(req, ev);
 			}
+			create_guid = &_create_guid;
 
 			do_durable_reconnect = true;
 		}
@@ -936,7 +987,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 		}
 
 		if (update_open) {
-			op->global->create_guid = create_guid;
+			op->global->create_guid = _create_guid;
 
 			status = smbXsrv_open_update(op);
 			DEBUG(10, ("smb2_create_send: smbXsrv_open_update "
diff --git a/source3/smbd/smbXsrv_open.c b/source3/smbd/smbXsrv_open.c
index 27dd50c..25dc6f7 100644
--- a/source3/smbd/smbXsrv_open.c
+++ b/source3/smbd/smbXsrv_open.c
@@ -1168,7 +1168,7 @@ NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
 NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn,
 			       struct auth_session_info *session_info,
 			       uint64_t persistent_id,
-			       struct GUID create_guid,
+			       const struct GUID *create_guid,
 			       NTTIME now,
 			       struct smbXsrv_open **_open)
 {
@@ -1207,7 +1207,15 @@ NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn,
 		return status;
 	}
 
-	if (!GUID_equal(&op->global->create_guid, &create_guid)) {
+	/*
+	 * If the provided create_guid is NULL, this means that
+	 * the reconnect request was a v1 request. In that case
+	 * we should skipt the create GUID verification, since
+	 * it is valid to v1-reconnect a v2-opened handle.
+	 */
+	if ((create_guid != NULL) &&
+	    !GUID_equal(&op->global->create_guid, create_guid))
+	{
 		TALLOC_FREE(op);
 		return NT_STATUS_OBJECT_NAME_NOT_FOUND;
 	}
diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h
index a246ade..95e6943 100644
--- a/source4/libcli/raw/libcliraw.h
+++ b/source4/libcli/raw/libcliraw.h
@@ -100,6 +100,8 @@ struct smbcli_options {
 	uint16_t max_mux;
 	int request_timeout;
 	enum smb_signing_setting signing;
+	uint32_t smb2_capabilities;
+	struct GUID client_guid;
 };
 
 /* this is the context for the client transport layer */
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index 5cdf258..18977d8 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -64,7 +64,7 @@ struct tevent_req *smb2_connect_send(TALLOC_CTX *mem_ctx,
 				     struct resolve_context *resolve_ctx,
 				     struct cli_credentials *credentials,
 				     uint64_t previous_session_id,
-				     struct smbcli_options *options,
+				     const struct smbcli_options *options,
 				     const char *socket_options,
 				     struct gensec_settings *gensec_settings)
 {
@@ -284,7 +284,7 @@ NTSTATUS smb2_connect_ext(TALLOC_CTX *mem_ctx,
 			  uint64_t previous_session_id,
 			  struct smb2_tree **tree,
 			  struct tevent_context *ev,
-			  struct smbcli_options *options,
+			  const struct smbcli_options *options,
 			  const char *socket_options,
 			  struct gensec_settings *gensec_settings)
 {
diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c
index 2ad16a9..b4a6c94 100644
--- a/source4/libcli/smb2/transport.c
+++ b/source4/libcli/smb2/transport.c
@@ -48,7 +48,6 @@ struct smb2_transport *smb2_transport_init(struct smbcli_socket *sock,
 					   struct smbcli_options *options)
 {
 	struct smb2_transport *transport;
-	struct GUID client_guid;
 	uint32_t smb2_capabilities = 0;
 
 	transport = talloc_zero(parent_ctx, struct smb2_transport);
@@ -60,18 +59,13 @@ struct smb2_transport *smb2_transport_init(struct smbcli_socket *sock,
 	TALLOC_FREE(sock->event.fde);
 	TALLOC_FREE(sock->event.te);
 
-	client_guid = GUID_random();
-
-	/* TODO: hand this in via the options? */
-	smb2_capabilities = SMB2_CAP_ALL;
-
 	transport->conn = smbXcli_conn_create(transport,
 					      sock->sock->fd,
 					      sock->hostname,
 					      options->signing,
 					      0, /* smb1_capabilities */
-					      &client_guid,
-					      smb2_capabilities);
+					      &options->client_guid,
+					      options->smb2_capabilities);
 	if (transport->conn == NULL) {
 		talloc_free(transport);
 		return NULL;
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 3fbf852..5f4f418 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -29,6 +29,7 @@
 #include "includes.h"
 #include "lib/param/param.h"
 #include "libcli/raw/libcliraw.h"
+#include "librpc/ndr/libndr.h"
 
 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
 			 struct smbcli_options *options)
@@ -43,6 +44,8 @@ void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
 	options->unicode = lpcfg_unicode(lp_ctx);
 	options->use_oplocks = true;
 	options->use_level2_oplocks = true;
+	options->smb2_capabilities = SMB2_CAP_ALL;
+	options->client_guid = GUID_random();
 }
 
 void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 4c84bc0..f2a44c9 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -8173,18 +8173,17 @@ static bool test_print_test_smbd(struct torture_context *tctx,
 	torture_comment(tctx, "Testing smbd job spooling\n");
 	lpcfg_smbcli_options(tctx->lp_ctx, &options);
 
-	status = smb2_connect_ext(mem_ctx,
-				  torture_setting_string(tctx, "host", NULL),
-				  lpcfg_smb_ports(tctx->lp_ctx),
-				  share,
-				  lpcfg_resolve_context(tctx->lp_ctx),
-				  credentials,
-				  0,
-				  &tree,
-				  tctx->ev,
-				  &options,
-				  lpcfg_socket_options(tctx->lp_ctx),
-				  lpcfg_gensec_settings(tctx, tctx->lp_ctx));
+	status = smb2_connect(mem_ctx,
+			      torture_setting_string(tctx, "host", NULL),
+			      lpcfg_smb_ports(tctx->lp_ctx),
+			      share,
+			      lpcfg_resolve_context(tctx->lp_ctx),
+			      credentials,
+			      &tree,
+			      tctx->ev,
+			      &options,
+			      lpcfg_socket_options(tctx->lp_ctx),
+			      lpcfg_gensec_settings(tctx, tctx->lp_ctx));
 	if (!NT_STATUS_IS_OK(status)) {
 		printf("Failed to connect to SMB2 printer %s - %s\n",
 		       share, nt_errstr(status));
diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c
index 69bc5ed..a931f6f 100644
--- a/source4/torture/smb2/durable_open.c
+++ b/source4/torture/smb2/durable_open.c
@@ -420,7 +420,7 @@ static bool test_durable_open_reopen2(struct torture_context *tctx,
 	char fname[256];
 	struct smb2_handle _h;
 	struct smb2_handle *h = NULL;
-	struct smb2_create io1, io2;
+	struct smb2_create io;
 	bool ret = true;
 
 	/* Choose a random name in case the state is left a little funky. */
@@ -429,22 +429,21 @@ static bool test_durable_open_reopen2(struct torture_context *tctx,
 
 	smb2_util_unlink(tree, fname);
 
-	smb2_oplock_create_share(&io1, fname,
+	smb2_oplock_create_share(&io, fname,
 				 smb2_util_share_access(""),
 				 smb2_util_oplock_level("b"));
-	io1.in.durable_open = true;
+	io.in.durable_open = true;
 
-	status = smb2_create(tree, mem_ctx, &io1);
+	status = smb2_create(tree, mem_ctx, &io);
 	CHECK_STATUS(status, NT_STATUS_OK);
-	_h = io1.out.file.handle;
+	_h = io.out.file.handle;
 	h = &_h;
-	CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_VAL(io1.out.durable_open, true);
-	CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b"));
+	CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+	CHECK_VAL(io.out.durable_open, true);
+	CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b"));
 
-	/* disconnect, reconnect and then do durable reopen */
-	talloc_free(tree);
-	tree = NULL;
+	/* disconnect, leaving the durable in place */
+	TALLOC_FREE(tree);
 
 	if (!torture_smb2_connection(tctx, &tree)) {
 		torture_warning(tctx, "couldn't reconnect, bailing\n");
@@ -452,17 +451,557 @@ static bool test_durable_open_reopen2(struct torture_context *tctx,
 		goto done;
 	}
 
-	ZERO_STRUCT(io2);
+	ZERO_STRUCT(io);
 	/* the path name is ignored by the server */
-	io2.in.fname = "__non_existing_fname__";
-	io2.in.durable_handle = h;
+	io.in.fname = fname;
+	io.in.durable_handle = h; /* durable v1 reconnect request */
 	h = NULL;
 
-	status = smb2_create(tree, mem_ctx, &io2);
+	status = smb2_create(tree, mem_ctx, &io);
 	CHECK_STATUS(status, NT_STATUS_OK);
-	CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_VAL(io2.out.oplock_level, smb2_util_oplock_level("b"));
-	_h = io2.out.file.handle;
+	CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
+	CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b"));
+	_h = io.out.file.handle;
+	h = &_h;
+
+	/* disconnect again, leaving the durable in place */
+	TALLOC_FREE(tree);
+
+	if (!torture_smb2_connection(tctx, &tree)) {
+		torture_warning(tctx, "couldn't reconnect, bailing\n");
+		ret = false;
+		goto done;
+	}
+
+	/*
+	 * show that the filename and many other fields
+	 * are ignored. only the reconnect request blob
+	 * is important.
+	 */
+	ZERO_STRUCT(io);
+	/* the path name is ignored by the server */
+	io.in.security_flags = 0x78;
+	io.in.oplock_level = 0x78;
+	io.in.impersonation_level = 0x12345678;
+	io.in.create_flags = 0x12345678;
+	io.in.reserved = 0x12345678;
+	io.in.desired_access = 0x12345678;
+	io.in.file_attributes = 0x12345678;
+	io.in.share_access = 0x12345678;
+	io.in.create_disposition = 0x12345678;
+	io.in.create_options = 0x12345678;
+	io.in.fname = "__non_existing_fname__";
+	io.in.durable_handle = h; /* durable v1 reconnect request */
+	h = NULL;
+
+	status = smb2_create(tree, mem_ctx, &io);
+	CHECK_STATUS(status, NT_STATUS_OK);
+	CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
+	CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b"));
+	_h = io.out.file.handle;
+	h = &_h;
+
+	/* disconnect, leaving the durable in place */
+	TALLOC_FREE(tree);
+
+	if (!torture_smb2_connection(tctx, &tree)) {
+		torture_warning(tctx, "couldn't reconnect, bailing\n");
+		ret = false;
+		goto done;
+	}
+
+	/*
+	 * show that an additionally specified durable v1 request
+	 * is ignored by the server.
+	 * See MS-SMB2, 3.3.5.9.7
+	 * Handling the SMB2_CREATE_DURABLE_HANDLE_RECONNECT Create Context
+	 */
+	ZERO_STRUCT(io);
+	/* the path name is ignored by the server */
+	io.in.fname = fname;
+	io.in.durable_handle = h;  /* durable v1 reconnect request */
+	io.in.durable_open = true; /* durable v1 handle request */
+	h = NULL;
+
+	status = smb2_create(tree, mem_ctx, &io);
+	CHECK_STATUS(status, NT_STATUS_OK);
+	CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
+	CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b"));
+	_h = io.out.file.handle;
+	h = &_h;
+
+done:
+	if (tree != NULL) {
+		if (h != NULL) {
+			smb2_util_close(tree, *h);
+		}
+
+		smb2_util_unlink(tree, fname);
+
+		talloc_free(tree);
+	}
+
+	talloc_free(mem_ctx);
+
+	return ret;
+}
+
+/**


-- 
Samba Shared Repository


More information about the samba-cvs mailing list