Page 1 of 1
Why does PHPs glob() fail for /var/* ?
Posted: Thu Oct 09, 2008 9:41 am
by js2007
Hi
glob('/var/*') and glob('/var/www/*') all return empty arrays for any subdir.
I tried it with PHP 5.2.0 and 5.2.6 on the same machine. System is Debian Sarge.
/var is a mounted ReiserFS partition, could this be a cause?
Other glob() calls work:
glob('/*') -> lists all dirs in the root, even /var
glob('/usr/*') -> lists all files / dirs within /usr
glob('/var*') -> returns the single entry '/var'
/var is not empty and permissions are 755.
I can fopen, include etc any file within /var, /var/www is the document_root.
There are only a few files and dirs in /var so it can't be because of the known bug that many files cause a segfault in glob.
Thanks in advance,
JS
Re: Why does PHPs glob() fail for /var/* ?
Posted: Thu Oct 09, 2008 9:48 am
by VladSun
There is a really big difference between /var* and /var/*
Re: Why does PHPs glob() fail for /var/* ?
Posted: Thu Oct 09, 2008 10:06 am
by js2007
Haha, i guess so.
the first one works and shows the correct entry in the system root
second one doesn't work so i guess he can't read inside that directory, but that only affects glob() so it's either a glob issue with the filesystem issue or a with the os (debian).
Re: Why does PHPs glob() fail for /var/* ?
Posted: Fri Oct 10, 2008 5:41 am
by VladSun
Sorry, but I can't reproduce your problem ...
Using glob('/var/*') gives the expexted result on my PC.
Re: Why does PHPs glob() fail for /var/* ?
Posted: Fri Oct 10, 2008 3:45 pm
by js2007
Thank you for trying, which filesystem is your /var folder on?
Regards, JS
Re: Why does PHPs glob() fail for /var/* ?
Posted: Fri Oct 10, 2008 4:26 pm
by VladSun
ReiserFS
Re: Why does PHPs glob() fail for /var/* ?
Posted: Sat Oct 11, 2008 3:00 pm
by js2007
Wow, that's interesting. So it's not because of the fs but another problem, maybe special to my system.
Re: Why does PHPs glob() fail for /var/* ?
Posted: Sat Oct 11, 2008 3:05 pm
by VladSun
Whats the output of
Also, post your code.
PS: Try to login as your Apache user and execute the commands above again.
Re: Why does PHPs glob() fail for /var/* ?
Posted: Sat Oct 11, 2008 3:23 pm
by js2007
My code:
Code: Select all
<?php
require_once "Var_Dump.php";
Var_Dump::display(glob('/var'));
Var_Dump::display(glob('/var/*'));
?>
this outputs:
array(1) {
0 => string(4) /var
}
array(0)
Output of the interesting line of 'ls -l /':
Code: Select all
drwxr-xr-x 17 root root 408 2008-10-09 14:15 var
Code: Select all
jake@dresden:~$ ls -l /var
total 9
drwxr-xr-x 2 root root 864 2008-10-11 06:25 backups
drwxr-xr-x 8 root root 192 2007-11-11 17:04 cache
drwxrwxr-x 9 jake www-data 224 2008-09-30 17:44 data
drwxr-xr-x 30 root root 768 2008-10-08 19:34 lib
drwxrwsr-x 2 root staff 48 2006-12-20 11:03 local
drwxrwxrwt 3 root root 96 2008-05-09 19:04 lock
drwxr-xr-x 8 root root 3768 2008-10-11 06:26 log
drwxrwsr-x 2 root mail 48 2007-10-15 16:08 mail
drwxr-xr-x 2 root root 48 2006-12-20 11:03 opt
drwxr-xr-x 11 root root 656 2008-10-11 04:47 run
drwxr-xr-x 7 root root 192 2007-02-04 12:07 spool
drwxrwx--- 4 root subversion 112 2007-01-04 11:19 svn
-rw-r--r-- 1 root root 3 2008-10-09 14:15 tess
drwxrwxrwt 5 root root 176 2008-10-08 19:12 tmp
drwxrwxr-x 10 www-data users 392 2008-10-09 12:51 www
ls -l /var/* looks the same but for the contents of each subdir of /var.
edit: If I execute this as www-data (apache user) it's completly the same.
Does this help?
Thank you,
JS