php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64986 is_readable cannot read UNC path
Submitted: 2013-06-07 07:36 UTC Modified: 2013-06-24 06:40 UTC
Votes:8
Avg. Score:4.5 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:0 (0.0%)
Same OS:7 (87.5%)
From: mhhechanova at gmail dot com Assigned: ab (profile)
Status: No Feedback Package: *Directory/Filesystem functions
PHP Version: 5.4.5 x64 OS: Windows 64 Bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mhhechanova at gmail dot com
New email:
PHP Version: OS:

 

 [2013-06-07 07:36 UTC] mhhechanova at gmail dot com
Description:
------------
When using UNC path or share drive as a parameter for is_readable, the function 
returns FALSE even if the file exists

Test script:
---------------
<?php
  $isReadable = is_readable("\\\\servername\\sharename\\file.txt"); //returns false
  $fileExists = file_exists("\\\\servername\\sharename\\file.txt"); //returns true
?>

Expected result:
----------------
is_readable should return TRUE since the file exists.

Actual result:
--------------
is_readable returns FALSE

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-07 07:57 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2013-06-07 07:57 UTC] pajoye@php.net
Are all parts of the path readable or with the access properties option set?
 [2013-06-07 08:00 UTC] mhhechanova at gmail dot com
-Status: Feedback +Status: Open
 [2013-06-07 08:00 UTC] mhhechanova at gmail dot com
Yes...in fact when using file_exists it returns TRUE
 [2013-06-07 08:38 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2013-06-07 08:38 UTC] pajoye@php.net
That was not my question :)

to see if something is readable, every part of the path is checked and for that we 
need the ability to read the property of each part. If one path does not have it, 
the operation will fail.
 [2013-06-07 08:39 UTC] pajoye@php.net
This is a permission option, you can check it either using the command line tool 
or via the property dialog > security.
 [2013-06-07 08:42 UTC] mhhechanova at gmail dot com
-Status: Feedback +Status: Open
 [2013-06-07 08:42 UTC] mhhechanova at gmail dot com
Yes its readable...Apache runs using Administrator account.
 [2013-06-07 09:09 UTC] pajoye@php.net
-Assigned To: +Assigned To: ab
 [2013-06-07 09:10 UTC] pajoye@php.net
@ab can you try to repro it pls?
 [2013-06-07 09:30 UTC] mhhechanova at gmail dot com
For reference please see the code below :

****Apache runs as Administrator Account

<?php
  $isReadable = is_readable("\\\\servername\\sharename\\file.txt"); //returns false
  $fileExists = file_exists("\\\\servername\\sharename\\file.txt"); //returns true
?>
 [2013-06-07 10:23 UTC] ab@php.net
I can reproduce the behaviour only if i set the file itself non readable to the 
user i'm under or everyone. Whereby the fact running something as administrator 
reveals nothing - in case administrator or everyone is denied on that path, here 
you are. This is most likely a file permission issue on your share.

Please post the output of the following commando on the file/share you have an 
issue with

icacls \\servername\sharename\file.txt
icacls \\servername\sharename
 [2013-06-10 01:02 UTC] mhhechanova at gmail dot com
@ab, here the result when issuing the command

icacls \\servername\sharename\file.txt ---> (I)(F)
icacls \\servername\sharename ---> (I)(OI)(CI)(F)
 [2013-06-10 07:53 UTC] ab@php.net
-Status: Assigned +Status: Feedback
 [2013-06-10 07:53 UTC] ab@php.net
Ok, despite it's not the complete output, from what I see there is an inheritance. That 
means if there was a deny in any superior object, it will override any allow on that file. 
Please try the following:

icacls /inheritance:r <path to file>
icacls <path to file> /remove:d <my suer>
icacls <path to file> /grant <my user>:(F,M,R,RX,W)

This way you disable inheritance and ensure the user has all the ACLs set. You can play 
with setting removing various ACLs to see the effect. Please consult you network admin.
 [2013-06-11 10:46 UTC] ab@php.net
ping?
 [2013-06-11 10:47 UTC] mhhechanova at gmail dot com
-Status: Feedback +Status: Assigned
 [2013-06-11 10:47 UTC] mhhechanova at gmail dot com
Administrator account has read, write and execute permission to the given path. It 
still does not work...

thanks
 [2013-06-11 11:06 UTC] ab@php.net
-Status: Assigned +Status: Feedback
 [2013-06-11 11:06 UTC] ab@php.net
Could you please check via the gui, properties->security->advanced, if the user 
has the right to 'read attributes' and 'read extended attributes'? If it's not 
set, please do set and try again. That permission must be set on every path 
element.
 [2013-06-11 11:10 UTC] mhhechanova at gmail dot com
-Status: Feedback +Status: Assigned
 [2013-06-11 11:10 UTC] mhhechanova at gmail dot com
Administrator account has full control.
 [2013-06-11 11:31 UTC] ab@php.net
-Status: Assigned +Status: Feedback
 [2013-06-11 11:31 UTC] ab@php.net
What happens if you try to access a share on \\127.0.0.1 ?
 [2013-06-11 23:58 UTC] mhhechanova at gmail dot com
-Status: Feedback +Status: Assigned
 [2013-06-11 23:58 UTC] mhhechanova at gmail dot com
@ab, 

after executing this command :

** What happens if you try to access a share on \\127.0.0.1 ?

 - A new explorer window opens, displaying the shared folder on my local 
machine.

Thanks
 [2013-06-12 06:47 UTC] ab@php.net
-Status: Assigned +Status: Feedback
 [2013-06-12 06:47 UTC] ab@php.net
Hi,

with \\127.0.0.1 i didn't mean explorer. Just create some test share like 
\\127.0.0.1\test\test.txt and try your PHP snippet. 

With 'full control' - as it might be different, again - are the checkboxes 'read 
attributes' and 'read extended attributes' explicitly active on that file?

Thanks.
 [2013-06-12 06:54 UTC] mhhechanova at gmail dot com
-Status: Feedback +Status: Assigned
 [2013-06-12 06:54 UTC] mhhechanova at gmail dot com
is_readable("\\\\127.0.0.1\\test\\test.txt"); //returns TRUE

However is_readable("\\\\servername\\sharename\\file.txt"); still returns FALSE

***ALL PERMISSIONS to that folder is set to ALLOW
 [2013-06-12 07:43 UTC] pajoye@php.net
-Status: Assigned +Status: Feedback
 [2013-06-12 07:43 UTC] pajoye@php.net
we can't reproduce it in our (numerous) environment.

We have now two ways to solve this issue:

- provide access to the host+client so we can debug

- give us the exact versions of the windows client and server so we can try using 
the same configurations in our lab
 [2013-06-12 07:49 UTC] mhhechanova at gmail dot com
-Status: Feedback +Status: Assigned -PHP Version: 5.3.26 +PHP Version: 5.4.5 x64
 [2013-06-12 07:49 UTC] mhhechanova at gmail dot com
@pajoye,

thank you for taking time to resolve this issue, however our development server 
is not connected to the internet.

As a reference, here's the server's configuration :

- Windows Storage Server 2008 R2 Standard
- PHP 5.4.5 x64 thread safe
- Apache 2.2.19 x64
- MySQL 5.6.11 x64

Thanks and regard,

Mo
 [2013-06-17 06:53 UTC] ab@php.net
-Status: Assigned +Status: Feedback
 [2013-06-17 06:53 UTC] ab@php.net
Tested again with Win7, Server 2008 and winxp. No reproduce though. Creating files  
locally on the target server, sharing - and it works. 

As we cannot debug on your server, lets do another try. The same as you were 
accessing a share on \\127.0.0.1, please create a test share on the target server,  
create a file and share it with administrator. You could even try to create that 
file from the source machine. Then try with your PHP snippet.
 [2013-06-24 06:40 UTC] ab@php.net
-Status: Feedback +Status: No Feedback
 [2013-06-24 06:40 UTC] ab@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 "Re-Opened". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC