Bug #52312 [Fbk]: PHP lstat problem

From: Date: Mon, 12 Jul 2010 17:00:40 +0000
Subject: Bug #52312 [Fbk]: PHP lstat problem
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-152321@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52312&edit=1

 ID:               52312
 Updated by:       rasmus@php.net
 Reported by:      v dot damore at gmail dot com
 Summary:          PHP lstat problem
 Status:           Feedback
 Type:             Bug
 Package:          Safe Mode/open_basedir
 Operating System: Linux
 PHP Version:      5.2.13

 New Comment:

I don't see that here.  Attach gdb and set a breakpoint on lstat and see
who is 
calling them.


Previous Comments:
------------------------------------------------------------------------
[2010-07-12 18:21:50] v dot damore at gmail dot com

I have already tried with 5.3 and I was thinking to open an new bug
because I have same behavior, there is only a change in the order of
execution of lstat from fullpath to /usr :

7339  chdir("/usr/local/myspace/webspace/httpdocs") = 0
7339  lstat("/usr/local/myspace/webspace/httpdocs/test.php",
{st_mode=S_IFREG|0644, st_size=19, ...}) = 0
7339  lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
7339  lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
7339  lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace/webspace/httpdocs/test.php",
{st_mode=S_IFREG|0644, st_size=19, ...}) = 0
7339  lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
7339  lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
7339  lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace/webspace/httpdocs/test.php",
{st_mode=S_IFREG|0644, st_size=19, ...}) = 0
7339  lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
7339  lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
7339  lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
7339  lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
7339  lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
7339  lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
7339  open("/usr/local/myspace/webspace/httpdocs/test.php", O_RDONLY) =
16
7339  fstat(16, {st_mode=S_IFREG|0644, st_size=19, ...}) = 0
7339  fstat(16, {st_mode=S_IFREG|0644, st_size=19, ...}) = 0
7339  fstat(16, {st_mode=S_IFREG|0644, st_size=19, ...}) = 0
7339  mmap(NULL, 19, PROT_READ, MAP_SHARED, 16, 0) = 0x2adfec195000
7339  munmap(0x2adfec195000, 19)        = 0
7339  close(16)                         = 0
7339  chdir("/")                        = 0

------------------------------------------------------------------------
[2010-07-12 18:03:54] pajoye@php.net

Can you try with 5.3 please?

------------------------------------------------------------------------
[2010-07-12 17:51:24] v dot damore at gmail dot com

I tried again with a simple script test.php '<? echo "Ciao" ?>'
realpath_cache_size=1024k
realpath_cache_ttl=600

I have always same behavior (also second and following times I try to
call curl http://damorealt.xoom.it/test.php:

13692 chdir("/usr/local/myspace/webspace/httpdocs") = 0
13692 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13692 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
13692 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
13692 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
13692 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13692 lstat("/usr/local/myspace/webspace/httpdocs/test.php",
{st_mode=S_IFREG|0644, st_size=19, ...}) = 0
13692 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13692 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
13692 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
13692 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
13692 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13692 lstat("/usr/local/myspace/webspace/httpdocs/test.php",
{st_mode=S_IFREG|0644, st_size=19, ...}) = 0
13692 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13692 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
13692 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
13692 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
13692 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13692 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
13692 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
13692 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
13692 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13692 lstat("/usr/local/myspace/webspace/httpdocs/test.php",
{st_mode=S_IFREG|0644, st_size=19, ...}) = 0
13692 open("/usr/local/myspace/webspace/httpdocs/test.php", O_RDONLY) =
16
13692 fstat(16, {st_mode=S_IFREG|0644, st_size=19, ...}) = 0
13692 read(16, "<? echo \"Ciao!\" ?>\n", 8192) = 19
13692 read(16, "", 8192)                = 0
13692 read(16, "", 8192)                = 0
13692 close(16)                         = 0
13692 chdir("/")                        = 0

------------------------------------------------------------------------
[2010-07-12 17:07:40] rasmus@php.net

phpinfo() is a special case.  Try it with a simple hello world script.

------------------------------------------------------------------------
[2010-07-12 16:56:36] v dot damore at gmail dot com

The real problem is that such full scan are repeated more then once:

25933 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
25933 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php",
{st_mode=S_IFREG|0644, st_size=16, ...}) = 0

First check

25933 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
25933 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php",
{st_mode=S_IFREG|0644, st_size=16, ...}) = 0

Second check

25933 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
25933 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0

Third check (incomplete)

25933 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
25933 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php",
{st_mode=S_IFREG|0644, st_size=16, ...}) = 0

Final check and then read the file.

25933 open("/usr/local/myspace/webspace/httpdocs/phpinfo.php", O_RDONLY)
= 16
25933 fstat(16, {st_mode=S_IFREG|0644, st_size=16, ...}) = 0
25933 read(16, "<? phpinfo() ?>\n", 8192) = 16
25933 read(16, "", 8192)                = 0
25933 read(16, "", 8192)                = 0
25933 close(16)                         = 0

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=52312


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


Thread (64 messages)

« previous php.bugs (#152321) next »