Subject: | get() has trouble with directories |
Hi there,
I'm running Net::SFTP 0.09 on perl v5.8.2(i386-freebsd) with FreeBSD 4.10-RELEASE. Before I begin, kudos on a very well-documented module. I especially appreciate the sample client you've included.
I've noticed that get() has problems with being asked to download directories:
-bash-2.05b$ perl psftp exile
Connecting to exile...
Remote working directory: /home/alambert
Show quoted text
sftp> get /etc
Downloading /etc to etc
Show quoted textsftp> exit
-bash-2.05b$ ls -al etc
-rwxr-xr-x 1 alambert alambert 0 Jun 12 20:49 etc
I tried the same with OpenSSH's sftp client; it returns an error message:
-bash-2.05b$ sftp exile
Connecting to exile...
Show quoted textsftp> get /etc
Fetching /etc to etc
Cannot download a directory: /etc
Show quoted textsftp> exit
In the latest versions of OpenSSH, it refuses to transfer any non-regular file. The check is trivial; here is the code that the OpenSSH client uses:
regular files only: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/sftp-client.c.diff?r1=1.40&r2=1.41&f=h
no directories (earlier): http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/sftp-client.c.diff?r1=1.13&r2=1.14&f=h
I looked at the Net::SFTP code and get() already does a stat(), which makes the necessary changes even easier. The Fnctl module provides the S_ISREG function that OpenSSH uses. A similar patch may be applied to put().
Thanks again.
Alex Lambert
alambert at quickfire dot org