Created attachment 1846 [details] set targetshouldbedirectory if there are two file arguments and argv[1] ends with a slash Sami Haahtinen reported the following bug as https://bugs.launchpad.net/bugs/18757: It appears that scp gets confused if one tries to copy a file in to a missing directory: % pwd /tmp/test % touch foo % ls foo % scp foo localhost:/tmp/test/not-a-dir/ user@localhost's password: scp: /tmp/test/not-a-dir/: Is a directory % scp foo localhost:/tmp/test/not-a-dir user@localhost's password: foo 100% 0 0.0KB/s 00:00 % ls foo not-a-dir % above, the error in question should be "Directory does not exist" instead of "Is a directory" This seems quite straightforward to fix without causing any compatibility problems: the scp client already passes -d to the server side if it knows that the target should be a directory because there are more than two file arguments, so it could test for a trailing slash in the same way. Patch attached.
Hello. This bug still exists today. A friend of mine and I were confused and motivated enough to fix it ourselves and/or seek out this bug (or one of it's duplicates at https://bugs.launchpad.net/bugs/18757 or https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473137 or https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=152909 or https://bugzilla.redhat.com/show_bug.cgi?id=1142223). I'm new to contributing to open source in general and I'm genuinely curious: How can I help get this resolved? It seems like a bug, that negatively affects people, with a simple solution.
Created attachment 2523 [details] patch to improve error message Hi, I ran into this problem in RHBZ#1142223 [1] and tried to solve it. After some time of digging in the source code I came up with solution which I introduce here as a attachment. This added condition covers only this one problematic case and according to regression test cases published in portable tarbal, shouldn't bring here any regression. Also I managed to write test case covering this problem. This file will be attached as the second file. Also I would like to say that the previous patch doesn't work, because it will break recursive scp, for example: > scp -r dir/ host:new_dir/ which is completely valid even if the new_dir doesn't exist. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1142223
Created attachment 2524 [details] patch to verify this problem in regress test suite
Created attachment 2526 [details] Patch revised