Bug #73884 [Com]: is_dir() returns false for junction / symlinkd

From: Date: Sat, 07 Jan 2017 20:19:57 +0000
Subject: Bug #73884 [Com]: is_dir() returns false for junction / symlinkd
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206361@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73884&edit=1 ID: 73884 Comment by: kulakov74 at yandex dot ru Reported by: kulakov74 at yandex dot ru Summary: is_dir() returns false for junction / symlinkd Status: Open Type: Bug Package: Filesystem function related Operating System: Windows 8.1 PHP Version: 7.1.0 Block user comment: N Private report: N New Comment: Note that readlink() returns an error for "c:\Users\Default User\": Warning: readlink(): readlink failed to read the symbolic link (C:\Users\Default User), error 5) I must add that the "Default User" junction does have a Deny rule for everyone to list folder/read data, but in practice it has no effect (if you use any other tool but PHP). After I removed it, both is_dir() and readlink() produced correct results. So it looks like PHP checks the permissions, finds the Deny rule and uses some wrong logic to conclude it has no right to access the link. BUT I have another junction also created by me before (not for tests) c:\Users\Sergei\ pointing to C:\Users\Серёжка (my name in Russian) and it doesn't have the deny rule, while it has full control for myself, AND is_dir() returns false for it (wrong!), while readlink() returns the right target. So there's some other kind of bug with is_dir(). Previous Comments: ------------------------------------------------------------------------ [2017-01-07 19:37:35] kulakov74 at yandex dot ru For tests, I tried "Default User", it was owned by System and had a right to read/execute for everyone. After I took over ownership and removed the right, I could not "enter" it and Dir stopped displaying its target (just showed "[..]"). is_dir() still returned false, which is actully not correct because if it has no way to know and check the target, it can't know if it's a dir or not, no error message displayed either. I readded the right to read/execute for everyone and everything works as it did before. The junction I created myself (templink) has "read & execute" right for "Users", not for everyone. Also it has Modify permission for Authenticated users. I added both to "Default User" but it didn't help. "Default User" also had "hs" attributes (hidden and system), but after I cleared them nothing changed. The only difference left is that "Default User" has the permissions added to it directly while templink inherits them from C:\. I disabled inheritance for templink but is_dir() still worked for it. Still, I could make is_dir() return false for templink by removing all rights. So, this could be related with permissions, but I couldn't prove it, and even if I did, php does smth wrong cause it shouldn't cause problems. ------------------------------------------------------------------------ [2017-01-06 21:41:54] ab@php.net Thanks for the report. Might be good a permission issue, yep. Would you mind to investigate more on it, maybe checking what difference the extended permissions tell, etc.? Thanks. ------------------------------------------------------------------------ [2017-01-06 20:12:44] kulakov74 at yandex dot ru Description: ------------ On my Windows PC, I scanned the whole directory structure in C:\ (both from browsers and in CLI mode) and found out that for all of the junctions / symlinks that had been created by the system is_dir() returns false. According to the manual, "If filename is a symbolic or hard link then the link will be resolved and checked." but this is only the case with the junctions / symlinks I created manually for testing. It might seem the problem is with permissions but I run the script as admin and also I can see the fact that the items in question are junctions by using plain console (cmd.exe) even not as admin, for ex.: c:\Users>dir /a:l ... 22.08.2013 17:45 <SYMLINKD> All Users [C:\ProgramData] 22.08.2013 17:45 <JUNCTION> Default User [C:\Users\Default] ... BTW, In Windows, junctions and symlinks are almost the same. Test script: --------------- $Dir="C:\Users\All Users"; if (is_dir($Dir)) echo("dir"); else echo("not a dir"); Expected result: ---------------- dir Actual result: -------------- not a dir ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73884&edit=1

« previous php.bugs (#206361) next »