[SFTP] Read from write-only file not returning error

Stef Bon stefbon at gmail.com
Tue Aug 8 17:55:33 AEST 2017


2017-08-06 11:29 GMT+02:00 Nikolaus Rath <Nikolaus at rath.org>:
> Hello,
>
> As far as I can tell, when sending a SSH_FXP_OPEN request with
> SSH_FXF_WRITE (i.e., opening the file write only), and then following up
> with a SSH_FXP_READ, the server responds with a SSH_FXP_STATUS
> indicating that all data has been read.
>

I'm doing the same using my fuse sftp client as described in the sshfs issue 72.
The second command

echo bar >> test.txt

with writeback cache enabled causes also a read command send while the
flags send to the sftp server
only allow write. The value of pflags indicating how the file has to
opened is 6 = 4 | 2 = write and append.
This value is used by the sftp server. So far so good.

The read command (caused by writeback cache) returns a status reply 2
indicating SSH_FX_NO_SUCH_FILE.
(see https://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/draft-ietf-secsh-filexfer-02.txt)
This error code is not correct but it's possible that this is the
"best guess". The number of error codes in the rfc
(which is used by the openssh sftp-server) is very limited.
What is the value sshfs receives? In the status codes used by the
sftp-server there is no "all data is read".

I will test this behaviour with another sftp server.
The read command is not there anymore when not using writeback cache.

Stef


More information about the openssh-unix-dev mailing list