Ticket UUID: | 849514 | |||
Title: | Absolute pathnames with ../ and links | |||
Type: | Bug | Version: | obsolete: 8.4.5 | |
Submitter: | vulpeculus | Created on: | 2003-11-26 09:07:49 | |
Subsystem: | 36. Pathname Management | Assigned To: | vincentdarley | |
Priority: | 7 High | Severity: | ||
Status: | Open | Last Modified: | 2004-12-03 01:18:26 | |
Resolution: | Fixed | Closed By: | hobbs | |
Closed on: | 2004-02-18 01:37:35 | |||
Description: |
This concerns Tcl on Unix (Solaris 8, Solaris 9, RH Linux Kernel 2.4.?): When trying to open a file (e.g. [open $filename r]) with an absolute pathname containing symbolic links and ../ (parent directory), a wrong file is referenced: e.g. if /home/somedir is a link to /root/otherdir then trying to open /home/somedir/../file opens /home/file instead of /root/file In Tcl 8.3.1 open worked as expected. The first Tcl version which I can test and has the problem is 8.4.1 | |||
User Comments: |
vincentdarley added on 2004-12-03 01:18:26:
Logged In: YES user_id=32170 I don't know if I agree with dgp's comment that each filesystem should have its own interpretation of '..'. Surely they should be the same? (At least that's what's in Tcl 8.5) dgp added on 2004-12-02 08:30:41: Logged In: YES user_id=80530 dropping priority since this can't be "fixed" until the differences of opinion about the correct design of the VFS layer laid out in 961646 are addressed. this won't be fixed in Tcl 8.4.9. dgp added on 2004-11-18 01:31:12: Logged In: YES user_id=80530 This matter is related to 961646. Both are rooted in the fact that Tcl's Tcl_Filesystem layer is imposing one interpretation of ".." in a path instead of leaving it up to each (native) filesystem to use its own preferences. hobbs added on 2004-02-18 09:04:21: Logged In: YES user_id=72656 had to revert because the changes were not properly isolated, and the 8.5 changes are a lot more spread out than expected. Don't know quite what to backport ... hobbs added on 2004-02-18 08:37:35: Logged In: YES user_id=72656 backported for 8.4.6. hobbs added on 2004-02-06 09:37:31: Logged In: YES user_id=72656 We will also need an 8.4-based patch. vincentdarley added on 2003-12-13 00:30:23: File Deleted - 70250: File Added - 70363: linknorm.diff Logged In: YES user_id=32170 Updated patch for cvs head. vincentdarley added on 2003-12-11 19:58:19: File Deleted - 70242: File Added - 70250: linknorm.diff Logged In: YES user_id=32170 Updated patch. Needs testing on unix, but should then be ready to go. Jeff: could you test this please? vincentdarley added on 2003-12-11 18:53:10: File Deleted - 70181: File Added - 70242: linknorm.diff vincentdarley added on 2003-12-11 00:35:47: File Added - 70181: linknorm.diff Logged In: YES user_id=32170 Please test the attached patch (to Tcl 8.5a0) vincentdarley added on 2003-12-10 19:32:43: Logged In: YES user_id=32170 The bug is quite clear now. TclFSNormalizeAbsolutePath removes all '.' and '..' sequences before passing the path to the platform-specific normalization code. But, the '..' removal is done in a purely string-based way, with no awareness of symlinks at all. We probably need to remove that whole block of code (lines 149-173 of tclPathObj.c) and make each platform-specific piece of code a bit cleverer. This might actually improve performance, since it would remove the need for a whole file split/file join pair in the current approach (but replace it with more complex platform-specific code). vincentdarley added on 2003-12-10 19:22:57: Logged In: YES user_id=32170 Here's a simple example on Windows: file mkdir tclfoo cd tclfoo file mkdir one/two/three file link link one/two/three file normalize link/../foo # The result: E:/tclfoo/foo # It should be: E:/tclfoo/one/two/foo vincentdarley added on 2003-12-10 19:17:38: Logged In: YES user_id=32170 This behaviour is all down to 'file normalize', so if this bug report is correct, you should be able to show that 'file normalize' returns the wrong path for some input strings containing ../ Can you please try to provide one or two examples? vulpeculus added on 2003-11-27 14:32:08: Logged In: YES user_id=917954 The bug IS still ion 8.4.5. What I wanted to say that it probably first occured between 8.3.1 and 8.4.1. In your example /home/dist is a link to /tmp/dist So /home/dist/../jeffh/.cshrc is /tmp/jeffh/.cshrc, not /home/jeffh/.cshrc (try it e.g. with ls in any shell). However, as long as you do not have a file /tmp/jeffh/.cshrc, the open command from your example should return an error "no such file or directory", instead of opening the wrong file. The same behaviour can also be found with a non-existing directory in your pathname: open /home/jeffh/nonexistentdir/../.cshrc fails in 8.3.1 (correct), but succeeds in 8.4.5 (incorrect) hobbs added on 2003-11-27 01:00:11: Logged In: YES user_id=72656 This works for me in 8.4.5 on linux: ln -s /tmp/dist /home/ tclsh % open /home/dist/../jeffh/.cshrc file4 So this should have been checked against the latest release before submitting. |
Attachments:
- linknorm.diff [download] added by vincentdarley on 2003-12-13 00:30:23. [details]