Why does PHPs glob() fail for /var/* ?
Moderator: General Moderators
Why does PHPs glob() fail for /var/* ?
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
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/* ?
There is a really big difference between /var* and /var/*
There are 10 types of people in this world, those who understand binary and those who don't
Re: Why does PHPs glob() fail for /var/* ?
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).
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/* ?
Sorry, but I can't reproduce your problem ...
Using glob('/var/*') gives the expexted result on my PC.
Using glob('/var/*') gives the expexted result on my PC.
There are 10 types of people in this world, those who understand binary and those who don't
Re: Why does PHPs glob() fail for /var/* ?
Thank you for trying, which filesystem is your /var folder on?
Regards, JS
Regards, JS
Re: Why does PHPs glob() fail for /var/* ?
ReiserFS
There are 10 types of people in this world, those who understand binary and those who don't
Re: Why does PHPs glob() fail for /var/* ?
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/* ?
Whats the output of
Also, post your code.
PS: Try to login as your Apache user and execute the commands above again.
Code: Select all
ls -l /var
ls -l /var/*PS: Try to login as your Apache user and execute the commands above again.
There are 10 types of people in this world, those who understand binary and those who don't
Re: Why does PHPs glob() fail for /var/* ?
My code:
this outputs:
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
Code: Select all
<?php
require_once "Var_Dump.php";
Var_Dump::display(glob('/var'));
Var_Dump::display(glob('/var/*'));
?>
Output of the interesting line of 'ls -l /':array(1) {
0 => string(4) /var
}
array(0)
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
edit: If I execute this as www-data (apache user) it's completly the same.
Does this help?
Thank you,
JS