pajoye Sat, 30 Jan 2010 20:55:01 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=294259
Log: - fix write access check when write mode only is requested (not RW) Changed paths: U php/php-src/branches/PHP_5_3/TSRM/tsrm_win32.c U php/php-src/trunk/TSRM/tsrm_win32.c U php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859.phpt U php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859_2.phpt A php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859_4.phpt Modified: php/php-src/branches/PHP_5_3/TSRM/tsrm_win32.c =================================================================== --- php/php-src/branches/PHP_5_3/TSRM/tsrm_win32.c 2010-01-30 20:44:57 UTC (rev 294258) +++ php/php-src/branches/PHP_5_3/TSRM/tsrm_win32.c 2010-01-30 20:55:01 UTC (rev 294259) @@ -303,7 +303,7 @@ 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 @@ 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; } } Modified: php/php-src/trunk/TSRM/tsrm_win32.c =================================================================== --- php/php-src/trunk/TSRM/tsrm_win32.c 2010-01-30 20:44:57 UTC (rev 294258) +++ php/php-src/trunk/TSRM/tsrm_win32.c 2010-01-30 20:55:01 UTC (rev 294259) @@ -303,7 +303,7 @@ 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 @@ 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; } } Modified: php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859.phpt 2010-01-30 20:44:57 UTC (rev 294258) +++ php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859.phpt 2010-01-30 20:55:01 UTC (rev 294259) @@ -21,6 +21,7 @@ $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 @@ $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"; Modified: php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859_2.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859_2.phpt 2010-01-30 20:44:57 UTC (rev 294258) +++ php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859_2.phpt 2010-01-30 20:55:01 UTC (rev 294259) @@ -21,11 +21,12 @@ $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 @@ $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); Added: php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859_4.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859_4.phpt (rev 0) +++ php/php-src/trunk/ext/standard/tests/file/windows_acls/bug44859_4.phpt 2010-01-30 20:55:01 UTC (rev 294259) @@ -0,0 +1,64 @@ +--TEST-- +bug #44859 (incorrect result with NTFS ACL permissions, is_readable) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- +<?php +include_once __DIR__ . '/common.inc'; +skipif(); +?> +--FILE-- +<?php +include_once __DIR__ . '/common.inc'; + +$iteration = array( + PHPT_ACL_READ => true, + PHPT_ACL_NONE => false, + PHPT_ACL_WRITE => false, + PHPT_ACL_WRITE|PHPT_ACL_READ => true, +); + +echo "Testing file with relative path:\n"; +$i = 1; +$path = './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_readable($path), $exp); + echo "failed.\n"; + } + delete_file($path); +} + +echo "Testing directory with relative path:\n"; +$path = '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_readable($path), $exp); + echo "failed.\n"; + } + delete_file($path); +} + +?> +--EXPECT-- +Testing file with relative path: +Iteration #1: passed. +Iteration #2: passed. +Iteration #3: passed. +Iteration #4: passed. +Testing directory with relative path: +Iteration #1: passed. +Iteration #2: passed. +Iteration #3: passed. +Iteration #4: passed.
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php