diff --git a/request-interfaces.go b/request-interfaces.go index 06106af..dd224cd 100644 --- a/request-interfaces.go +++ b/request-interfaces.go @@ -25,6 +25,8 @@ type FileReader interface { // The request server code will call Close() on the returned io.WriterAt // ojbect if an io.Closer type assertion succeeds. // Note in cases of an error, the error text will be sent to the client. +// Note when receiving an Append flag it is important to not open files using +// O_APPEND if you plan to use WriteAt, as they conflict. // Called for Methods: Put, Open type FileWriter interface { Filewrite(*Request) (io.WriterAt, error) diff --git a/server.go b/server.go index e7d6d81..905b75c 100644 --- a/server.go +++ b/server.go @@ -398,9 +398,9 @@ func (p sshFxpOpenPacket) respond(svr *Server) responsePacket { return statusFromError(p, syscall.EINVAL) } - if p.hasPflags(sshFxfAppend) { - osFlags |= os.O_APPEND - } + // Don't use O_APPEND flag as it conflicts with WriteAt. + // The sshFxfAppend flag is a no-op here as the client sends the offsets. + if p.hasPflags(sshFxfCreat) { osFlags |= os.O_CREATE }