]> granicus.if.org Git - php/commitdiff
- fix write access check when write mode only is requested (not RW)
authorPierre Joye <pajoye@php.net>
Sat, 30 Jan 2010 20:55:01 +0000 (20:55 +0000)
committerPierre Joye <pajoye@php.net>
Sat, 30 Jan 2010 20:55:01 +0000 (20:55 +0000)
TSRM/tsrm_win32.c
ext/standard/tests/file/windows_acls/bug44859.phpt
ext/standard/tests/file/windows_acls/bug44859_2.phpt
ext/standard/tests/file/windows_acls/bug44859_4.phpt [new file with mode: 0644]

index 99f27794a1bbd9aca3894870828ea4f983598329..50c6210e965d509a3b6337e50a3f20c1a624222d 100644 (file)
@@ -303,7 +303,7 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
                                fAccess = bucket->is_writable;
                                goto Finished;
                        }
-                       desired_access = FILE_GENERIC_READ | FILE_GENERIC_WRITE;
+                       desired_access = FILE_GENERIC_WRITE;
                } else if(mode <= 4) {
                        if(bucket != NULL && bucket->is_rvalid) {
                                fAccess = bucket->is_readable;
@@ -348,6 +348,11 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
                        else if(desired_access == FILE_GENERIC_WRITE) {
                                bucket->is_wvalid = 1;
                                bucket->is_writable = fAccess;
+                       } else if (desired_access == FILE_GENERIC_READ | FILE_GENERIC_WRITE) {
+                               bucket->is_rvalid = 1;
+                               bucket->is_readable = fAccess;
+                               bucket->is_wvalid = 1;
+                               bucket->is_writable = fAccess;
                        }
                }
 
index 0716ee5ac47c4f039353007efa94362300ee161d..bb22a5cd8e597a7a95706818caea4f5f2604404d 100644 (file)
@@ -21,6 +21,7 @@ $i = 1;
 $path = __DIR__ . '/a.txt';
 foreach ($iteration as $perms => $exp) {
        create_file($path, $perms);
+       clearstatcache(true, $path);
        echo 'Iteration #' . $i++ . ': ';
        if (is_writable($path) == $exp) {
                echo "passed.\n";
@@ -36,6 +37,7 @@ $path = __DIR__ . '/adir';
 $i = 1;
 foreach ($iteration as $perms => $exp) {
        create_file($path, $perms);
+       clearstatcache(true, $path);
        echo 'Iteration #' . $i++ . ': ';
        if (is_writable($path) == $exp) {
                echo "passed.\n";
index 8326eb473ee199ed89e335fec84a7e6b032ff041..3cc4ed1ba19da6224e07bb9f0106272489dbf559 100644 (file)
@@ -21,11 +21,12 @@ $i = 1;
 $path = __DIR__ . '/a.txt';
 foreach ($iteration as $perms => $exp) {
        create_file($path, $perms);
+       clearstatcache(true, $path);
        echo 'Iteration #' . $i++ . ': ';
        if (is_readable($path) == $exp) {
                echo "passed.\n";
        } else {
-               var_dump(is_writable($path), $exp);
+               var_dump(is_readable($path), $exp);
                echo "failed.\n";
        }
        delete_file($path);
@@ -36,11 +37,12 @@ $path = __DIR__ . '/adir';
 $i = 1;
 foreach ($iteration as $perms => $exp) {
        create_file($path, $perms);
+       clearstatcache(true, $path);
        echo 'Iteration #' . $i++ . ': ';
        if (is_readable($path) == $exp) {
                echo "passed.\n";
        } else {
-               var_dump(is_writable($path), $exp);
+               var_dump(is_readable($path), $exp);
                echo "failed.\n";
        }
        delete_file($path);
diff --git a/ext/standard/tests/file/windows_acls/bug44859_4.phpt b/ext/standard/tests/file/windows_acls/bug44859_4.phpt
new file mode 100644 (file)
index 0000000..61aae65
--- /dev/null
@@ -0,0 +1,64 @@
+--TEST--\r
+bug #44859 (incorrect result with NTFS ACL permissions, is_readable)\r
+--CREDITS--\r
+Venkat Raman Don\r
+--SKIPIF--\r
+<?php \r
+include_once __DIR__ . '/common.inc';\r
+skipif();\r
+?>\r
+--FILE--\r
+<?php\r
+include_once __DIR__ . '/common.inc';\r
+\r
+$iteration = array(\r
+       PHPT_ACL_READ => true,\r
+       PHPT_ACL_NONE => false,\r
+       PHPT_ACL_WRITE => false,\r
+       PHPT_ACL_WRITE|PHPT_ACL_READ => true,\r
+);\r
+\r
+echo "Testing file with relative path:\n";\r
+$i = 1;\r
+$path = './a.txt';\r
+foreach ($iteration as $perms => $exp) {\r
+       create_file($path, $perms);\r
+       clearstatcache(true, $path);\r
+       echo 'Iteration #' . $i++ . ': ';\r
+       if (is_readable($path) == $exp) {\r
+               echo "passed.\n";\r
+       } else {\r
+               var_dump(is_readable($path), $exp);\r
+               echo "failed.\n";\r
+       }\r
+       delete_file($path);\r
+}\r
+\r
+echo "Testing directory with relative path:\n";\r
+$path = 'adir';\r
+$i = 1;\r
+foreach ($iteration as $perms => $exp) {\r
+       create_file($path, $perms);\r
+       clearstatcache(true, $path);\r
+       echo 'Iteration #' . $i++ . ': ';\r
+       if (is_readable($path) == $exp) {\r
+               echo "passed.\n";\r
+       } else {\r
+               var_dump(is_readable($path), $exp);\r
+               echo "failed.\n";\r
+       }\r
+       delete_file($path);\r
+}\r
+\r
+?>\r
+--EXPECT--\r
+Testing file with relative path:\r
+Iteration #1: passed.\r
+Iteration #2: passed.\r
+Iteration #3: passed.\r
+Iteration #4: passed.\r
+Testing directory with relative path:\r
+Iteration #1: passed.\r
+Iteration #2: passed.\r
+Iteration #3: passed.\r
+Iteration #4: passed.\r