When mounting an ftp vfs and trying to change the
directory to a directory that is a symbolic link to
another directory, the cd fails.
When using the tcllib ftp package the directory can be
succesfully canged into.
To reproduce:
Install ActiveState Tcl 8.4.12
Create a symlink /test/bin -> /usr/bin
(test box is:
SunOS XXXX 5.8 Generic_108528-29 sun4u sparc SUNW,
UltraAX-i2 )
Execute the tcl script below results in the following
output:
-- stdout --
8.4.12
Changing dir to 0
drwxr-xr-x 2 root other 512 Feb 27 18:15 .
drwxr-xr-x 24 root root 1024 Feb 27 18:15
..
lrwxrwxrwx 1 root other 8 Feb 27 18:15
bin -> /usr/bin
Changing dir to 0
. .. bin
-- stderr --
couldn't change working directory to "bin": no such
file or directory
while executing
"cd bin"
(file "vfsftp-symlink.tcl" line 26)
----------
package require vfs::ftp
# /test/bin is symlink to /usr/bin
puts [info patchlevel]
set user XXX
set passwd XXX
set machine XXX
set conn [::ftp::Open $machine $user $passwd]
::ftp::Cd $conn /test
foreach line [::ftp::List $conn] {
puts $line
}
::ftp::Cd $conn bin
# cd completes succesfully
vfs::ftp::Mount ftp://$user:$passwd@$machine machine
cd machine/test/
puts [glob *]
cd bin
# cd fails
--------------
Logged In: YES
user_id=1463011
Bug logged by me
Logged In: YES
user_id=32170
Can you have a go at debugging what is going on in
ftpvfs.tcl and provide a patch to fix this?
Vince.
Logged In: YES
user_id=1463011
I did some more investigating and the problem seems to be
in the vfs::ftp::stat proc. This proc should return either
type = file or type = directory. For type = directory a cd
will succeed.
This means that a workaround for my problem is to change
the line:
if {[string index $perms 0] == "d" } {
to:
if {[string index $perms 0] == "d" || [string index
$perms 0] == "l"} {
This way all symlinks will be handled as directories and
the script will succeeds. However symlinks to files will
now behave like directories instead.
So the best solution will be to adapt vfs::ftp::stat to
follow symlinks to determine if a name is a file or
directory. This can be a tricky exercise using ftp
commands. I am not familiar enough with the VFS to
determine if there is a cleaner solution to this.