Re: SCP in SFTP mode regression

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



On Tue, 22 Feb 2022, Dmitry Belyavskiy wrote:

> Hello,
> 
> We came across a weird bug using SCP in SFTP mode
> Current master, command
> 
> ./scp -s -S `which ssh` qq localhost:`pwd`/qq
> 
> effectively truncates the file to be copied.
> 
> SCP mode deals normally.
> 
> I understand that it's a corner case but still think it's worth reporting.

Yes, this is because scp/rcp does open(path, O_CREAT) and then ftruncate()
at close() time, whereas scp/sftp does open(path, O_CREAT|O_TRUNC) on the
basis that in an aborted transfer it's better to leave truncated files
around than files with inconsistent contents.

I don't want to change the behaviour of sftp's upload code, because I think
it is better (at the very least, it allows resumption of transfers without
needing rsync-like tricks), so IMO the best way to avoid this would be to
teach the upload code to go via a temporary file. Not sure whether this is
worth the hassle though for such a corner-case.

-d
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux