sftp client stores files and directories with wrong permissions received by the server and lets download fail

Bug #1374386 reported by Michael Mess on 2014-09-26
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
openssh (Ubuntu)
Undecided
Unassigned

Bug Description

Ubuntu: 14.04 LTS
The problem occurs always, but only with remote site reporting wrong/broken file permissions:

sftp downloads files with those wrong permissions. The download succeeds for a single file or directory, but to access the local file/directory, you have to chmod it locally.
Recursive downloads fail reproducibly, because the local directory created by sftp during the download lacks permission to add the remote files to be downloaded into it.
If the local directory already exists with the right permissions, the permissions are unchanged by sftp and the remote files and directories can be created and downloaded into it, but both with the wrong permissions.

A network resource wasting workaround for a manual download of a directory could be to chmod +rwX the local directories after a failed download and try the download command again, then chmod the local download tree again, try the download again, ... , until the download was finally successful.

The remote site reports wrong permissions (no permission at all) for each directory and file.
sftp takes these permissions for the download, even when it is not told to do so via option.
As a result the downloaded directories have no write permissions and downloading the contained files fails.

sftp> ls -l
d--------- 32 0 0 8192 Sep 25 18:45 download
sftp>

sftp> get -r download/
Fetching /home/test/download/ to download
Retrieving /home/test/download
Retrieving /home/test/download/20140821
mkdir download/20140821: Permission denied
Retrieving /home/test/download/20140826
mkdir download/20140826: Permission denied
Retrieving /home/test/download/20140828
mkdir download/20140828: Permission denied
Retrieving /home/test/download/20140902
mkdir download/20140902: Permission denied
Retrieving /home/test/download/20140903
mkdir download/20140903: Permission denied
Retrieving /home/test/download/20140904
mkdir download/20140904: Permission denied
Retrieving /home/test/download/20140909
mkdir download/20140909: Permission denied
Retrieving /home/test/download/20140910
mkdir download/20140910: Permission denied
Retrieving /home/test/download/20140911
mkdir download/20140911: Permission denied
Retrieving /home/test/download/20140916
mkdir download/20140916: Permission denied
Retrieving /home/test/download/20140917
mkdir download/20140917: Permission denied
Retrieving /home/test/download/20140918
mkdir download/20140918: Permission denied
Retrieving /home/test/download/20140923
mkdir download/20140923: Permission denied
Retrieving /home/test/download/20140925
mkdir download/20140925: Permission denied
Retrieving /home/test/download/20140717
mkdir download/20140717: Permission denied
Retrieving /home/test/download/20140722
mkdir download/20140722: Permission denied
Retrieving /home/test/download/20140723
mkdir download/20140723: Permission denied
Retrieving /home/test/download/20140729
mkdir download/20140729: Permission denied
Retrieving /home/test/download/20140730
mkdir download/20140730: Permission denied
Retrieving /home/test/download/20140731
mkdir download/20140731: Permission denied
Retrieving /home/test/download/20140806
mkdir download/20140806: Permission denied
Retrieving /home/test/download/20140807
mkdir download/20140807: Permission denied
Retrieving /home/test/download/20140812
mkdir download/20140812: Permission denied
Retrieving /home/test/download/20140814
mkdir download/20140814: Permission denied
Retrieving /home/test/download/20140819
mkdir download/20140819: Permission denied
Retrieving /home/test/download/20140820
mkdir download/20140820: Permission denied
Retrieving /home/test/download/20140827
mkdir download/20140827: Permission denied
Retrieving /home/test/download/20140924
mkdir download/20140924: Permission denied
Retrieving /home/test/download/20140929
mkdir download/20140929: Permission denied
Retrieving /home/test/download/20140724
mkdir download/20140724: Permission denied
sftp>

The directory has been created, but with empty permissions, thus downloading the content fails, because the local files/directories could not be created.

mm@janus:~/download/download-test/test $ ll
total 4
d--------- 2 mm mm 4096 Jul 25 13:41 download
mm@janus:~/download/download-test/test $

Expected behaviour:
sftp should use local umask or given umask for creating files and directories.
Only when it has been told to by option, it should set the remote permissions of directories and files, but only after their content has been downloaded, so that local files and directories can be created for download, even when the remote directory does not have write permission enabled.
Thus it could even download and reproduce a directory tree without write permissions.

description: updated
tags: added: trusty
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in openssh (Ubuntu):
status: New → Confirmed
tags: added: sftp
description: updated
description: updated
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers