|
2016-12-16
| ||
| 10:24 | • Closed ticket [534026d188]: interpreter initialization, auto_path, [info nameofe... artifact: bc8f281188 user: jan.nijtmans | |
| 02:51 | • Ticket [534026d188]: 4 changes artifact: f989c0f96d user: pooryorick | |
|
2016-12-15
| ||
| 10:16 | • Pending ticket [534026d188]. artifact: f7e67f5814 user: jan.nijtmans | |
| 05:24 | • New ticket [534026d188]. artifact: 6bb0b924b1 user: pooryorick | |
interpreter initialization, auto_path, [info nameofexecutable], and symbolic links
set Dir [file join [file dirname [file dirname \
[info nameofexecutable]]] lib]
[info nameofexecutable] returns the full path of the executable
but doesn't normalize symbolic links. If a symbolic link to the tclsh
executable is made in some other directory , the interpreter invoked by the
symbolic link, $Dir will contain a different value based on the
location of the symbolic link. This could result in some surprises at runtime.
If the script were changed to something like the following, the executable
would always pick up the lib directory that actually resides next to the tclsh
executable:
set Dir [file join [file dirname [file dirname \
[file dirname [file normalize [info nameofexecutable]/...]]]] lib]
Well, looking at the complete code [http://core.tcl.tk/tcl/artifact/13b6f382159e4d5b?ln=50-59], $auto_path is already initialized using the content of $tcl_library and its parent, which - if everything is OK - already contains something like /usr/lib/tcl8.? and /usr/lib. So, your proposal wouldn't make any change for Tcl startup, usually (it might make a difference in the search for additional packages). The place where $tcl_library is determined is here: [http://core.tcl.tk/tcl/artifact/1b7fac712ad43c21?ln=390-438], maybe you meant to make a change there. However, the Tcl initialization is tricky stuff (unfortunately), extra care is necessary for any change in that. Any change needs to be argumented and TIP'ed, otherwise it is asking for trouble. Therefor I am inclined to reject this issue .. ;-) Sorry.
Yes, the script hard-coded into Tcl_Init() is also fails to resolve symbolic links, and so has the same issue. Even though this issue has already been rejected, I'd like so summarize it: tclsh will potentially find a different set of libraries depending on which symbolic link it is invoked through. I argue that it's a bug that doesn't need to be TIP'ed, because on *nix systems it is common to create symbolic links for convenience, and it is not expected that simply creating a symbolic link to an executable will change the search path for dependencies. It's hard to imagine anyone legitimately relying on this behaviour. There are plenty of documented security vulnerabilities that arose from behaviour just like this.
@pooryorick, Feel free to submit a patch (to both tclInterp.c and init.tcl, I assume) which fixes the 'bug'. I have no problem to adding additional paths to the search mechanism, that itself doesn't need a TIP. However, if this really is a security issue, then please point that out with a more concrete example! (and ... of course ... make sure that your patch fixes this 'bug'. Maybe for Tcl 9.0, the number of paths to be searched for init.tcl should be reduced for security reasons. Whether this is done through a TIP or not is not so important, I am prepared and happy to listen to arguments. However, this 'bug' report as it is now is not enough to convince me. ;-) You can always re-open this issue, whenever you have additional information.