Reputation: 16802
When you connect with WinSCP to a directory that contains a symlink it'll show you that it's a symlink by using a slightly different icon. eg. instead of just a folder it'll be a folder with an arrow or some such.
My question is... how does WinSCP know that the symlink is a symlink to a folder?
When you SFTP into a directory the client sends a SSH_FXP_READDIR
packet. The server responds with a SSH_FXP_NAME
packet. In my testing it seems that the data in this packet corresponds to lstat - not stat. ie. if you AND the permissions attribute with 1111 0000 0000 0000
you get 1010 0000 0000 0000
(symlink) instead of 0100 0000 0000 0000
(directory).
My guess is that WinSCP then sends out a SSH_FXP_STAT
for each of these symlinks but maybe it's doing SSH_FXP_READLINK
instead. If the latter the server would respond with SSH_FXP_NAME
- if the former the server would respond with SSH_FXP_ATTRS
(which is pretty much an SSH_FXP_NAME
for just one file instead of x files). But then again, maybe it's doing something else entirely.
Remembering that WinSCP uses PuTTY I tried to see which one it was doing by creating a session with PuTTY that had "Session logging" set to "SSH packets". I then tried to connect to that session with WinSCP but no putty.log file was created. I didn't see it in the directory where I had initially ran PuTTY to update the session nor did I see it in C:\Program Files (x86)\WinSCP
. So I have no idea where it is.
Any ideas?
Upvotes: 0
Views: 1261
Reputation: 202494
WinSCP sends both SSH_FXP_STAT
and SSH_FXP_READLINK
.
The SSH_FXP_STAT
to find out, if the symlink points to a file or a directory.
The SSH_FXP_READLINK
to find out link target.
See WinSCP log:
. 2015-07-20 11:00:15.837 Listing directory "...".
> 2015-07-20 11:00:15.837 Type: SSH_FXP_OPENDIR, Size: 53, Number: 11275
< 2015-07-20 11:00:15.894 Type: SSH_FXP_HANDLE, Size: 13, Number: 11275
> 2015-07-20 11:00:15.894 Type: SSH_FXP_READDIR, Size: 13, Number: 11532
< 2015-07-20 11:00:15.950 Type: SSH_FXP_NAME, Size: 431, Number: 11532
> 2015-07-20 11:00:15.950 Type: SSH_FXP_READDIR, Size: 13, Number: 11788
. 2015-07-20 11:00:15.950 Reading symlink "link".
> 2015-07-20 11:00:15.950 Type: SSH_FXP_READLINK, Size: 58, Number: 12051
> 2015-07-20 11:00:15.950 Type: SSH_FXP_STAT, Size: 58, Number: 12305
< 2015-07-20 11:00:16.005 Type: SSH_FXP_STATUS, Size: 28, Number: 11788
. 2015-07-20 11:00:16.005 Storing reserved response
< 2015-07-20 11:00:16.062 Type: SSH_FXP_NAME, Size: 41, Number: 12051
. 2015-07-20 11:00:16.062 Link resolved to "target.txt".
< 2015-07-20 11:00:16.062 Type: SSH_FXP_ATTRS, Size: 37, Number: 12305
< 2015-07-20 11:00:16.063 Status code: 1
> 2015-07-20 11:00:16.063 Type: SSH_FXP_CLOSE, Size: 13, Number: 12548
Upvotes: 1