Bug 3222 - get -r doesn't work because directories are created without write permissions
Summary: get -r doesn't work because directories are created without write permissions
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 8.1p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_8_5
  Show dependency treegraph
 
Reported: 2020-10-21 07:54 AEDT by ncdehnel
Modified: 2021-04-23 15:02 AEST (History)
1 user (show)

See Also:


Attachments
Ensure directory is writable and searchable for the duration of a recursive transfer (1.37 KB, patch)
2020-10-21 13:38 AEDT, Darren Tucker
no flags Details | Diff
Ensure directory is writable and searchable for the duration of a recursive transfer (1.38 KB, patch)
2020-10-21 15:32 AEDT, Darren Tucker
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ncdehnel 2020-10-21 07:54:27 AEDT
nathan@gentooserver /media/store/Data/VM/OpenVMS/OPENKITS $ sftp -o PasswordAuthentication=yes OPENKITS@vsiftp.vmssoftware.com

 This is VMS Software, Inc. OpenVMS (TM) IA64 Operating System, V8.4-2L1
OPENKITS@vsiftp.vmssoftware.com's password: 
Connected to vsiftp.vmssoftware.com.
sftp> ls   
ALPOPENSOURCE  I64OPENSOURCE  README.TXT     
sftp> get -r ALPOPENSOURCE
Fetching /disk$guest03/OPENKITS/ALPOPENSOURCE/ to ALPOPENSOURCE
Retrieving /disk$guest03/openkits/alpopensource
Retrieving /disk$guest03/openkits/alpopensource/ARCHIVE
mkdir ALPOPENSOURCE/ARCHIVE: Permission denied
Couldn't open local file "ALPOPENSOURCE/SYSLOGD-AXPVMS-04-FEB-2018.TXT" for writing: Permission denied
Download of file /disk$guest03/openkits/alpopensource/SYSLOGD-AXPVMS-04-FEB-2018.TXT to ALPOPENSOURCE/SYSLOGD-AXPVMS-04-FEB-2018.TXT failed

nathan@gentooserver /media/store/Data/VM/OpenVMS/OPENKITS $ ls -l
total 4
dr--r----- 1 nathan nathan   0 Oct 20 15:28 ALPOPENSOURCE
dr--r----- 1 nathan nathan   0 Oct 20 15:28 I64OPENSOURCE
-rw-r--r-- 1 nathan nathan 675 Oct 20 15:28 README.TXT
Comment 1 Darren Tucker 2020-10-21 13:15:16 AEDT
This is because the source directories are not writable either, and sftp is maintaining those permissions:
sftp> ls -l
dr--r-----   1 ECOKITS  VSI$GUEST     4096 Oct 26  2016 ALPOPENSOURCE
dr--r-----   1 ECOKITS  VSI$GUEST     9216 Apr 19  2016 I64OPENSOURCE
-r--r--r--   1 OPENKITS VSI$GUEST      706 Jan 29  2019 README.TXT

sftp would need to open the directory with user write, then set the final permission when it's done with the directory.
Comment 2 Darren Tucker 2020-10-21 13:25:58 AEDT
oh, and the directory doesn't have the "x" bit, which is also going to cause some problems on most unix variants.
Comment 3 Darren Tucker 2020-10-21 13:38:40 AEDT
Created attachment 3450 [details]
Ensure directory is writable and searchable for the duration of a recursive transfer

Please try this patch.
Comment 4 Darren Tucker 2020-10-21 15:32:21 AEDT
Created attachment 3451 [details]
Ensure directory is writable and searchable for the duration of a recursive transfer

fix incorrect error message in previous.
Comment 5 ncdehnel 2020-10-22 08:37:56 AEDT
The patch seems to work. It seems to have downloaded all the files. Thank you.
Comment 6 Darren Tucker 2020-11-20 14:18:26 AEDT
The patch (plus the equivalent for the upload path) has been committed and will be in the 8.5 release.  Thanks for the report.
Comment 7 Damien Miller 2021-04-23 15:02:01 AEST
closing resolved bugs as of 8.6p1 release