Hi,
I just made a patch to "correctly" support special characters in scp
at
the remote side. First let me explain the problem:
# cd /tmp
# touch this is a test
# cp this\ is\ a\ test a\ test
# scp localhost:$PWD/a\ test this\ is\ a\ test
scp: /tmp/a: No such file or directory
scp: test: No such file or directory
but
# scp localhost:$PWD/a\\\ test this\ is\ a\ test
a test 100% 0 0.0KB/s 00:00
errror at defiant:/tmp> ls a\ test -l
-rw-rw-r-- 1 errror errror 0 2005-07-26 11:50 a test
So: As scp stringifies the remote side filename, ignoring special
characters like ' ', the remote side get the wrong arguments. The
correct way to go would be to redesign the scp client-server-protocol,
but this is not desired (see http://www.openssh.com/faq.html#2.10) and
would take years to reach all running server's implementations. A quiet
easier fix is, to "correctly" quote the filenames for the remote side.
Here an example with my patch scp client:
# scp -v localhost:$PWD/a\ test this\ is\ a\ test
Unquoted target: "/tmp/a test"
Quoted target = "/tmp/a\ test"
Executing: program /usr/bin/ssh host localhost, user (unspecified),
command scp -v -t /tmp/a\ test
a test 100% 0 0.0KB/s 00:00
I made the patch against the version of openssh I am currently running
on Linux Debian/sarge (openssh-3.8.1p1). It worked fine. For your
convenience, I also adopted the patch to the current cvs head version of
scp.c, but I did not test nor even compiled it.
I would be happy to see the functionality integrated in further
releases. Maybe this should be wrapped into an non-default option to
avoid incompatibility with existing setups.
So, what do you, the developers, think of my patch?
P.S.: Before I started developing the patch, I also noticed that the
sftp program has the same problems.
--
Patrick Cernko | mailto:errror at errror.org | http://www.errror.org
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: openssh_3.8.1p1-scpclient_with_correct_filename_quoting.diff
Url:
http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20050726/d1ff975f/attachment.ksh
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: openssh_cvshead-scpclient_with_correct_filename_quoting.diff
Url:
http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20050726/d1ff975f/attachment-0001.ksh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 257 bytes
Desc: OpenPGP digital signature
Url :
http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20050726/d1ff975f/attachment.bin