From 5ba3f0c48f98008406a996950c7cd4821faca33f Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Mon, 15 Aug 2016 23:39:50 +0300 Subject: [PATCH] seltest: allow opening files with arbitrary rights in smb2.ioctl tests Separate file creation (which requires write access) from the opening of the file for the test (which might be without write access). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12149 Signed-off-by: Uri Simchoni Reviewed-by: David Disseldorp (cherry picked from commit 6ce0304eda4b464972defcecd591fab03428bd03) --- source4/torture/smb2/ioctl.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c index 8e7f69ad819..0aadca29b07 100644 --- a/source4/torture/smb2/ioctl.c +++ b/source4/torture/smb2/ioctl.c @@ -273,20 +273,36 @@ static bool test_setup_create_fill(struct torture_context *torture, uint32_t file_attributes) { bool ok; + uint32_t initial_access = desired_access; + + if (size > 0) { + initial_access |= SEC_FILE_APPEND_DATA; + } smb2_util_unlink(tree, fname); ok = test_setup_open(torture, tree, mem_ctx, fname, fh, - desired_access, + initial_access, file_attributes); - torture_assert(torture, ok, "file open"); + torture_assert(torture, ok, "file create"); if (size > 0) { ok = write_pattern(torture, tree, mem_ctx, *fh, 0, size, 0); torture_assert(torture, ok, "write pattern"); } + + if (initial_access != desired_access) { + smb2_util_close(tree, *fh); + ok = test_setup_open(torture, tree, mem_ctx, + fname, + fh, + desired_access, + file_attributes); + torture_assert(torture, ok, "file open"); + } + return true; } -- 2.11.4.GIT