php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20423 relative symlink are not correctly created
Submitted: 2002-11-14 04:27 UTC Modified: 2002-11-14 10:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: d dot roche at lectra dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4CVS-2002-11-14 OS: Linux 2.4.x
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: d dot roche at lectra dot com
New email:
PHP Version: OS:

 

 [2002-11-14 04:27 UTC] d dot roche at lectra dot com
try this little script :

<script language="php">
chdir("/tmp");
@unlink("/tmp/foo2.txt");
symlink("../foo.txt", "/tmp/foo2.txt");
</script>

it create on /tmp the following link : 
foo2.txt -> /foo.txt

while it should have created ( as previous versions does ) 
foo2.txt -> ../foo.txt

looks like relative path are resolved before making the link
thus it is no longer possible to create relative links !

my configure line is : 
./configure  --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --with-config-file-path=/etc --enable-force-cgi-redirect --disable-debug --enable-pic --disable-rpath --enable-inline-optimization --with-bz2 --with-db3 --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --with-gd --enable-gd-native-ttf --with-ttf --with-gdbm --with-gettext --with-jpeg-dir=/usr --with-openssl --with-png --with-regex=system --with-xml --with-zlib --with-layout=GNU --enable-debugger --enable-ftp --enable-magic-quotes --enable-safe-mode --enable-sockets --enable-sysvsem --enable-sysvshm --enable-discard-path --enable-track-vars --enable-trans-sid --enable-yp --enable-wddx --with-oci8=shared --with-oracle=shared --with-imap=shared --with-imap-ssl --with-kerberos=/usr/kerberos --with-ldap=shared --with-mysql=shared,/usr --enable-shmop --enable-versioning --enable-calendar --enable-dbx --enable-dio --enable-mcal --enable-mbstring --enable-mbstr-enc-trans --with-apxs=/usr/sbin/apxs



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-14 08:39 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The symlink ends up pointing to the same file, not a bug.
If have 'foo2.txt -> ../foo.txt' and you do cat /tmp/foo2.txt the filesystem will resolve it to /foo.txt anyway. 
 [2002-11-14 09:03 UTC] d dot roche at lectra dot com
I do not agree with you, 
It is a bug and a very serious one !

I want to create my symlink with a relative path
in order to be able to move then with the rest of my file 
tree , i do not want PHP to silently resolv the path !

previous version of PHP do not behave like this !

my application does not run with this version of PHP because
of this problem, it is not possible with this version
to create relative symlinks !!!!
 [2002-11-14 09:14 UTC] d dot roche at lectra dot com
to be more precise,  the two links points to te same file
only if you are in the same directory than the link
which may be not the case !

Anyway , PHP do not have to interpret the relative path
i give to transform it in an absolute path !
 [2002-11-14 09:21 UTC] iliaa@php.net
You are wrong.
Ex:
cd /tmp;
echo "TEST DATA" > /my/home/file.txt;
ln -s ../my/home/file.txt test_link.txt;
ls -lia test_link.txt;
{ test_link -> ../my/home/file.txt }
cd /some/dir;
cat /tmp/test_link;
{ TEST DATA }
 [2002-11-14 09:41 UTC] d dot roche at lectra dot com
> ln -s ../my/home/file.txt test_link.txt;
> ls -lia test_link.txt;
> { test_link -> ../my/home/file.txt }

what you say is right , but IT IS NOT POSSIBLE
to create such a link with the last PHP version

in your example , the link created by php will be :
test_link -> /my/home/file.txt

i do not want the ../ to disapear even if it points to 
the same location !

what i say is not that the link is broken, but the link
is no longer relative, i can not move it , or i cannot 
create it from anywhere !
 [2002-11-14 10:21 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 15:01:29 2024 UTC