php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50659 Junctions over a share fail
Submitted: 2010-01-04 17:55 UTC Modified: 2021-10-24 04:22 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: RQuadling at GMail dot com Assigned: cmb (profile)
Status: No Feedback Package: Directory function related
PHP Version: 5.3SVN-2010-01-04 (snap) OS: win32 only - Windows XP SP3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-01-04 17:55 UTC] RQuadling at GMail dot com
Description:
------------
realpath() returns false for files inside junctions inside a share 
accessed using a relative path.

Ok. I _did_ say this was an edge case.

The code below is an batch script utilising Windows NET SHARE and NET 
MAP commands to create a drive J: mapped to C:\RAQ_Share and the 
JUNCTION program from System Internals to create a junction in that 
share. 

The last few lines relate specifically to PHP.

Essentially absolute paths are realpath()-able just fine, but relative 
paths are not.





Reproduce code:
---------------
@ECHO OFF
ECHO Create Original directory and file.
MD C:\RAQ_Orig
ECHO This is the file. > C:\RAQ_Orig\File.txt
ECHO.

ECHO Create share
MD C:\RAQ_Share
NET SHARE RAQ_Shared=C:\RAQ_Share /UNLIMITED
ECHO.

ECHO Map share
@NET USE J: /D > NUL
NET USE J: \\%COMPUTERNAME%\RAQ_Shared
ECHO.

ECHO Create junction
MD J:\RAQ_Junc
JUNCTION J:\RAQ_Junc C:\RAQ_Orig
ECHO.

ECHO Show the folders.
DIR \RAQ*
ECHO.

ECHO See contents of junction
DIR J:\RAQ_Junc\File.txt
ECHO.

ECHO Use PHP to report realpaths
PHP -v
PHP -n -r "var_dump(realpath('J:/RAQ_Junc/File.txt'));"
CD /D J:\
PHP -n -r "var_dump(realpath('/RAQ_Junc/File.txt'));"
CD \RAQ_Junc
PHP -n -r "var_dump(realpath('./File.txt'));"


Expected result:
----------------
Create Original directory and file.

Create share
RAQ_Shared was shared successfully.


Drop and map share
J: was deleted successfully.

The command completed successfully.


Create junction

Junction v1.05 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2007 Mark Russinovich
Systems Internals - http://www.sysinternals.com

Created: J:\RAQ_Junc
Targetted at: C:\RAQ_Orig

Show the folders.
 Volume in drive C has no label.
 Volume Serial Number is 1044-5992

 Directory of C:\

2010/01/04  17:47    <DIR>          RAQ_Orig
2010/01/04  17:47    <DIR>          RAQ_Share
               0 File(s)              0 bytes
               2 Dir(s)  11,663,155,200 bytes free

See contents of junction
 Volume in drive J has no label.
 Volume Serial Number is 1044-5992

 Directory of J:\RAQ_Junc

2010/01/04  17:47                20 File.txt
               1 File(s)             20 bytes
               0 Dir(s)  11,663,155,200 bytes free

Use PHP to report realpaths
PHP 5.3.3-dev (cli) (built: Jan  4 2010 12:59:42)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
string(20) "C:\RAQ_Orig\File.txt"
string(20) "C:\RAQ_Orig\File.txt"
string(20) "C:\RAQ_Orig\File.txt"


Actual result:
--------------
Create Original directory and file.

Create share
RAQ_Shared was shared successfully.


Drop and map share
J: was deleted successfully.

The command completed successfully.


Create junction

Junction v1.05 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2007 Mark Russinovich
Systems Internals - http://www.sysinternals.com

Created: J:\RAQ_Junc
Targetted at: C:\RAQ_Orig

Show the folders.
 Volume in drive C has no label.
 Volume Serial Number is 1044-5992

 Directory of C:\

2010/01/04  17:47    <DIR>          RAQ_Orig
2010/01/04  17:47    <DIR>          RAQ_Share
               0 File(s)              0 bytes
               2 Dir(s)  11,663,155,200 bytes free

See contents of junction
 Volume in drive J has no label.
 Volume Serial Number is 1044-5992

 Directory of J:\RAQ_Junc

2010/01/04  17:47                20 File.txt
               1 File(s)             20 bytes
               0 Dir(s)  11,663,155,200 bytes free

Use PHP to report realpaths
PHP 5.3.3-dev (cli) (built: Jan  4 2010 12:59:42)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
string(20) "C:\RAQ_Orig\File.txt"
string(20) "C:\RAQ_Orig\File.txt"
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-10-15 11:30 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-10-15 11:30 UTC] cmb@php.net
> Essentially absolute paths are realpath()-able just fine, but
> relative paths are not.

This appears to have been resolved in the meantime, or do you
still experience this with any of the actively supported PHP
versions[1]?

BTW, the following part of the reproducer doesn't look right:

    MD J:\RAQ_Junc
    JUNCTION J:\RAQ_Junc C:\RAQ_Orig

I don't think it's possible to convert an existing folder to a
junction; I went without the MD.

[1] <https://www.php.net/supported-versions.php>
 [2021-10-24 04:22 UTC] php-bugs at lists dot php dot 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-2022 The PHP Group
All rights reserved.
Last updated: Tue May 17 18:05:45 2022 UTC