The branch, v4-13-test has been updated via 5d4bbaff8b6 smbd: correctly initialize close timestamp fields via 37233cbdf8f torture: add a test that verifies SMB2 close fields without postqueryattrib from c67dbd55aad ctdb: Fix a crash in run_proc_signal_handler()
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-13-test - Log ----------------------------------------------------------------- commit 5d4bbaff8b62504f20074c08bc8f07093a9f52cc Author: Ralph Boehme <s...@samba.org> Date: Mon May 24 12:03:28 2021 +0200 smbd: correctly initialize close timestamp fields BUG: https://bugzilla.samba.org/show_bug.cgi?id=14714 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Mon May 24 16:56:22 UTC 2021 on sn-devel-184 (cherry picked from commit f96cc29711181b5237a5b92c4bfb5e75fe2a73b9) Autobuild-User(v4-13-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-13-test): Wed May 26 11:43:14 UTC 2021 on sn-devel-184 commit 37233cbdf8fc95cd63f24419d8516e303cbbbbff Author: Ralph Boehme <s...@samba.org> Date: Mon May 24 12:21:38 2021 +0200 torture: add a test that verifies SMB2 close fields without postqueryattrib The server must set all fields to 0 if postqueryattrib is not set. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14714 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit ac9042ff4dc6c892764abd23a9445116ad40e62a) ----------------------------------------------------------------------- Summary of changes: source3/smbd/smb2_close.c | 8 ++--- source4/torture/smb2/timestamps.c | 65 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/smbd/smb2_close.c b/source3/smbd/smb2_close.c index a7f1eb7ae46..8ea84c3f0cf 100644 --- a/source3/smbd/smb2_close.c +++ b/source3/smbd/smb2_close.c @@ -215,10 +215,10 @@ static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req, uint16_t flags = 0; bool posix_open = false; - ZERO_STRUCTP(out_creation_ts); - ZERO_STRUCTP(out_last_access_ts); - ZERO_STRUCTP(out_last_write_ts); - ZERO_STRUCTP(out_change_ts); + *out_creation_ts = (struct timespec){0, SAMBA_UTIME_OMIT}; + *out_last_access_ts = (struct timespec){0, SAMBA_UTIME_OMIT}; + *out_last_write_ts = (struct timespec){0, SAMBA_UTIME_OMIT}; + *out_change_ts = (struct timespec){0, SAMBA_UTIME_OMIT}; *out_flags = 0; *out_allocation_size = 0; diff --git a/source4/torture/smb2/timestamps.c b/source4/torture/smb2/timestamps.c index f0cc9c269ff..c37e81d2adc 100644 --- a/source4/torture/smb2/timestamps.c +++ b/source4/torture/smb2/timestamps.c @@ -29,6 +29,70 @@ #define BASEDIR "smb2-timestamps" #define FNAME "testfile.dat" +static bool test_close_no_attrib(struct torture_context *tctx, + struct smb2_tree *tree) +{ + const char *filename = BASEDIR "/" FNAME; + struct smb2_create cr; + struct smb2_handle handle = {{0}}; + struct smb2_handle testdirh = {{0}}; + struct smb2_close c; + NTSTATUS status; + bool ret = true; + + smb2_deltree(tree, BASEDIR); + + status = torture_smb2_testdir(tree, BASEDIR, &testdirh); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "torture_smb2_testdir failed\n"); + smb2_util_close(tree, testdirh); + + cr = (struct smb2_create) { + .in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED, + .in.file_attributes = FILE_ATTRIBUTE_NORMAL, + .in.share_access = NTCREATEX_SHARE_ACCESS_MASK, + .in.create_disposition = NTCREATEX_DISP_OPEN_IF, + .in.impersonation_level = NTCREATEX_IMPERSONATION_ANONYMOUS, + .in.fname = filename, + }; + + status = smb2_create(tree, tctx, &cr); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "smb2_create failed\n"); + handle = cr.out.file.handle; + + c = (struct smb2_close) { + .in.file.handle = handle, + }; + + status = smb2_close(tree, &c); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "close failed\n"); + ZERO_STRUCT(handle); + + torture_assert_u64_equal_goto(tctx, c.out.create_time, NTTIME_OMIT, + ret, done, "Unexpected create time\n"); + torture_assert_u64_equal_goto(tctx, c.out.access_time, NTTIME_OMIT, + ret, done, "Unexpected access time\n"); + torture_assert_u64_equal_goto(tctx, c.out.write_time, NTTIME_OMIT, + ret, done, "Unexpected write time\n"); + torture_assert_u64_equal_goto(tctx, c.out.change_time, NTTIME_OMIT, + ret, done, "Unexpected change time\n"); + torture_assert_u64_equal_goto(tctx, c.out.alloc_size, 0, + ret, done, "Unexpected allocation size\n"); + torture_assert_u64_equal_goto(tctx, c.out.size, 0, + ret, done, "Unexpected size\n"); + torture_assert_u64_equal_goto(tctx, c.out.file_attr, 0, + ret, done, "Unexpected attributes\n"); + +done: + if (!smb2_util_handle_empty(handle)) { + smb2_util_close(tree, handle); + } + smb2_deltree(tree, BASEDIR); + return ret; +} + static bool test_time_t(struct torture_context *tctx, struct smb2_tree *tree, const char *fname, @@ -907,6 +971,7 @@ struct torture_suite *torture_smb2_timestamps_init(TALLOC_CTX *ctx) { struct torture_suite *suite = torture_suite_create(ctx, "timestamps"); + torture_suite_add_1smb2_test(suite, "test_close_not_attrib", test_close_no_attrib); torture_suite_add_1smb2_test(suite, "time_t_15032385535", test_time_t_15032385535); torture_suite_add_1smb2_test(suite, "time_t_10000000000", test_time_t_10000000000); torture_suite_add_1smb2_test(suite, "time_t_4294967295", test_time_t_4294967295); -- Samba Shared Repository