[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Fri Nov 7 14:42:04 MST 2014
The branch, master has been updated
via dbb191f libcli/smb: Add smb2_lease_equal() which compares client_guids and keys.
via 2fc8f76 libcli/smb: add smb2_lease_key_equal() helper function
via a6affb7 libcli/smb: mask off SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET for version 1
via 171cefe libcli/smb: remember the lease_version in struct smb2_lease
via 8db5150 s4:torture: Add smb2.oplock test batch9a and raw.oplock test batch9a
via 5cb4a28 s3:smbstatus: fix return value in print_share_mode()
from fbe40d2 s3:smbd: fix file corruption using "write cache size != 0"
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit dbb191f35bb093ad7fc8839b3d47e508be8f6069
Author: Jeremy Allison <jra at samba.org>
Date: Tue Nov 4 21:44:45 2014 -0800
libcli/smb: Add smb2_lease_equal() which compares client_guids and keys.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Fri Nov 7 22:41:47 CET 2014 on sn-devel-104
commit 2fc8f761c188b1abc90df68003b05b7a098aeabe
Author: Volker Lendecke <vl at samba.org>
Date: Wed Oct 29 13:55:16 2014 +0100
libcli/smb: add smb2_lease_key_equal() helper function
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit a6affb7bb3ff595165e708c56ede2181f0bb570f
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 22 21:21:36 2014 +0200
libcli/smb: mask off SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET for version 1
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 171cefe48fe1d312c60426c09876700a07d45547
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 23 22:56:41 2014 +0200
libcli/smb: remember the lease_version in struct smb2_lease
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 8db5150143c4770bf2ffc40a5234f7b090ec8208
Author: Jeremy Allison <jra at samba.org>
Date: Wed Nov 5 10:12:20 2014 -0800
s4:torture: Add smb2.oplock test batch9a and raw.oplock test batch9a
Shows attribute(stat) access open can create a file,
and subsequent attribute(stat) opens don't break oplocks.
Can be extended to explore more varients.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 5cb4a285690958c8349cb87d5d46d955df789ca4
Author: Stefan Metzmacher <metze at samba.org>
Date: Wed Nov 5 20:27:06 2014 +0100
s3:smbstatus: fix return value in print_share_mode()
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 | 16 +++++
libcli/smb/smb2_lease.h | 7 +++
librpc/idl/smb2_lease_struct.idl | 1 +
selftest/knownfail | 1 +
source3/utils/status.c | 2 +-
source4/torture/raw/oplock.c | 121 ++++++++++++++++++++++++++++++++++++
source4/torture/smb2/oplock.c | 128 +++++++++++++++++++++++++++++++++++++++
7 files changed, 275 insertions(+), 1 deletion(-)
Changeset truncated at 500 lines:
diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c
index f97f096..7705256 100644
--- a/libcli/smb/smb2_lease.c
+++ b/libcli/smb/smb2_lease.c
@@ -43,10 +43,12 @@ ssize_t smb2_lease_pull(const uint8_t *buf, size_t len,
lease->lease_state = IVAL(buf, 16);
lease->lease_flags = IVAL(buf, 20);
lease->lease_duration = BVAL(buf, 24);
+ lease->lease_version = version;
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:
@@ -85,3 +87,17 @@ bool smb2_lease_push(const struct smb2_lease *lease, uint8_t *buf, size_t len)
return true;
}
+
+bool smb2_lease_key_equal(const struct smb2_lease_key *k1,
+ const struct smb2_lease_key *k2)
+{
+ return ((k1->data[0] == k2->data[0]) && (k1->data[1] == k2->data[1]));
+}
+
+bool smb2_lease_equal(const struct GUID *g1,
+ const struct smb2_lease_key *k1,
+ const struct GUID *g2,
+ const struct smb2_lease_key *k2)
+{
+ return GUID_equal(g1, g2) && smb2_lease_key_equal(k1, k2);
+}
diff --git a/libcli/smb/smb2_lease.h b/libcli/smb/smb2_lease.h
index ba8178d..2e6faf7 100644
--- a/libcli/smb/smb2_lease.h
+++ b/libcli/smb/smb2_lease.h
@@ -23,6 +23,7 @@
#ifndef _LIBCLI_SMB_SMB2_LEASE_H_
#define _LIBCLI_SMB_SMB2_LEASE_H_
+#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/smb2_lease_struct.h"
/*
@@ -32,5 +33,11 @@
ssize_t smb2_lease_pull(const uint8_t *buf, size_t len,
struct smb2_lease *lease);
bool smb2_lease_push(const struct smb2_lease *lease, uint8_t *buf, size_t len);
+bool smb2_lease_key_equal(const struct smb2_lease_key *k1,
+ const struct smb2_lease_key *k2);
+bool smb2_lease_equal(const struct GUID *g1,
+ const struct smb2_lease_key *k1,
+ const struct GUID *g2,
+ const struct smb2_lease_key *k2);
#endif /* _LIBCLI_SMB_SMB2_LEASE_H_ */
diff --git a/librpc/idl/smb2_lease_struct.idl b/librpc/idl/smb2_lease_struct.idl
index be80d14..5ccd8a3 100644
--- a/librpc/idl/smb2_lease_struct.idl
+++ b/librpc/idl/smb2_lease_struct.idl
@@ -28,6 +28,7 @@ interface smb2_lease_struct
uint32 lease_flags;
hyper lease_duration; /* should be 0 */
smb2_lease_key parent_lease_key;
+ uint16 lease_version;
uint16 lease_epoch;
} smb2_lease;
};
\ No newline at end of file
diff --git a/selftest/knownfail b/selftest/knownfail
index 6cca3dd..1c4f446 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -167,6 +167,7 @@
^samba4.smb2.oplock.batch1\(.*\)$ # samba 4 oplocks are a mess
^samba4.smb2.oplock.batch6\(.*\)$ # samba 4 oplocks are a mess
^samba4.smb2.oplock.batch9\(.*\)$ # samba 4 oplocks are a mess
+^samba4.smb2.oplock.batch9a\(.*\)$ # samba 4 oplocks are a mess
^samba4.smb2.oplock.batch10\(.*\)$ # samba 4 oplocks are a mess
^samba4.smb2.oplock.batch20\(.*\)$ # samba 4 oplocks are a mess
^samba4.smb2.oplock.batch26\(.*\)$
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 936e87b7..978d3c5 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -123,7 +123,7 @@ static int print_share_mode(const struct share_mode_entry *e,
static int count;
if (do_checks && !is_valid_share_mode_entry(e)) {
- return;
+ return 0;
}
if (count==0) {
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index a4f6a05..1d7522f 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -1873,6 +1873,126 @@ done:
return ret;
}
+static bool test_raw_oplock_batch9a(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname = BASEDIR "\\test_batch9a.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ uint16_t fnum=0, fnum2=0;
+ char c = 0;
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid.fnum = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ torture_comment(tctx, "BATCH9: open with attributes only can create file\n");
+
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
+ io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.create_action, FILE_WAS_CREATED);
+ CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
+
+ torture_comment(tctx, "Subsequent attributes open should not break\n");
+
+ ZERO_STRUCT(break_info);
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
+
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ torture_wait_for_oplock_break(tctx);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(io.ntcreatex.out.create_action, FILE_WAS_OPENED);
+ CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
+ smbcli_close(cli2->tree, fnum2);
+
+ torture_comment(tctx, "Subsequent normal open should break oplock on attribute only open to level II\n");
+
+ ZERO_STRUCT(break_info);
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
+
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ torture_wait_for_oplock_break(tctx);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.fnum, fnum);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+ CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
+ smbcli_close(cli2->tree, fnum2);
+
+ torture_comment(tctx, "third oplocked open should grant level2 without break\n");
+ ZERO_STRUCT(break_info);
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
+ smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree);
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ torture_wait_for_oplock_break(tctx);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
+
+ ZERO_STRUCT(break_info);
+
+ torture_comment(tctx, "write should trigger a break to none on both\n");
+ smbcli_write(cli2->tree, fnum2, 0, &c, 0, 1);
+
+ /* We expect two breaks */
+ torture_wait_for_oplock_break(tctx);
+ torture_wait_for_oplock_break(tctx);
+
+ CHECK_VAL(break_info.count, 2);
+ CHECK_VAL(break_info.level, 0);
+ CHECK_VAL(break_info.failures, 0);
+
+ smbcli_close(cli1->tree, fnum);
+ smbcli_close(cli2->tree, fnum2);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
static bool test_raw_oplock_batch10(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
{
const char *fname = BASEDIR "\\test_batch10.dat";
@@ -4311,6 +4431,7 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
torture_suite_add_2smb_test(suite, "batch7", test_raw_oplock_batch7);
torture_suite_add_2smb_test(suite, "batch8", test_raw_oplock_batch8);
torture_suite_add_2smb_test(suite, "batch9", test_raw_oplock_batch9);
+ torture_suite_add_2smb_test(suite, "batch9a", test_raw_oplock_batch9a);
torture_suite_add_2smb_test(suite, "batch10", test_raw_oplock_batch10);
torture_suite_add_2smb_test(suite, "batch11", test_raw_oplock_batch11);
torture_suite_add_2smb_test(suite, "batch12", test_raw_oplock_batch12);
diff --git a/source4/torture/smb2/oplock.c b/source4/torture/smb2/oplock.c
index d2a2832..be1c5eb 100644
--- a/source4/torture/smb2/oplock.c
+++ b/source4/torture/smb2/oplock.c
@@ -1611,6 +1611,133 @@ static bool test_smb2_oplock_batch9(struct torture_context *tctx,
return ret;
}
+static bool test_smb2_oplock_batch9a(struct torture_context *tctx,
+ struct smb2_tree *tree1,
+ struct smb2_tree *tree2)
+{
+ const char *fname = BASEDIR "\\test_batch9a.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ struct smb2_handle h, h1, h2, h3;
+ char c = 0;
+
+ status = torture_smb2_testdir(tree1, BASEDIR, &h);
+ torture_assert_ntstatus_ok(tctx, status, "Error creating directory");
+
+ /* cleanup */
+ smb2_util_unlink(tree1, fname);
+
+ tree1->session->transport->oplock.handler = torture_oplock_handler;
+ tree1->session->transport->oplock.private_data = tree1;
+
+ /*
+ base ntcreatex parms
+ */
+ ZERO_STRUCT(io.smb2);
+ io.generic.level = RAW_OPEN_SMB2;
+ io.smb2.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io.smb2.in.alloc_size = 0;
+ io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.smb2.in.create_options = 0;
+ io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
+ io.smb2.in.security_flags = 0;
+ io.smb2.in.fname = fname;
+
+ torture_comment(tctx, "BATCH9: open with attributes only can create "
+ "file\n");
+
+ io.smb2.in.create_flags = NTCREATEX_FLAGS_EXTENDED;
+ io.smb2.in.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+ io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
+ SEC_FILE_WRITE_ATTRIBUTE |
+ SEC_STD_SYNCHRONIZE;
+ status = smb2_create(tree1, tctx, &(io.smb2));
+ torture_assert_ntstatus_ok(tctx, status, "Error creating the file");
+ h1 = io.smb2.out.file.handle;
+ CHECK_VAL(io.smb2.out.create_action, FILE_WAS_CREATED);
+ CHECK_VAL(io.smb2.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+
+ torture_comment(tctx, "Subsequent attributes open should not break\n");
+
+ ZERO_STRUCT(break_info);
+
+ status = smb2_create(tree2, tctx, &(io.smb2));
+ torture_assert_ntstatus_ok(tctx, status, "Incorrect status");
+ h3 = io.smb2.out.file.handle;
+ torture_wait_for_oplock_break(tctx);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(io.smb2.out.create_action, FILE_WAS_OPENED);
+ CHECK_VAL(io.smb2.out.oplock_level, SMB2_OPLOCK_LEVEL_NONE);
+ smb2_util_close(tree2, h3);
+
+ torture_comment(tctx, "Subsequent normal open should break oplock on "
+ "attribute only open to level II\n");
+
+ ZERO_STRUCT(break_info);
+
+ io.smb2.in.create_flags = NTCREATEX_FLAGS_EXTENDED;
+ io.smb2.in.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+ io.smb2.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
+ status = smb2_create(tree2, tctx, &(io.smb2));
+ torture_assert_ntstatus_ok(tctx, status, "Incorrect status");
+ h2 = io.smb2.out.file.handle;
+ torture_wait_for_oplock_break(tctx);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.handle.data[0], h1.data[0]);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, SMB2_OPLOCK_LEVEL_II);
+ CHECK_VAL(io.smb2.out.oplock_level, SMB2_OPLOCK_LEVEL_II);
+ smb2_util_close(tree2, h2);
+
+ torture_comment(tctx, "third oplocked open should grant level2 without "
+ "break\n");
+ ZERO_STRUCT(break_info);
+
+ tree2->session->transport->oplock.handler = torture_oplock_handler;
+ tree2->session->transport->oplock.private_data = tree2;
+
+ io.smb2.in.create_flags = NTCREATEX_FLAGS_EXTENDED;
+ io.smb2.in.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+ io.smb2.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
+ status = smb2_create(tree2, tctx, &(io.smb2));
+ torture_assert_ntstatus_ok(tctx, status, "Incorrect status");
+ h2 = io.smb2.out.file.handle;
+ torture_wait_for_oplock_break(tctx);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(io.smb2.out.oplock_level, SMB2_OPLOCK_LEVEL_II);
+
+ ZERO_STRUCT(break_info);
+
+ torture_comment(tctx, "write should trigger a break to none on both\n");
+ tree1->session->transport->oplock.handler =
+ torture_oplock_handler_level2_to_none;
+ tree2->session->transport->oplock.handler =
+ torture_oplock_handler_level2_to_none;
+ smb2_util_write(tree2, h2, &c, 0, 1);
+
+ /* We expect two breaks */
+ torture_wait_for_oplock_break(tctx);
+ torture_wait_for_oplock_break(tctx);
+
+ CHECK_VAL(break_info.count, 2);
+ CHECK_VAL(break_info.level, 0);
+ CHECK_VAL(break_info.failures, 0);
+
+ smb2_util_close(tree1, h1);
+ smb2_util_close(tree2, h2);
+ smb2_util_close(tree1, h);
+
+ smb2_deltree(tree1, BASEDIR);
+ return ret;
+}
+
+
static bool test_smb2_oplock_batch10(struct torture_context *tctx,
struct smb2_tree *tree1,
struct smb2_tree *tree2)
@@ -3836,6 +3963,7 @@ struct torture_suite *torture_smb2_oplocks_init(void)
torture_suite_add_2smb2_test(suite, "batch7", test_smb2_oplock_batch7);
torture_suite_add_2smb2_test(suite, "batch8", test_smb2_oplock_batch8);
torture_suite_add_2smb2_test(suite, "batch9", test_smb2_oplock_batch9);
+ torture_suite_add_2smb2_test(suite, "batch9a", test_smb2_oplock_batch9a);
torture_suite_add_2smb2_test(suite, "batch10", test_smb2_oplock_batch10);
torture_suite_add_2smb2_test(suite, "batch11", test_smb2_oplock_batch11);
torture_suite_add_2smb2_test(suite, "batch12", test_smb2_oplock_batch12);
--
Samba Shared Repository
More information about the samba-cvs
mailing list