From 536bf173461fd17256d8e1a478ee779107e0113b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Apr 2011 16:18:14 -0700 Subject: [PATCH 2/2] Add POSIX O_RDONLY test of a directory for bug #8112 - POSIX extension opens of a directory are denied with EISDIR. Don't strip access bits from wire flags when opening a directory. --- source3/libsmb/clifile.c | 2 -- source3/torture/torture.c | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index cde2466..9c0db1e 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -4396,7 +4396,6 @@ static uint32_t open_flags_to_wire(int flags) #endif #if defined(O_DIRECTORY) if (flags & O_DIRECTORY) { - ret &= ~(SMB_O_RDONLY|SMB_O_RDWR|SMB_O_WRONLY); ret |= SMB_O_DIRECTORY; } #endif @@ -4471,7 +4470,6 @@ static struct tevent_req *cli_posix_open_internal_send(TALLOC_CTX *mem_ctx, /* Setup data words. */ if (is_dir) { - wire_flags &= ~(SMB_O_RDONLY|SMB_O_RDWR|SMB_O_WRONLY); wire_flags |= SMB_O_DIRECTORY; } diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 61af238..5dfcb7e 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -5073,8 +5073,16 @@ static bool run_simple_posix_open_test(int dummy) goto out; } - /* What happens when we try and POSIX open a directory ? */ - if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) { + if (!NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) { + printf("POSIX open directory O_RDONLY of %s failed (%s)\n", + dname, cli_errstr(cli1)); + goto out; + } + + cli_close(cli1, fnum1); + + /* What happens when we try and POSIX open a directory for write ? */ + if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDWR, 0, &fnum1))) { printf("POSIX open of directory %s succeeded, should have failed.\n", fname); goto out; } else { -- 1.7.3.1