Ubuntu

scp gets confused when destination directory is missing.

Reported by Sami Haahtinen on 2005-07-07
32
This bug affects 5 people
Affects Status Importance Assigned to Milestone
portable OpenSSH
Unknown
Unknown
openssh (Ubuntu)
Low
Unassigned

Bug Description

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"

Ante Karamatić (ivoks) wrote :

Hm... Or it tells you can't copy a file and make it a directory?

Colin Watson (cjwatson) wrote :

In this case it's what you get if you try to create a nonexistent directory
(with trailing slash) using open(), as the following short C program demonstrates:

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>

int main(int argc, char **argv)
{
    int fd = open("nonexistent/", O_WRONLY | O_CREAT);
    if (fd < 0) {
        perror("open");
        return 1;
    }
    close(fd);
    return 0;
}

scp probably ought to be a little bit more careful; calling verifydir() when the
target ends in '/' would do it, I think. Still, it's minor.

Sami Haahtinen (ressu) wrote :

True, this is a cosmetic bug, but it's still confusing. It got be confused for a
while there until i figured out that i had mistyped bug/ as bugs/.

Colin Watson (cjwatson) on 2007-04-20
Changed in openssh:
assignee: kamion → nobody
Rick Clark (dendrobates) wrote :

confirmed in gutsy. This is minor, but we should push it upstream.

Changed in openssh:
status: New → Triaged
Isaac Henry (isaachenry) wrote :

Still seeing this in gutsy 32bit. This can be pretty confusing/frustrating. I was trying to copy to a user directory that didn't exist. I spent about 15 min trying to figure this out (and I use linux everyday). Small things like this could be super frustrating for a newish user who wasn't sure if they were doing things correctly.

Changed in openssh:
assignee: nobody → nxvl
Changed in openssh:
assignee: nxvl → nobody
Colin Watson (cjwatson) wrote :

I've forwarded this bug upstream and attached a patch there.

Łukasz Zaroda (lukenuke) wrote :

This bug is still here on 12.04 Precise Pangolin. It's quite annoying.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.