r3180: - basic support for SEC_RIGHT_MAXIMUM_ALLOWED in pvfs
authorAndrew Tridgell <tridge@samba.org>
Mon, 25 Oct 2004 02:36:12 +0000 (02:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:04:37 +0000 (13:04 -0500)
- RAW-CONTEXT test now passes
(This used to be commit 0dae9fef09ec8bce19c39a0caf36e0882e507bc4)

source4/ntvfs/posix/pvfs_open.c
source4/script/tests/test_posix.sh
source4/torture/raw/context.c

index ac2742d357939b00555bd3dbb97d417332ad85b2..badd18d370e6296950ff53b9d2ff28b3b885101c 100644 (file)
@@ -283,6 +283,10 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
                return NT_STATUS_CANNOT_DELETE;
        }
        
+       if (access_mask & SEC_RIGHT_MAXIMUM_ALLOWED) {
+               access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE;
+       }
+
        flags = O_RDWR;
 
        f = talloc_p(req, struct pvfs_file);
@@ -355,7 +359,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
        f->lock_count = 0;
        f->create_options = io->generic.in.create_options;
        f->share_access = io->generic.in.share_access;
-       f->access_mask = io->generic.in.access_mask;
+       f->access_mask = access_mask;
        f->seek_offset = 0;
        f->position = 0;
 
@@ -429,6 +433,14 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
        share_access   = io->generic.in.share_access;
        access_mask    = io->generic.in.access_mask;
 
+       if (access_mask & SEC_RIGHT_MAXIMUM_ALLOWED) {
+               if (name->dos.attrib & FILE_ATTRIBUTE_READONLY) {
+                       access_mask = GENERIC_RIGHTS_FILE_READ;
+               } else {
+                       access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE;
+               }
+       }
+
        /* certain create options are not allowed */
        if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
            !(access_mask & STD_RIGHT_DELETE_ACCESS)) {
@@ -551,7 +563,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
        f->lock_count = 0;
        f->create_options = io->generic.in.create_options;
        f->share_access = io->generic.in.share_access;
-       f->access_mask = io->generic.in.access_mask;
+       f->access_mask = access_mask;
        f->seek_offset = 0;
        f->position = 0;
 
index 0cb983e74c98a03c5e9b651460d4a1c190c158d8..d17d428642248c4af6a95c4b8ee610b9d8cf6027 100755 (executable)
@@ -36,12 +36,12 @@ tests="$tests BASE-DENY3 BASE-XCOPY"
 tests="$tests BASE-DELETE BASE-PROPERTIES BASE-MANGLE"
 tests="$tests BASE-CHKPATH BASE-SECLEAK"
 tests="$tests RAW-QFSINFO RAW-QFILEINFO RAW-SFILEINFO-BUG"
-tests="$tests RAW-LOCK RAW-SEEK"
+tests="$tests RAW-LOCK RAW-SEEK RAW-CONTEXT"
 
 
 soon="BASE-DIR1 BASE-DENY1 BASE-VUID BASE-OPEN BASE-DEFER_OPEN BASE-RENAME BASE-OPENATTR BASE-CHARSET"
-soon="$soon RAW-SFILEINFO RAW-SEARCH RAW-CLOSE RAW-OPEN RAW-MKDIR RAW-OPLOCK RAW-NOTIFY RAW-MUX RAW-IOCTL"
-soon="$soon RAW-CHKPATH RAW-UNLINK RAW-READ RAW-WRITE RAW-CONTEXT RAW-RENAME"
+soon="$soon RAW-SFILEINFO RAW-SEARCH RAW-OPEN RAW-MKDIR RAW-OPLOCK RAW-NOTIFY RAW-MUX RAW-IOCTL"
+soon="$soon RAW-CHKPATH RAW-UNLINK RAW-READ RAW-WRITE RAW-RENAME RAW-CLOSE"
 
 for t in $tests; do
     if [ ! -z "$start" -a "$start" != $t ]; then
index 33eab4a0c37fe5a1ff6d3d1e94cdd2b52b53dbdf..85357e2535acc297e21e0301b54a0c765f2ae791 100644 (file)
 
 #define CHECK_STATUS(status, correct) do { \
        if (!NT_STATUS_EQUAL(status, correct)) { \
-               printf("(%d) Incorrect status %s - should be %s\n", \
-                      __LINE__, nt_errstr(status), nt_errstr(correct)); \
+               printf("(%s) Incorrect status %s - should be %s\n", \
+                      __location__, nt_errstr(status), nt_errstr(correct)); \
                ret = False; \
                goto done; \
        }} while (0)
 
 #define CHECK_VALUE(v, correct) do { \
        if ((v) != (correct)) { \
-               printf("(%d) Incorrect value %s=%d - should be %d\n", \
-                      __LINE__, #v, v, correct); \
+               printf("(%s) Incorrect value %s=%d - should be %d\n", \
+                      __location__, #v, v, correct); \
                ret = False; \
                goto done; \
        }} while (0)
 
 #define CHECK_NOT_VALUE(v, correct) do { \
        if ((v) == (correct)) { \
-               printf("(%d) Incorrect value %s=%d - should not be %d\n", \
-                      __LINE__, #v, v, correct); \
+               printf("(%s) Incorrect value %s=%d - should not be %d\n", \
+                      __location__, #v, v, correct); \
                ret = False; \
                goto done; \
        }} while (0)