Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1142223

Summary: scp gives wrong errormessage: "Is a directory"
Product: [Fedora] Fedora Reporter: customercare
Component: opensshAssignee: Petr Lautrbach <plautrba>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 20CC: customercare, jjelen, jss, mattias.ellert, mgrepl, plautrba, tmraz
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openssh-6.4p1-8.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-03 12:02:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
[patch] to improve error message
none
[patch] to improve error message (second round)
none
dist git patch
none
dist git patch revised
none
Patch revised
none
dist git patch revised none

Description customercare 2014-09-16 12:05:30 UTC
Description of problem:

scp does say it's a directory, if a path does not exist at all. See below.

Version-Release number of selected component (if applicable):

OpenSSH_6.4p1, OpenSSL 1.0.1e-fips 11 Feb 2013

How reproducible:

always

Steps to Reproduce:

1. scp /tmp/conf_16.9.2014.tgz  root@s137:/usr/doesnotexist/


Actual results:

scp: /usr/doesnotexist/: Is a directory

Expected results:

scp: /usr/doesnotexist/: File o. Directory does not exist

Additional info:

Comment 1 Petr Lautrbach 2014-09-16 14:01:28 UTC
It works for me:

[root@fedora20 ~]# scp .bashrc localhost:/a/b/c
root@localhost's password: 
scp: /a/b/c: No such file or directory
[root@fedora20 ~]# rpm -q openssh
openssh-6.4p1-4.fc20.x86_64

Please provide more information.

Comment 2 customercare 2014-09-17 08:45:26 UTC
Situation:

on the server we have : 

/usr/java              which is a real directory
/java -> /usr/java     a link 

scp something to /usr/java/test/ gives "is a directory"

[marius@eve ~]$ scp /tmp/adb.log root@sXXX:/usr/java/test/
scp: /usr/java/test/: Is a directory
[marius@eve ~]$ ssh root@sXXX
Last login: Wed Sep 17 00:19:32 2014 from XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[root@sXXX ~]# ls -la /usr/
insgesamt 172
drwxr-xr-x.  14 root root  4096 16. Sep 21:47 .
dr-xr-xr-x.  20 root root  4096 16. Sep 21:34 ..
dr-xr-xr-x    2 root root 40960 17. Sep 04:03 bin
drwxr-xr-x    2 root root  4096 16. Sep 21:23 eximtools
drwxr-xr-x.   2 root root  4096  7. Aug 2013  games
drwxr-xr-x.  69 root root  4096 16. Sep 21:44 include
drwxr-xr-x    6 root root  4096 13. Jun 2012  java
dr-xr-xr-x  128 root root 69632 17. Sep 04:03 lib
drwxr-xr-x    3 root root  4096 12. Jan 2013  lib64
drwxr-xr-x.  24 root root  4096 17. Sep 04:03 libexec
drwxr-xr-x.  11 root root  4096  7. Aug 2013  local
drwxr-xr-x    2 root root 20480 17. Sep 04:03 sbin
drwxr-xr-x. 132 root root  4096 16. Sep 21:44 share
drwxr-xr-x.   5 root root  4096  7. Aug 2013  src
lrwxrwxrwx    1 root root    10 16. Sep 21:18 tmp -> ../var/tmp
[root@sXXX ~]# ls -la /usr/java/
insgesamt 24
drwxr-xr-x   3 root root 4096 13. Jun 2012  .
drwxr-xr-x. 14 root root 4096 16. Sep 21:47 ..
drwxr-xr-x   3 root root 4096 18. Feb 2012  webapps

Comment 3 customercare 2014-09-17 08:47:24 UTC
[root@sXXX ~]# rpm -qf /usr/sbin/sshd
openssh-server-6.4p1-5.fc20.i686

[marius@eve ~]$ rpm -qf /usr/bin/scp
openssh-clients-6.4p1-5.fc20.x86_64

Comment 4 Jakub Jelen 2015-01-06 16:37:20 UTC
Created attachment 976864 [details]
[patch] to improve error message

This problem is also in original openSSH and appears when you try to copy something into non-existing directory with existing parent directory.
There is missing check for this boundary condition.
Error message is thrown when scp process tries to write into above mentioned file, but this file ends with slash (which is interpretation for directory) and this is the reason for current error message.
Without understanding what is going on in there it is pretty confusing.

I came up with patch fixing this problem in both Fedora and upstream. It is only covering this one condition and resulting with better error message.
See attached patch.

Comment 5 Petr Lautrbach 2015-01-07 10:30:47 UTC
Thanks for the patch Jakub. Unfortunately, it breaks copying directories using '-r' option.

$ ls -l ~/tmp/bz1142223
total 4
-rw-rw-r--. 1 plautrba plautrba    0 Jan  7 10:10 a
drwxrwxr-x. 2 plautrba plautrba 4096 Jan  7 10:21 c

$ scp -r c  localhost:~/tmp/bz1142223/b/
scp: error: Target directory doesn't exist: /home/plautrba/tmp/bz1142223/b/

Comment 6 Jakub Jelen 2015-01-07 19:13:51 UTC
Created attachment 977512 [details]
[patch] to improve error message (second round)

Peter, thank you for your remark. I missed this use case of target directory creation. I have chosen more appropriate place for this fix.
Successfully verified with openssh unit tests.

Comment 7 Jakub Jelen 2015-01-12 09:14:01 UTC
Created attachment 979001 [details]
dist git patch

Comment 8 Jakub Jelen 2015-01-12 09:25:15 UTC
Created attachment 979003 [details]
dist git patch revised

Comment 9 Jakub Jelen 2015-01-12 16:31:38 UTC
Created attachment 979238 [details]
Patch revised

Comment 10 Jakub Jelen 2015-01-14 12:42:05 UTC
Created attachment 979977 [details]
dist git patch revised

Comment 11 Fedora Update System 2015-01-15 14:34:13 UTC
openssh-6.6.1p1-11.1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/openssh-6.6.1p1-11.1.fc21

Comment 12 Fedora Update System 2015-01-15 15:03:28 UTC
openssh-6.4p1-8.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/openssh-6.4p1-8.fc20

Comment 13 Fedora Update System 2015-01-17 05:40:02 UTC
Package openssh-6.4p1-8.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing openssh-6.4p1-8.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-0756/openssh-6.4p1-8.fc20
then log in and leave karma (feedback).

Comment 14 customercare 2015-01-17 12:10:33 UTC
Sat, 17 Jan 2015 13:08:51 +0100:

[marius@eve ~]$ sudo yum update --enablerepo=updates-testing openssh-6.4p1-8.fc20
Geladene Plugins: langpacks, refresh-packagekit
Kein Übereinstimmung für Argument: openssh-6.4p1-8.fc20
Kein Paket openssh-6.4p1-8.fc20 verfügbar.
No packages marked for update
[root@eve marius]# yum list --enablerepo=updates-testing openssh-6.4*
Geladene Plugins: langpacks, refresh-packagekit
Installierte Pakete  openssh.x86_64 6.4p1-7.fc20  @updates


makecache or cleaning the expire cache didn't help to find it.

Comment 15 customercare 2015-01-17 12:29:32 UTC
After downloading and installing packages from Koji:

# scp /tmp/screen.jpg root@localhost:/java/test/
scp: /java/test/: Not a directory

# ls -lad /java
lrwxrwxrwx. 1 root root 5 17. Jan 13:16 /java -> /tmp/
# ls -lad /java/test
ls: Zugriff auf /java/test nicht möglich: Datei oder Verzeichnis nicht gefunden


I know you guys put in a bit of efford into it, but shouldn't it be "Directory /java/test/ does not exist!" ? 

"Not a Directory" is in fact the same way wrong, as the original message was. It's neiter a file nor a directory nor is it a directory(original msg): 

it simply does not exist at all. 

It can not be so hard to make a check like this:

File file = new File("/java/test/");
if ( utils.treatAsADirectory(file.getFilePath()) && ! file.exists() ) disconnectWithError("Directory "+file+" does not exist!");

Comment 16 Fedora Update System 2015-01-17 23:55:29 UTC
openssh-6.6.1p1-11.1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 17 Jakub Jelen 2015-01-19 08:56:53 UTC
Hello customercare,
I tried my best to find a problem and solve it.

In my opinion, there is no difference between:
> Directory /java/test/ does not exist!
 and 
> /java/test/: Not a directory

It is the same message phrased in little bit different way. We are reusing system wide error message ENOTDIR converted to string using strerror()

When I compare it with previous message:
> /java/test/: Is a directory
I see some progress, because this meant complete opposite.

Patch is always welcome, so if you will come up with something better, we can discuss it further.

Comment 18 Fedora Update System 2015-02-03 12:02:29 UTC
openssh-6.4p1-8.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 19 John 2020-06-17 08:03:59 UTC
Unreal:

scp foreman-client.sles12.repo somehost://root/foreman/
blah blah
Password:
scp: //root/foreman/: Is a directory


I've got this on the source side:
openssh-7.4p1-21.el7.x86_64
And this on the destination side:
openssh-7.2p2-74.54.1.x86_64

AND STILL I HAD MY TIME WASTED BY THIS ERROR. AND I END UP HERE.,
And here: 
https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/18757
THAT BUG REPORT WAS FILED 15 YEARS AGO.

FIFTEEN YEARS AGO.

AND IT IS STILL NOT FIXED.

Comment 20 Jakub Jelen 2020-06-17 09:18:01 UTC
You are barking up the wrong tree. Bug is filled for 15 years in Debian (your link) and not fixed, for 10 years in OpenSSH Portable bugzilla (linked above), it has a patch for 5 years attached and it is fixed in Fedora for 5 years (and in RHEL8). Update.

Comment 21 John 2020-06-18 04:06:52 UTC
Jakub, sorry if I offended you. I should thank you, for actually fixing the bug.
But I am not barking up the wrong tree.
It is not fixed in EL7.

What i am angry about, is that this bug was reported 15 years ago.
15 years after a bug is reported, it should be fixed everywhere.
And yet, it still wasted my time the other day, in EL7

How can it not be fixed in EL7?

This bug report says it was fixed in: openssh-6.6.1p1
I am seeing the error on EL7 with:    openssh-7.4p1-21.el7.x86_64

How is this possible?

Comment 22 Jakub Jelen 2020-06-18 08:06:09 UTC
This is Fedora bug so it was fixed in Fedora.

RHEL7 is out of support and no future updates are expected now, unless they will be fixing critical security issues. Please, consult RHEL life cycle and your red hat support:

https://access.redhat.com/support/policy/updates/errata#Maintenance_Support_2_Phase

To question why this is not fixed in upstream, use upstream bug tracker, but openssh team is not eager to fix things in scp anymore:

https://bugzilla.mindrot.org/show_bug.cgi?id=1768

Comment 23 John 2020-06-18 08:46:56 UTC
If it was fixed in Fedora, it should have percolated into RHEL7.
That is the whole point of Fedora.

But it's not a fedora bug anyway, is it?
It's a bug in openssh.

So what is the point of fixing it in fedora and not fixing it upstream?
What is the point of that?

I could probably bet the life of my first-born son, that if i go and test for this bug in Fedora now, it is back.

And, you say, RHEL7 is out of support so it won't get fixed. What is the point of telling me that?
This bug was first reported 4 years before RHEL7.0 was released.
And your patches were released well-inside EL7's full-support phase.
And yet, this was never fixed in EL7.

Is that something Red Hat is proud of?

It's just so bloody disappointing.
This is what is wrong with the world, right here.

15 years. To fix an error message.
And it's not fixed.
Just incredible.

Comment 24 customercare 2020-06-18 09:10:14 UTC
Hi John,

i can anticipate your anger about this, but you need to know some things about Linux Distros in general to understand this.

Any distributor has it's own set of patches, because the upstream projects are partly unresponsive, have a hell lot a testing, very long lists a bugs to fix and therefor are unable to respond rapidly to minor problems like this bug. It does not explain, why it's not in RHEL7, if the bug is older, that's true. 

BTW: you should not bet on your sons life, as you would loose him:

F31 to F31:

$ scp 545\ -\ The\ Land\ That\ Time\ Forgot.txt root@sXXX:/tmp/x/
scp: /tmp/x/: Not a directory

Args.. that's not really better :D 

@Jacob.. isn't there a "does not exist" code or why was this exchange from one wrong-message to a not-so-wrong-wrong-message?

If i have seen it correctly in the bugreport to openssh, they ignored it by not assigning it to anyone. So pushing in that report won't help, IMHO. Opening a new one, mentioning the missed one, might help.