Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: scp/sftp -R broken?

On Tue, 6 Jun 2023, Michael van Elst wrote:

When I try to recursively copy a directory with "scp -r" or sftp's
"put -Rp" between a -current and a NetBSD 9, I see:

# scp -r a netbsd-9:
scp: realpath ./a: No such file
scp: upload "./a": path canonicalization failed
scp: failed to upload directory a to .

That was a known issue with sftp when the target directory (in this
case that's netbsd-9:./a) does not exist and the OpenSSH 9 server
apparently has fixed it.

Yup, this is realpath() failing on a non-existent directory. In the
old sftp-server server (see process_realpath() in
src/crypto/external/bsd/openssh/dist/sftp-server.c), realpath() is
called directly, and this will fail when there are non-existent
components in the path to be resolved.

In the new sftp-server, a wrapper function `sftp_realpath()' which
allows the _last_ component to not exist is used instead (just like
what realpath(1) in 10.x does).

If you want to patch this, you can bring in the new sftp-realpath.c
file and call sftp_realpath() instead of the bare realpath().


Home | Main Index | Thread Index | Old Index