Add POSIX O_RDONLY test of a directory for bug #8112 - POSIX extension opens of a...
authorJeremy Allison <jra@samba.org>
Fri, 29 Apr 2011 23:18:14 +0000 (16:18 -0700)
committerJeremy Allison <jra@samba.org>
Sat, 30 Apr 2011 00:21:24 +0000 (02:21 +0200)
Don't strip access bits from wire flags when opening a directory.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Sat Apr 30 02:21:24 CEST 2011 on sn-devel-104

source3/libsmb/clifile.c
source3/torture/torture.c

index cde24661757953a912a3ecc4fa0c66e27de7a9d4..9c0db1ed3acc62c42efcec1bbd73d3328aaaa837 100644 (file)
@@ -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;
        }
 
index 61af2387c00b998bbe695b2307f6c03c904d2e64..5dfcb7e97ce447418e70ed612477be1f8f7364a2 100644 (file)
@@ -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 {