From ed1bc0de189208eb8d4351b9a707d8eb076631d7 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 23 Sep 2019 15:15:01 -0700 Subject: [PATCH 1/3] extend test BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 --- selftest/knownfail.d/samba3.smb2.fileid | 1 + source4/torture/smb2/create.c | 40 ++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 selftest/knownfail.d/samba3.smb2.fileid diff --git a/selftest/knownfail.d/samba3.smb2.fileid b/selftest/knownfail.d/samba3.smb2.fileid new file mode 100644 index 00000000000..89455dacdf0 --- /dev/null +++ b/selftest/knownfail.d/samba3.smb2.fileid @@ -0,0 +1 @@ +^samba3.smb2.fileid.fileid\(nt4_dc\) diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c index 09bdd5aa6cd..518a15738ce 100644 --- a/source4/torture/smb2/create.c +++ b/source4/torture/smb2/create.c @@ -1927,7 +1927,8 @@ static bool test_fileid(struct torture_context *tctx, struct smb2_find f; unsigned int count; union smb_search_data *d; - uint64_t fileid; + uint64_t fileid, fileid2; + uint64_t ow_fileid; uint64_t stream_fileid; NTSTATUS status; bool ret = true; @@ -1954,6 +1955,43 @@ static bool test_fileid(struct torture_context *tctx, fileid = BVAL(&create.out.on_disk_id, 0); + create = (struct smb2_create) { + .in.desired_access = SEC_FILE_ALL, + .in.share_access = NTCREATEX_SHARE_ACCESS_MASK, + .in.file_attributes = FILE_ATTRIBUTE_NORMAL, + .in.create_disposition = NTCREATEX_DISP_OPEN, + .in.fname = fname, + .in.query_on_disk_id = true, + }; + + status = smb2_create(tree, tctx, &create); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "test file could not be created\n"); + fileid2 = BVAL(&create.out.on_disk_id, 0); + smb2_util_close(tree, create.out.file.handle); + + torture_assert_u64_equal_goto(tctx, fileid2, fileid, + ret, done, "bad fileid\n"); + + create = (struct smb2_create) { + .in.desired_access = SEC_FILE_ALL, + .in.share_access = NTCREATEX_SHARE_ACCESS_MASK, + .in.file_attributes = FILE_ATTRIBUTE_NORMAL, + .in.create_disposition = NTCREATEX_DISP_OVERWRITE, + .in.fname = fname, + .in.query_on_disk_id = true, + }; + + status = smb2_create(tree, tctx, &create); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "test file could not be created\n"); + h1 = create.out.file.handle; + + ow_fileid = BVAL(&create.out.on_disk_id, 0); + + torture_assert_u64_equal_goto(tctx, ow_fileid, fileid, + ret, done, "bad fileid\n"); + finfo = (union smb_fileinfo) { .generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION, .generic.in.file.handle = h1, -- 2.21.0 From cc045e61d73bb2b62e9a55041b10ee7e2ffe401b Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 23 Sep 2019 15:15:31 -0700 Subject: [PATCH 2/3] smb2_create.c fetch dos_mode() in smbd_smb2_create_after_exec This is needed for the QFID create context response BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 --- source3/smbd/smb2_create.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c index 61ed72169fb..66f4aad8c9e 100644 --- a/source3/smbd/smb2_create.c +++ b/source3/smbd/smb2_create.c @@ -1274,6 +1274,9 @@ static void smbd_smb2_create_after_exec(struct tevent_req *req) DEBUG(10, ("smbd_smb2_create_send: " "response construction phase\n")); + state->out_file_attributes = dos_mode(state->result->conn, + state->result->fsp_name); + if (state->mxac != NULL) { NTTIME last_write_time; @@ -1472,8 +1475,6 @@ static void smbd_smb2_create_finish(struct tevent_req *req) state->out_create_action = state->info; } result->op->create_action = state->out_create_action; - state->out_file_attributes = dos_mode(result->conn, - result->fsp_name); state->out_creation_ts = get_create_timespec(smb1req->conn, result, result->fsp_name); -- 2.21.0 From 3816ff4e615b541e5f792c99637b4afa5198d2f3 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 23 Sep 2019 15:16:58 -0700 Subject: [PATCH 3/3] s3:smbd: when storing DOS attribute call dos_mode() beforehand This is required to ensure File-ID info is up2date. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 --- selftest/knownfail.d/samba3.smb2.fileid | 1 - source3/smbd/open.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 selftest/knownfail.d/samba3.smb2.fileid diff --git a/selftest/knownfail.d/samba3.smb2.fileid b/selftest/knownfail.d/samba3.smb2.fileid deleted file mode 100644 index 89455dacdf0..00000000000 --- a/selftest/knownfail.d/samba3.smb2.fileid +++ /dev/null @@ -1 +0,0 @@ -^samba3.smb2.fileid.fileid\(nt4_dc\) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 20b5a3e294c..061f16a0ebe 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3953,6 +3953,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, /* Overwritten files should be initially set as archive */ if ((info == FILE_WAS_OVERWRITTEN && lp_map_archive(SNUM(conn))) || lp_store_dos_attributes(SNUM(conn))) { + (void)dos_mode(conn, smb_fname); if (!posix_open) { if (file_set_dosmode(conn, smb_fname, new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE, -- 2.21.0