Bug #72738 [Opn->Ver]: realpath() expands junction points

From: Date: Tue, 02 Aug 2016 22:30:00 +0000
Subject: Bug #72738 [Opn->Ver]: realpath() expands junction points
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202846@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72738&edit=1

 ID:                 72738
 Updated by:         cmb@php.net
 Reported by:        anrdaemon at freemail dot ru
 Summary:            realpath() expands junction points
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Windows
 PHP Version:        7.1.0beta1
 Block user comment: N
 Private report:     N

 New Comment:

I can confirm this behavior. Obviously, the invariant

  realpath(realpath($x)) == realpath($x)

does not hold in this case.


Previous Comments:
------------------------------------------------------------------------
[2016-08-02 19:31:28] anrdaemon at freemail dot ru

Description:
------------
On Windows, realpath() expands the directory junction points.
According to an apparently authoritative assesment of pajoye@php.net in the https://bugs.php.net/bug.php?id=72642 , this
shouldn't happen.

Test script:
---------------
<?php

$rootdir = substr(getenv('SystemRoot'), 0, 3);
$tmpdir = getenv('TEMP');
shell_exec("mklink /J \"{$rootdir}home\" \"{$rootdir}Users\"");
shell_exec("mklink /J \"{$tmpdir}\\test.dir\"
\"{$rootdir}home\\Public\\Desktop\"");
$file = "{$tmpdir}\\test.dir\\desktop.ini";
$rfile1 = realpath($file);
$rfile2 = realpath($rfile1);
printf("orig.file name: %s\n", $file);
printf("realpath(name): %s (%s)\n", $rfile1, $file == $rfile1 ? 'Ok' :
'fail');
printf("THE real name:  %s (%s)\n", $rfile2, $file == $rfile2 ? 'Ok' :
'fail');

rmdir("{$rootdir}home");
rmdir("{$tmpdir}\\test.dir");


Expected result:
----------------
According to pajoye@php.net, expansion shouldn't happen, and all paths must be the same == the
original path.

Actual result:
--------------
All paths are different. On each iteration, realpath() only expands a portion of nested junctions.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72738&edit=1


Thread (3 messages)

« previous php.bugs (#202846) next »