Aydin Hassan
Aydin Hassan

Reputation: 1475

PHP is_readable fails but opendir works

Basically what it says on the tin:

if(is_dir($dir))
    echo $dir . " is a directory\n";

if(is_readable($dir))
    echo $dir . " is readable\n";

if($this->handle = opendir($dir))
    echo $dir . " opened\n";

Returns:

\\HTPC\MOVIES is a directory

\\HTPC\MOVIES opened

Which is wierd? I can iterate through the files in the directory but apparently it is not readable. It doesn't really matter as like I said I can still read the files, however I just find it a little odd.

Does anyone have any thoughts?

Upvotes: 5

Views: 1422

Answers (2)

Aydin Hassan
Aydin Hassan

Reputation: 1475

It seems it was a permission error. Assigned to that particular folder was a homegroup. The homegroup wasn't actually being used on the network. Upon removing the homegroup and re-adding the users group is_readable returned true. Still strange how opendir returned true but is_readable not. You surely would expect something that is not readable to fail upon open.

Thanks for your help guys.

Upvotes: 3

Sampo Sarrala
Sampo Sarrala

Reputation: 4868

Check your security policies if you want to prevent entering directory, look for bypass traversal checking or something like that.

If it is bypassing that check then one can enter directory that is forbidden by acl's, however contents can't be read.

If your ACL's is set and selected carefully and correctly for whole tree then you don't normally need to touch this.

Upvotes: 0

Related Questions