diff options
author | Andrew Tridgell <tridge@samba.org> | 2008-05-30 07:28:29 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2008-05-30 07:28:29 +1000 |
commit | b33dba845e4e583a25c2f88b8439b8dde205dc89 (patch) | |
tree | 06ffb0f8862a799b4e52907f557d4b6eaa5ff3f4 /source4/torture | |
parent | 2371de92a08a1fb63ba458bba3cee5a251419579 (diff) | |
download | samba-b33dba845e4e583a25c2f88b8439b8dde205dc89.tar.gz samba-b33dba845e4e583a25c2f88b8439b8dde205dc89.tar.bz2 samba-b33dba845e4e583a25c2f88b8439b8dde205dc89.zip |
don't emulate broken SMB2 locking behaviour from windows
(This used to be commit c50e7a15f9a7f2c5821b5ee468f9ade6eaa0ed55)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/smb2/lock.c | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c index 5a36ac3eae..35ad839610 100644 --- a/source4/torture/smb2/lock.c +++ b/source4/torture/smb2/lock.c @@ -106,7 +106,11 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree lck.in.reserved = 0x123ab3; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + if (torture_setting_bool(torture, "windows", false)) { + CHECK_STATUS(status, NT_STATUS_OK); + } else { + CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); + } CHECK_VALUE(lck.out.reserved, 0); lck.in.reserved = 0x123ab4; @@ -115,7 +119,11 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree lck.in.reserved = 0x123ab5; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + if (torture_setting_bool(torture, "windows", false)) { + CHECK_STATUS(status, NT_STATUS_OK); + } else { + CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); + } CHECK_VALUE(lck.out.reserved, 0); lck.in.lock_count = 0x0001; @@ -133,14 +141,22 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + if (torture_setting_bool(torture, "windows", false)) { + CHECK_STATUS(status, NT_STATUS_OK); + } else { + CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); + } CHECK_VALUE(lck.out.reserved, 0); status = smb2_lock(tree, &lck); CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + if (torture_setting_bool(torture, "windows", false)) { + CHECK_STATUS(status, NT_STATUS_OK); + } else { + CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); + } CHECK_VALUE(lck.out.reserved, 0); el[0].flags = 0x00000000; @@ -473,6 +489,51 @@ static bool test_lock_rw_exclusiv(struct torture_context *torture, struct smb2_t return test_lock_read_write(torture, tree, &s); } + +static bool test_lock_auto_unlock(struct torture_context *torture, struct smb2_tree *tree) +{ + bool ret = true; + NTSTATUS status; + struct smb2_handle h; + uint8_t buf[200]; + struct smb2_lock lck; + struct smb2_lock_element el[2]; + + ZERO_STRUCT(buf); + + status = torture_smb2_testfile(tree, "autounlock.txt", &h); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf)); + CHECK_STATUS(status, NT_STATUS_OK); + + ZERO_STRUCT(lck); + lck.in.locks = el; + lck.in.lock_count = 0x0001; + lck.in.file.handle = h; + el[0].offset = 0; + el[0].length = 1; + el[0].flags = SMB2_LOCK_FLAG_EXCLUSIVE | SMB2_LOCK_FLAG_FAIL_IMMEDIATELY; + status = smb2_lock(tree, &lck); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb2_lock(tree, &lck); + CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); + + status = smb2_lock(tree, &lck); + if (torture_setting_bool(torture, "windows", false)) { + CHECK_STATUS(status, NT_STATUS_OK); + } else { + CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); + } + + + +done: + return ret; +} + + /* basic testing of SMB2 locking */ struct torture_suite *torture_smb2_lock_init(void) @@ -483,6 +544,7 @@ struct torture_suite *torture_smb2_lock_init(void) torture_suite_add_1smb2_test(suite, "RW-NONE", test_lock_rw_none); torture_suite_add_1smb2_test(suite, "RW-SHARED", test_lock_rw_shared); torture_suite_add_1smb2_test(suite, "RW-EXCLUSIV", test_lock_rw_exclusiv); + torture_suite_add_1smb2_test(suite, "AUTO-UNLOCK", test_lock_auto_unlock); suite->description = talloc_strdup(suite, "SMB2-LOCK tests"); |