#21551 [Opn->Csd]: is_readable() & is_writable() returns wrong values on related pathes

From: Date: Sat, 08 Feb 2003 01:58:42 +0000
Subject: #21551 [Opn->Csd]: is_readable() & is_writable() returns wrong values on related pathes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-32426@lists.php.net to get a copy of this message
 ID:               21551
 Updated by:       magnus@php.net
 Reported By:      xdl@mail.ru
-Status:           Open
+Status:           Closed
 Bug Type:         Filesystem function related
 Operating System: SuSe Linux 7.2
 PHP Version:      4.2.3
 New Comment:

User reports the problem is fixed in release 4.3.0. 


Previous Comments:
------------------------------------------------------------------------

[2003-02-07 18:55:59] xdl@mail.ru

Yes, in PHP 4.3.0 the bug is fixed.
Thank you!
---------------------------------------------
<?
header("Content-type: text/plain");

function s($c) {
        echo "\$ $c\n";
        system($c);
        echo "\n";
}

function wr($f) {
        if(is_writable($f)) {
                echo "$f is writable.\n";
        } else {
                echo "$f is NOT writable.\n";
        }
        if(is_readable($f)) {
                echo "$f is readable.\n";
        } else {
                echo "$f is NOT readable.\n";
        }
}

$dir = "attachments";

s("whoami");
s("pwd");
s("ls -ld $dir");


echo "PHP version = ".phpversion()."\n";
echo "getcwd() = ".getcwd()."\n";

wr($dir);
$dir2 = "$dir/test";
mkdir("$dir2");
wr($dir2);
$dir3 = $DOCUMENT_ROOT . "/phpbt/" . $dir;
wr($dir3);
?>
---------------------------------------------
$ whoami
nobody

$ pwd
/usr/local/httpd/web/phpbt

$ ls -ld attachments
drwxrwxrwx    4 nobody   nogroup      4096 Feb  8 03:43 attachments

PHP version = 4.3.0
getcwd() = /usr/local/httpd/web/phpbt
attachments is writable.
attachments is readable.
attachments/test is writable.
attachments/test is readable.
/usr/local/httpd/web/phpbt/attachments is writable.
/usr/local/httpd/web/phpbt/attachments is readable.
---------------------------------------------

------------------------------------------------------------------------

[2003-01-27 22:39:29] sniper@php.net

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.



------------------------------------------------------------------------

[2003-01-09 19:00:47] sniper@php.net

First of all, update to PHP 4.3.0. Then if this still
misbehaves, try adding 'echo getcwd();' in your script to see what PHP
thinks the current working directory is.


------------------------------------------------------------------------

[2003-01-09 10:26:45] xdl@mail.ru

<?
function s($c) {
	echo "\$ $c\n";
	system($c);
	echo "\n";
}

function wr($f) {
	if(is_writable($f)) {
		echo "<b>$f</b> is writable.\n";
	} else {
		echo "<b>$f</b> is <font color='red'>NOT</font>
writable.\n";
	}

	if(is_readable($f)) {
		echo "<b>$f</b> is readable.\n";
	} else {
		echo "<b>$f</b> is <font color='red'>NOT</font>
readable.\n";
	}
}

$dir = "attachments";

s("whoami");
s("pwd");
s("ls -ld $dir");

wr($dir);

$dir2 = "$dir/test";
mkdir("$dir2");

wr($dir2);

//$dir3 = pwd;
$dir3 = $DOCUMENT_ROOT . "/phpbt/" . $dir;

wr($dir3);

?>

Output is:
------------------------------
$ whoami
nobody

$ pwd
/usr/local/httpd/web/phpbt

$ ls -ld attachments
drwxrwxrwx    4 nobody   nogroup      4096 Jan  9 18:50 attachments

attachments is NOT writable.
attachments is NOT readable.
attachments/test is NOT writable.
attachments/test is NOT readable.
/usr/local/httpd/web/phpbt/attachments is writable.
/usr/local/httpd/web/phpbt/attachments is readable.
------------------------------

------------------------------------------------------------------------

[2003-01-09 10:21:25] xdl@mail.ru

<?
function s($c) {
	echo "\$ $c\n";
	system($c);
	echo "\n";
}

function wr($f) {
	if(is_writable($f)) {
		echo "<b>$f</b> is writable.\n";
	} else {
		echo "<b>$f</b> is <font color='red'>NOT</font>
writable.\n";
	}

	if(is_readable($f)) {
		echo "<b>$f</b> is readable.\n";
	} else {
		echo "<b>$f</b> is <font color='red'>NOT</font>
readable.\n";
	}
}

$dir = "attachments";

s("whoami");
s("pwd");
s("ls -ld $dir");

wr($dir);

$dir2 = "$dir/test";
mkdir("$dir2");

wr($dir2);

//$dir3 = pwd;
$dir3 = $DOCUMENT_ROOT . "/phpbt/" . $dir;

wr($dir3);

?>

Output is:
------------------------------
$ whoami
nobody

$ pwd
/usr/local/httpd/web/phpbt

$ ls -ld attachments
drwxrwxrwx    4 nobody   nogroup      4096 Jan  9 18:50 attachments

attachments is NOT writable.
attachments is NOT readable.
attachments/test is NOT writable.
attachments/test is NOT readable.
/usr/local/httpd/web/phpbt/attachments is writable.
/usr/local/httpd/web/phpbt/attachments is readable.
------------------------------

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=21551&edit=1



Thread (6 messages)

« previous php.bugs (#32426) next »