From: Uri Simchoni Date: Mon, 15 Aug 2016 20:39:50 +0000 (+0300) Subject: seltest: allow opening files with arbitrary rights in smb2.ioctl tests X-Git-Tag: samba-4.3.12~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d6240b48e021165f2f60d1e37c455a7fc33f578;p=thirdparty%2Fsamba.git 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) --- 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; }