55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
--TEST--
|
|
posix_access() flag (mode) validation
|
|
--SKIPIF--
|
|
<?php
|
|
if (!function_exists("posix_access")) {
|
|
die("skip no posix_access()");
|
|
}
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
$dir = __DIR__;
|
|
$testfile = "$dir/testfile.txt";
|
|
|
|
// Create a temporary file for valid access tests
|
|
file_put_contents($testfile, "hello");
|
|
|
|
try {
|
|
posix_access($testfile, -1);
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
try {
|
|
posix_access($testfile, 01000); // S_ISVTX bit (sticky)
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
try {
|
|
posix_access($testfile, 02000); // S_ISGID bit
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
if (posix_access($testfile, POSIX_R_OK | POSIX_W_OK)) {
|
|
echo "Read/write access OK\n";
|
|
}
|
|
|
|
if (posix_access($testfile, POSIX_F_OK)) {
|
|
echo "File exists OK\n";
|
|
}
|
|
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
@unlink(__DIR__ . '/testfile.txt');
|
|
?>
|
|
--EXPECTF--
|
|
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
|
|
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
|
|
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
|
|
Read/write access OK
|
|
File exists OK
|