[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Thu Nov 27 11:09:03 MST 2014


The branch, master has been updated
       via  c6a5eab s4: torture: leases - Add test for leases and blocking locks.
       via  62c6c79 s4: smb2 : torture: Add new dynamic_share leases test.
       via  f76c7c7 s3: leases - torture test for timeout of responding to lease break request.
       via  ea25f0d s4:torture/smb2: smb2.lease.breaking6 test
       via  6494597 s4:torture/smb2: smb2.lease.breaking5 test
       via  b3a985a s4:torture/smb2: smb2.lease.breaking4 test
       via  8d16a2e s4:torture/smb2: smb2.lease.breaking3 test
       via  5a652db s4:torture/smb2: smb2.lease.breaking2 test
       via  a7a59b1 s4:torture/smb2: smb2.lease.breaking1 test
       via  0c239d3 s4:torture/smb2: make it possible to skip the automatic ack of lease breaks.
       via  c18c84c s4:torture/smb2: add smb2.lease.v2_epoch[2|3] tests
       via  45c98b8 s4:torture/smb2: add smb2.lease.[v2_]complex1 tests
       via  90c886e s4:torture/smb2: pass the expected flags to CHECK_LEASE()
       via  a9d4626 s4:torture/smb2: don't check the lease break connection against samba3
       via  c0f2b46 s4:torture/smb2: always verify the v2 lease epoch.
       via  8fa2fb7 s4:torture/smb2: verify lease_flags in CHECK_LEASE_BREAK()
       via  2742257 s4:torture/smb2: lease per test fnames
       via  34926bd s4:torture/smb2: make lease tests more reliable by calling torture_wait_for_lease_break()
       via  683b956 s4:torture/smb2: skip lease tests if the server doesn't support them
       via  38b0fde s4:libcli/smb2: initialize ls->lease_version
       via  3327615 s4:libcli/smb2: add new_epoch to struct smb2_lease_break
       via  d7669ea s4:param: don't expand PROTOCOL_DEFAULT in lpcfg_smbcli_options()
       via  d0a1995 s4:libcli/smb2: allow the caller to specify a specific value for max_protocol.
       via  bc83e45 s4:libcli/raw: fix up the max_protocol value for the current transport connection
       via  55750f0 s4:libcli/smb_composite: use the options on the transport
       via  fe0ad5c s3:smb2_create: send interim responses after 0.5 milliseconds
       via  334089c Revert "libcli/smb: mask off SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET for version 1"
      from  82c0ecb gse_krb5: Avoid a segfault when we can not read the dedicated keytab file

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


- Log -----------------------------------------------------------------
commit c6a5eab3690d2926d66024a35e3c3e818d7e4935
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Nov 21 21:28:14 2014 -0800

    s4: torture: leases - Add test for leases and blocking locks.
    
    Signed-off-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): Thu Nov 27 19:08:24 CET 2014 on sn-devel-104

commit 62c6c79011d7e62423fa97d4cabd9de149af8311
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Nov 17 14:17:34 2014 -0800

    s4: smb2 : torture: Add new dynamic_share leases test.
    
    Depends on new share "dynamic_share" being set up containing an %R
    in the path= statement.
    
    Shows we will break leases and fail to grant new ones
    if we get a lease_key+client guid pair match on files
    with different fileid's, as can happen on dynamic shares.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit f76c7c7404c1a67389b701bd1ab24d3b2938c212
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Nov 14 10:24:40 2014 -0800

    s3: leases - torture test for timeout of responding to lease break request.
    
    Passes against W2K12.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit ea25f0d32a045e30d69aab4d84b15cf13a6e32ea
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 26 14:00:24 2014 +0100

    s4:torture/smb2: smb2.lease.breaking6 test
    
    The client is allowed to downgrade a lease to a lower value
    than required.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6494597c0451944e2599736af116d6838e6aac4e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 26 10:25:45 2014 +0100

    s4:torture/smb2: smb2.lease.breaking5 test
    
    This is like breaking4, but with an initial "R" lease instead
    of "RH".
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b3a985ab6662cacb2ac399c667b48e03c0bd1bfe
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Nov 15 11:58:01 2014 +0100

    s4:torture/smb2: smb2.lease.breaking4 test
    
    This demonstrates that a confliciting open with NTCREATEX_DISP_OVERWRITE
    isn't delayed by a "RH" lease, even if a lease is in 'breaking' mode.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8d16a2e36762f6da825106798689c96aff95437f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 15:43:56 2014 +0100

    s4:torture/smb2: smb2.lease.breaking3 test
    
    This demonstrates a race case where the client reuses a lease,
    while the server already sent a break.
    
    The open succeeds with SMB2_LEASE_FLAG_BREAK_IN_PROGRESS being set.
    
    This is more complex that smb2.lease.breaking[1-2] as it generates breaks
    from RWH => RH => R => NONE.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5a652dbb92231183070b2d139d3459be8fd89439
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Nov 15 11:58:01 2014 +0100

    s4:torture/smb2: smb2.lease.breaking2 test
    
    This demonstrates that a conflicting open with NTCREATEX_DISP_OVERWRITE
    breaks a lease to NONE.
    
    It also shows which error codes are generated for unexpected lease break acks.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a7a59b16a4920181fd0e2484c24b448ff8642e88
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 15:43:56 2014 +0100

    s4:torture/smb2: smb2.lease.breaking1 test
    
    This demonstrates a race case where the client reuses a lease,
    while the server already sent a break.
    
    The open succeeds with SMB2_LEASE_FLAG_BREAK_IN_PROGRESS being set.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0c239d32094f8cc20bd36b55a4d08f57d04bd263
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 15:43:56 2014 +0100

    s4:torture/smb2: make it possible to skip the automatic ack of lease breaks.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c18c84ca6ca04815e8ffedb3d6f8abadad06500b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 09:53:45 2014 +0100

    s4:torture/smb2: add smb2.lease.v2_epoch[2|3] tests
    
    They demonstrate that the lease version (v1 or v2) is selected
    by the first open. All following opens using the other version
    still get the lease version of the first open.
    
    This implies that the server has to remember the lease version
    more globaly.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 45c98b8069f6b94115616d7fddef515c76d7767e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Nov 11 19:35:59 2014 +0100

    s4:torture/smb2: add smb2.lease.[v2_]complex1 tests
    
    These tests verify the lease state is consistent between two connections
    with the same client_guid.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 90c886e9656a1360ffdb8eaa80ad2b6c987f73ef
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 15:41:50 2014 +0100

    s4:torture/smb2: pass the expected flags to CHECK_LEASE()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a9d46264ab3eb53cf4a70edf4e5dad2fe6d86e6c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 09:15:58 2014 +0100

    s4:torture/smb2: don't check the lease break connection against samba3
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c0f2b46d69dc7e729bac766785b26a1911a80825
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Nov 11 19:35:07 2014 +0100

    s4:torture/smb2: always verify the v2 lease epoch.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8fa2fb7dde10640ded645d8180d441012dbad155
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 17:00:44 2014 +0100

    s4:torture/smb2: verify lease_flags in CHECK_LEASE_BREAK()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2742257be693d57c075523e2691137692aa9e34a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 07:24:16 2014 +0100

    s4:torture/smb2: lease per test fnames
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 34926bd4bd13ea6518273e94473fbb47b7cf565e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 07:23:31 2014 +0100

    s4:torture/smb2: make lease tests more reliable by calling torture_wait_for_lease_break()
    
    They now work against w2k8r2, w2012, w2012r2.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 683b9569487bd30ecd0ba677367dbe9e0eff16c2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 07:19:49 2014 +0100

    s4:torture/smb2: skip lease tests if the server doesn't support them
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 38b0fded58f9e066ad7190f7797cdfb92d3d23ff
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 12 11:13:15 2014 +0100

    s4:libcli/smb2: initialize ls->lease_version
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3327615c23fbfd26b572b01acfe7e1402f018a16
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Nov 11 19:33:13 2014 +0100

    s4:libcli/smb2: add new_epoch to struct smb2_lease_break
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d7669ea451fa445b6ec77fa08d951fa59b08ab5f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 20 14:38:09 2014 +0100

    s4:param: don't expand PROTOCOL_DEFAULT in lpcfg_smbcli_options()
    
    We let the low-level smb1 or smb2 code assign what PROTOCOL_DEFAULT means.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d0a1995b934895ae9f0bbeed52772a4ef5d4b0dd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 20 14:35:38 2014 +0100

    s4:libcli/smb2: allow the caller to specify a specific value for max_protocol.
    
    The default is still PROTOCOL_LATEST. As smb2_connect*() is about SMB2/3 only
    we upgrade to PROTOCOL_LATEST if PROTOCOL_NT1 or lower is given.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bc83e45a19deccfb0106c9ad79b0624b1c5d1fa7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 20 14:32:40 2014 +0100

    s4:libcli/raw: fix up the max_protocol value for the current transport connection
    
    This allows the caller to pass PROTOCOL_DEFAULT,
    which results in PROTOCOL_NT1.
    
    As smbcli_transport_init() is about SMB1 only we downgrade
    to PROTOCOL_NT1 if a higher value (for SMB2 or SMB3) was given.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 55750f010423b0548e9d6b8f5745d7ad5fc4b773
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 20 14:30:31 2014 +0100

    s4:libcli/smb_composite: use the options on the transport
    
    These are the options which really belong to the connection
    and might not be the the same as the hints given from the caller.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fe0ad5c66884da5e7cba5c7b0d40a8c41cf6a63b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 13 12:10:46 2014 +0100

    s3:smb2_create: send interim responses after 0.5 milliseconds
    
    We don't have to care about delayed NT_STATUS_SHARING_VIOLATION anymore
    after the following commit:
    
        commit 4111fcfd4f570d39d46a0d414546ca62c7b609be
        Author: Jeremy Allison <jra at samba.org>
        Date:   Thu May 2 11:12:47 2013 -0700
    
            Only do the 1 second delay for sharing violations for SMB1, not SMB2.
    
            Match Windows behavior.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 334089c1015ca35ee37d4c9bf5da455e72c3e86e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 26 11:06:16 2014 +0100

    Revert "libcli/smb: mask off SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET for version 1"
    
    This reverts commit a6affb7bb3ff595165e708c56ede2181f0bb570f.
    
    This is not really needed. The caller should ignore this flag.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 libcli/smb/smb2_lease.c                |    1 -
 selftest/target/Samba3.pm              |   10 +
 source3/smbd/smb2_create.c             |    8 +-
 source4/libcli/raw/clitransport.c      |    8 +
 source4/libcli/raw/interfaces.h        |    1 +
 source4/libcli/smb2/connect.c          |    3 +-
 source4/libcli/smb2/create.c           |    2 +
 source4/libcli/smb2/transport.c        |    9 +
 source4/libcli/smb_composite/connect.c |    2 +-
 source4/param/loadparm.c               |    2 +-
 source4/torture/smb2/lease.c           | 2167 ++++++++++++++++++++++++++++++--
 11 files changed, 2068 insertions(+), 145 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c
index 7705256..fc641ff 100644
--- a/libcli/smb/smb2_lease.c
+++ b/libcli/smb/smb2_lease.c
@@ -48,7 +48,6 @@ ssize_t smb2_lease_pull(const uint8_t *buf, size_t len,
 	switch (version) {
 	case 1:
 		ZERO_STRUCT(lease->parent_lease_key);
-		lease->lease_flags &= ~SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET;
 		lease->lease_epoch = 0;
 		break;
 	case 2:
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 48b8164..797179f 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -879,6 +879,12 @@ sub provision($$$$$$)
 	my $badnames_shrdir="$shrdir/badnames";
 	push(@dirs,$badnames_shrdir);
 
+	my $lease1_shrdir="$shrdir/SMB2_10";
+	push(@dirs,$lease1_shrdir);
+
+	my $lease2_shrdir="$shrdir/SMB3_00";
+	push(@dirs,$lease2_shrdir);
+
 	# this gets autocreated by winbindd
 	my $wbsockdir="$prefix_abs/winbindd";
 	my $wbsockprivdir="$lockdir/winbindd_privileged";
@@ -1223,6 +1229,10 @@ sub provision($$$$$$)
 [badname-tmp]
 	path = $badnames_shrdir
 	guest ok = yes
+
+[dynamic_share]
+	path = $shrdir/%R
+	guest ok = yes
 	";
 	close(CONF);
 
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index 31dc3ac..1e31cbf 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -241,13 +241,7 @@ NTSTATUS smbd_smb2_request_process_create(struct smbd_smb2_request *smb2req)
 	}
 	tevent_req_set_callback(tsubreq, smbd_smb2_request_create_done, smb2req);
 
-	/*
-	 * For now we keep the logic that we do not send STATUS_PENDING
-	 * for sharing violations, so we just wait 2 seconds.
-	 *
-	 * TODO: we need more tests for this.
-	 */
-	return smbd_smb2_request_pending_queue(smb2req, tsubreq, 2000000);
+	return smbd_smb2_request_pending_queue(smb2req, tsubreq, 500);
 }
 
 static uint64_t get_mid_from_smb2req(struct smbd_smb2_request *smb2req)
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index f9d96b5..d0dd1f9 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -58,6 +58,14 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
 	transport->ev = sock->event.ctx;
 	transport->options = *options;
 
+	if (transport->options.max_protocol == PROTOCOL_DEFAULT) {
+		transport->options.max_protocol = PROTOCOL_NT1;
+	}
+
+	if (transport->options.max_protocol > PROTOCOL_NT1) {
+		transport->options.max_protocol = PROTOCOL_NT1;
+	}
+
 	TALLOC_FREE(sock->event.fde);
 	TALLOC_FREE(sock->event.te);
 
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 03e9bbb..dd0c3bd 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -57,6 +57,7 @@ struct smb2_handle {
 
 struct smb2_lease_break {
 	struct smb2_lease current_lease;
+	uint16_t new_epoch; /* only for v2 leases */
 	uint32_t break_flags;
 	uint32_t new_lease_state;
 	uint32_t break_reason; /* should be 0 */
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index c81bd67..9535380 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -149,7 +149,8 @@ static void smb2_connect_socket_done(struct composite_context *creq)
 
 	subreq = smbXcli_negprot_send(state, state->ev,
 				      state->transport->conn, timeout_msec,
-				      PROTOCOL_SMB2_02, PROTOCOL_LATEST);
+				      PROTOCOL_SMB2_02,
+				      state->transport->options.max_protocol);
 	if (tevent_req_nomem(subreq, req)) {
 		return;
 	}
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index 10fe4f7..550069a 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -385,9 +385,11 @@ NTSTATUS smb2_create_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, struct
 			switch (io->out.blobs.blobs[i].data.length) {
 			case 32:
 				ls = &io->out.lease_response;
+				ls->lease_version = 1;
 				break;
 			case 52:
 				ls = &io->out.lease_response_v2;
+				ls->lease_version = 2;
 				break;
 			default:
 				smb2_request_destroy(req);
diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c
index 9b0c146..166f34b 100644
--- a/source4/libcli/smb2/transport.c
+++ b/source4/libcli/smb2/transport.c
@@ -55,6 +55,14 @@ struct smb2_transport *smb2_transport_init(struct smbcli_socket *sock,
 	transport->ev = sock->event.ctx;
 	transport->options = *options;
 
+	if (transport->options.max_protocol == PROTOCOL_DEFAULT) {
+		transport->options.max_protocol = PROTOCOL_LATEST;
+	}
+
+	if (transport->options.max_protocol < PROTOCOL_SMB2_02) {
+		transport->options.max_protocol = PROTOCOL_LATEST;
+	}
+
 	TALLOC_FREE(sock->event.fde);
 	TALLOC_FREE(sock->event.te);
 
@@ -390,6 +398,7 @@ static void smb2_transport_break_handler(struct tevent_req *subreq)
 		struct smb2_lease_break lb;
 
 		ZERO_STRUCT(lb);
+		lb.new_epoch =			SVAL(body, 0x2);
 		lb.break_flags =		SVAL(body, 0x4);
 		memcpy(&lb.current_lease.lease_key, body+0x8,
 		    sizeof(struct smb2_lease_key));
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index 14b53e5..d87d5ec 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -297,7 +297,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c,
 	state->subreq = smb_raw_negotiate_send(state,
 					       state->transport->ev,
 					       state->transport,
-					       io->in.options.max_protocol);
+					       state->transport->options.max_protocol);
 	NT_STATUS_HAVE_NO_MEMORY(state->subreq);
 	tevent_req_set_callback(state->subreq, subreq_handler, c);
 	state->stage = CONNECT_NEGPROT;
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 529c828..af3313f 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -40,7 +40,7 @@ void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
 	options->signing = lpcfg_client_signing(lp_ctx);
 	options->request_timeout = SMB_REQUEST_TIMEOUT;
 	options->ntstatus_support = lpcfg_nt_status_support(lp_ctx);
-	options->max_protocol = lpcfg_client_max_protocol(lp_ctx);
+	options->max_protocol = lpcfg__client_max_protocol(lp_ctx);
 	options->unicode = lpcfg_unicode(lp_ctx);
 	options->use_oplocks = true;
 	options->use_level2_oplocks = true;
diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c
index 4326958..c7b3592 100644
--- a/source4/torture/smb2/lease.c
+++ b/source4/torture/smb2/lease.c
@@ -25,7 +25,9 @@
 #include "libcli/smb2/smb2_calls.h"
 #include "torture/torture.h"
 #include "torture/smb2/proto.h"
+#include "torture/util.h"
 #include "libcli/smb/smbXcli_base.h"
+#include "lib/param/param.h"
 
 #define CHECK_VAL(v, correct) do { \
 	if ((v) != (correct)) { \
@@ -51,8 +53,9 @@
 		CHECK_VAL((__io)->out.reserved2, 0);			\
 	} while(0)
 
-#define CHECK_LEASE(__io, __state, __oplevel, __key)			\
+#define CHECK_LEASE(__io, __state, __oplevel, __key, __flags)		\
 	do {								\
+		CHECK_VAL((__io)->out.lease_response.lease_version, 1); \
 		if (__oplevel) {					\
 			CHECK_VAL((__io)->out.oplock_level, SMB2_OPLOCK_LEVEL_LEASE); \
 			CHECK_VAL((__io)->out.lease_response.lease_key.data[0], (__key)); \
@@ -65,12 +68,14 @@
 			CHECK_VAL((__io)->out.lease_response.lease_state, 0); \
 		}							\
 									\
-		CHECK_VAL((__io)->out.lease_response.lease_flags, 0);	\
+		CHECK_VAL((__io)->out.lease_response.lease_flags, (__flags));	\
 		CHECK_VAL((__io)->out.lease_response.lease_duration, 0); \
+		CHECK_VAL((__io)->out.lease_response.lease_epoch, 0); \
 	} while(0)
 
-#define CHECK_LEASE_V2(__io, __state, __oplevel, __key, __flags, __parent) \
+#define CHECK_LEASE_V2(__io, __state, __oplevel, __key, __flags, __parent, __epoch) \
 	do {								\
+		CHECK_VAL((__io)->out.lease_response_v2.lease_version, 2); \
 		if (__oplevel) {					\
 			CHECK_VAL((__io)->out.oplock_level, SMB2_OPLOCK_LEVEL_LEASE); \
 			CHECK_VAL((__io)->out.lease_response_v2.lease_key.data[0], (__key)); \
@@ -89,6 +94,7 @@
 			CHECK_VAL((__io)->out.lease_response_v2.parent_lease_key.data[1], ~(__parent)); \
 		} \
 		CHECK_VAL((__io)->out.lease_response_v2.lease_duration, 0); \
+		CHECK_VAL((__io)->out.lease_response_v2.lease_epoch, (__epoch)); \
 	} while(0)
 
 static const uint64_t LEASE1 = 0xBADC0FFEE0DDF00Dull;
@@ -116,10 +122,10 @@ static bool test_lease_request(struct torture_context *tctx,
 	struct smb2_lease ls;
 	struct smb2_handle h1, h2;
 	NTSTATUS status;
-	const char *fname = "lease.dat";
-	const char *fname2 = "lease2.dat";
-	const char *sname = "lease.dat:stream";
-	const char *dname = "lease.dir";
+	const char *fname = "lease_request.dat";
+	const char *fname2 = "lease_request.2.dat";
+	const char *sname = "lease_request.dat:stream";
+	const char *dname = "lease_request.dir";
 	bool ret = true;
 	int i;
 	uint32_t caps;
@@ -139,15 +145,17 @@ static bool test_lease_request(struct torture_context *tctx,
 	CHECK_STATUS(status, NT_STATUS_OK);
 	h1 = io.out.file.handle;
 	CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_LEASE(&io, "RHW", true, LEASE1);
+	CHECK_LEASE(&io, "RHW", true, LEASE1, 0);
 
 	/* But will reject leases on directories. */
-	smb2_lease_create(&io, &ls, true, dname, LEASE2, smb2_util_lease_state("RHW"));
-	status = smb2_create(tree, mem_ctx, &io);
-	CHECK_STATUS(status, NT_STATUS_OK);
-	CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_DIRECTORY);
-	CHECK_LEASE(&io, "", false, 0);
-	smb2_util_close(tree, io.out.file.handle);
+	if (!(caps & SMB2_CAP_DIRECTORY_LEASING)) {
+		smb2_lease_create(&io, &ls, true, dname, LEASE2, smb2_util_lease_state("RHW"));
+		status = smb2_create(tree, mem_ctx, &io);
+		CHECK_STATUS(status, NT_STATUS_OK);
+		CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_DIRECTORY);
+		CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_NONE);
+		smb2_util_close(tree, io.out.file.handle);
+	}
 
 	/* Also rejects multiple files leased under the same key. */
 	smb2_lease_create(&io, &ls, true, fname2, LEASE1, smb2_util_lease_state("RHW"));
@@ -160,7 +168,7 @@ static bool test_lease_request(struct torture_context *tctx,
 	h2 = io.out.file.handle;
 	CHECK_STATUS(status, NT_STATUS_OK);
 	CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_LEASE(&io, "RHW", true, LEASE2);
+	CHECK_LEASE(&io, "RHW", true, LEASE2, 0);
 	smb2_util_close(tree, h2);
 
 	smb2_util_close(tree, h1);
@@ -177,7 +185,7 @@ static bool test_lease_request(struct torture_context *tctx,
 		h2 = io.out.file.handle;
 		CHECK_STATUS(status, NT_STATUS_OK);
 		CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
-		CHECK_LEASE(&io, request_results[i][1], true, LEASE1);
+		CHECK_LEASE(&io, request_results[i][1], true, LEASE1, 0);
 		smb2_util_close(tree, io.out.file.handle);
 	}
 
@@ -202,7 +210,7 @@ static bool test_lease_upgrade(struct torture_context *tctx,
 	struct smb2_lease ls;
 	struct smb2_handle h, hnew;
 	NTSTATUS status;
-	const char *fname = "lease.dat";
+	const char *fname = "lease_upgrade.dat";
 	bool ret = true;
 	uint32_t caps;
 
@@ -218,7 +226,7 @@ static bool test_lease_upgrade(struct torture_context *tctx,
 	status = smb2_create(tree, mem_ctx, &io);
 	CHECK_STATUS(status, NT_STATUS_OK);
 	CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_LEASE(&io, "RH", true, LEASE1);
+	CHECK_LEASE(&io, "RH", true, LEASE1, 0);
 	h = io.out.file.handle;
 
 	/* Upgrades (sidegrades?) to RW leave us with an RH. */
@@ -226,7 +234,7 @@ static bool test_lease_upgrade(struct torture_context *tctx,
 	status = smb2_create(tree, mem_ctx, &io);
 	CHECK_STATUS(status, NT_STATUS_OK);
 	CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_LEASE(&io, "RH", true, LEASE1);
+	CHECK_LEASE(&io, "RH", true, LEASE1, 0);
 	hnew = io.out.file.handle;
 
 	smb2_util_close(tree, hnew);
@@ -236,7 +244,7 @@ static bool test_lease_upgrade(struct torture_context *tctx,
 	status = smb2_create(tree, mem_ctx, &io);
 	CHECK_STATUS(status, NT_STATUS_OK);
 	CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_LEASE(&io, "RHW", true, LEASE1);
+	CHECK_LEASE(&io, "RHW", true, LEASE1, 0);
 	hnew = io.out.file.handle;
 
 	smb2_util_close(tree, h);
@@ -247,7 +255,7 @@ static bool test_lease_upgrade(struct torture_context *tctx,
 	status = smb2_create(tree, mem_ctx, &io);
 	CHECK_STATUS(status, NT_STATUS_OK);
 	CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_LEASE(&io, "RHW", true, LEASE1);
+	CHECK_LEASE(&io, "RHW", true, LEASE1, 0);
 	hnew = io.out.file.handle;
 
 	smb2_util_close(tree, hnew);
@@ -326,7 +334,7 @@ static bool test_lease_upgrade2(struct torture_context *tctx,
 	NTSTATUS status;
 	struct smb2_create io;
 	struct smb2_lease ls;
-	const char *fname = "lease.dat";
+	const char *fname = "lease_upgrade2.dat";
 	bool ret = true;
 	int i;
 	uint32_t caps;
@@ -346,7 +354,7 @@ static bool test_lease_upgrade2(struct torture_context *tctx,
 		status = smb2_create(tree, mem_ctx, &io);
 		CHECK_STATUS(status, NT_STATUS_OK);
 		CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-		CHECK_LEASE(&io, t.initial, true, LEASE1);
+		CHECK_LEASE(&io, t.initial, true, LEASE1, 0);
 		h = io.out.file.handle;
 
 		/* Upgrade. */
@@ -354,7 +362,7 @@ static bool test_lease_upgrade2(struct torture_context *tctx,
 		status = smb2_create(tree, mem_ctx, &io);
 		CHECK_STATUS(status, NT_STATUS_OK);
 		CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
-		CHECK_LEASE(&io, t.expected, true, LEASE1);
+		CHECK_LEASE(&io, t.expected, true, LEASE1, 0);
 		hnew = io.out.file.handle;
 
 		smb2_util_close(tree, hnew);
@@ -375,10 +383,18 @@ static bool test_lease_upgrade2(struct torture_context *tctx,
 
 #define CHECK_LEASE_BREAK(__lb, __oldstate, __state, __key)		\
 	do {								\
-		CHECK_VAL((__lb)->new_lease_state, smb2_util_lease_state(__state));	\
-		CHECK_VAL((__lb)->current_lease.lease_state, smb2_util_lease_state(__oldstate)); \
+		uint16_t __new = smb2_util_lease_state(__state); \
+		uint16_t __old = smb2_util_lease_state(__oldstate); \
+		CHECK_VAL((__lb)->new_lease_state, __new);	\
+		CHECK_VAL((__lb)->current_lease.lease_state, __old); \
 		CHECK_VAL((__lb)->current_lease.lease_key.data[0], (__key)); \
 		CHECK_VAL((__lb)->current_lease.lease_key.data[1], ~(__key)); \
+		if (__old & (SMB2_LEASE_WRITE | SMB2_LEASE_HANDLE)) { \
+			CHECK_VAL((__lb)->break_flags, \
+				  SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED);	\
+		} else { \
+			CHECK_VAL((__lb)->break_flags, 0); \
+		} \
 	} while(0)
 
 #define CHECK_LEASE_BREAK_ACK(__lba, __state, __key)			\
@@ -391,8 +407,10 @@ static bool test_lease_upgrade2(struct torture_context *tctx,
 		CHECK_VAL((__lba)->out.lease.lease_duration, 0);	\
 	} while(0)
 
-static struct {
+static struct torture_lease_break {
 	struct smb2_lease_break lease_break;
+	struct smb2_transport *lease_transport;
+	bool lease_skip_ack;
 	struct smb2_lease_break_ack lease_break_ack;
 	int count;
 	int failures;
@@ -404,19 +422,58 @@ static struct {
 	int oplock_failures;
 } break_info;
 
-#define CHECK_BREAK_INFO(__oldstate, __state, __key)			\
+#define CHECK_NO_BREAK(tctx)	\
+	do {								\
+		torture_wait_for_lease_break(tctx);			\
+		CHECK_VAL(break_info.failures, 0);			\
+		CHECK_VAL(break_info.count, 0);				\
+		CHECK_VAL(break_info.oplock_failures, 0);		\
+		CHECK_VAL(break_info.oplock_count, 0);			\
+	} while(0)
+
+#define CHECK_OPLOCK_BREAK(__brokento)	\
+	do {								\
+		torture_wait_for_lease_break(tctx);			\
+		CHECK_VAL(break_info.oplock_count, 1);			\
+		CHECK_VAL(break_info.oplock_failures, 0);		\
+		CHECK_VAL(break_info.oplock_level,			\
+			  smb2_util_oplock_level(__brokento)); \
+		break_info.held_oplock_level = break_info.oplock_level; \
+	} while(0)
+
+#define _CHECK_BREAK_INFO(__oldstate, __state, __key)			\
 	do {								\
+		torture_wait_for_lease_break(tctx);			\
 		CHECK_VAL(break_info.failures, 0);			\
 		CHECK_VAL(break_info.count, 1);				\
 		CHECK_LEASE_BREAK(&break_info.lease_break, (__oldstate), \
 		    (__state), (__key));				\
-		if (break_info.lease_break.break_flags &		\
-		    SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED) {	\
+		if (!break_info.lease_skip_ack && \
+		    (break_info.lease_break.break_flags &		\
+		     SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED))	\
+		{	\
+			torture_wait_for_lease_break(tctx);		\
 			CHECK_LEASE_BREAK_ACK(&break_info.lease_break_ack, \
 				              (__state), (__key));	\
 		}							\
 	} while(0)
 
+#define CHECK_BREAK_INFO(__oldstate, __state, __key)			\
+	do {								\
+		_CHECK_BREAK_INFO(__oldstate, __state, __key);		\
+		CHECK_VAL(break_info.lease_break.new_epoch, 0);		\
+	} while(0)
+
+#define CHECK_BREAK_INFO_V2(__transport, __oldstate, __state, __key, __epoch) \
+	do {								\
+		_CHECK_BREAK_INFO(__oldstate, __state, __key);		\
+		CHECK_VAL(break_info.lease_break.new_epoch, __epoch);	\
+		if (!TARGET_IS_SAMBA3(tctx)) {				\
+			CHECK_VAL((uintptr_t)break_info.lease_transport, \
+				  (uintptr_t)__transport);		\
+		} \
+	} while(0)
+
 static void torture_lease_break_callback(struct smb2_request *req)
 {
 	NTSTATUS status;
@@ -437,9 +494,14 @@ static bool torture_lease_handler(struct smb2_transport *transport,
 	struct smb2_lease_break_ack io;
 	struct smb2_request *req;
 
+	break_info.lease_transport = transport;
 	break_info.lease_break = *lb;
 	break_info.count++;
 
+	if (break_info.lease_skip_ack) {
+		return true;
+	}
+
 	if (lb->break_flags & SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED) {
 		ZERO_STRUCT(io);
 		io.in.lease.lease_key = lb->current_lease.lease_key;
@@ -522,7 +584,7 @@ static bool test_lease_upgrade3(struct torture_context *tctx,
 	NTSTATUS status;
 	struct smb2_create io;
 	struct smb2_lease ls;
-	const char *fname = "upgrade3.dat";
+	const char *fname = "lease_upgrade3.dat";
 	bool ret = true;
 	int i;
 	uint32_t caps;
@@ -549,7 +611,7 @@ static bool test_lease_upgrade3(struct torture_context *tctx,
 		status = smb2_create(tree, mem_ctx, &io);
 		CHECK_STATUS(status, NT_STATUS_OK);
 		CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-		CHECK_LEASE(&io, t.held1, true, LEASE1);
+		CHECK_LEASE(&io, t.held1, true, LEASE1, 0);
 		h = io.out.file.handle;
 
 		/* grab second lease */
@@ -557,7 +619,7 @@ static bool test_lease_upgrade3(struct torture_context *tctx,
 		status = smb2_create(tree, mem_ctx, &io);
 		CHECK_STATUS(status, NT_STATUS_OK);
 		CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
-		CHECK_LEASE(&io, t.held2, true, LEASE2);
+		CHECK_LEASE(&io, t.held2, true, LEASE2, 0);
 		h2 = io.out.file.handle;
 
 		/* no break has happened */
@@ -569,7 +631,7 @@ static bool test_lease_upgrade3(struct torture_context *tctx,
 		status = smb2_create(tree, mem_ctx, &io);
 		CHECK_STATUS(status, NT_STATUS_OK);
 		CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
-		CHECK_LEASE(&io, t.upgraded_to, true, LEASE1);
+		CHECK_LEASE(&io, t.upgraded_to, true, LEASE1, 0);
 		hnew = io.out.file.handle;
 
 		/* no break has happened */
@@ -688,7 +750,7 @@ static bool test_lease_break(struct torture_context *tctx,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list