forked from TrueCloudLab/rclone
vendor: update github.com/pkg/sftp because dep insisted
This commit is contained in:
parent
ef412c1985
commit
18317a2747
7 changed files with 68 additions and 28 deletions
17
Gopkg.lock
generated
17
Gopkg.lock
generated
|
@ -139,8 +139,14 @@
|
|||
packages = [
|
||||
"dropbox",
|
||||
"dropbox/async",
|
||||
"dropbox/common",
|
||||
"dropbox/file_properties",
|
||||
"dropbox/files"
|
||||
"dropbox/files",
|
||||
"dropbox/sharing",
|
||||
"dropbox/team_common",
|
||||
"dropbox/team_policies",
|
||||
"dropbox/users",
|
||||
"dropbox/users_common"
|
||||
]
|
||||
revision = "f0b3f3ded6d415a94e83e9a514fb8025e4e6be31"
|
||||
|
||||
|
@ -254,8 +260,8 @@
|
|||
[[projects]]
|
||||
name = "github.com/pkg/sftp"
|
||||
packages = ["."]
|
||||
revision = "49488377fa2f14143ba3067cf7555f60f6c7b550"
|
||||
version = "1.5.0"
|
||||
revision = "43ec6c679d353f6e077d3965dc74f6d996eb4a09"
|
||||
version = "1.5.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/pmezard/go-difflib"
|
||||
|
@ -375,7 +381,8 @@
|
|||
"idna",
|
||||
"lex/httplex",
|
||||
"webdav",
|
||||
"webdav/internal/xml"
|
||||
"webdav/internal/xml",
|
||||
"websocket"
|
||||
]
|
||||
revision = "92b859f39abd2d91a854c9f9c4621b2f5054a92d"
|
||||
|
||||
|
@ -468,6 +475,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "a91eff17e50d8733124875c68dbe771833cb9d8d07d545ba75fc4dd561f9bfe2"
|
||||
inputs-digest = "50d82f1173802259032be4dddb962f1b7ed8eebdbc24c73febcde47d8deecb30"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
4
vendor/github.com/pkg/sftp/packet-typing.go
generated
vendored
4
vendor/github.com/pkg/sftp/packet-typing.go
generated
vendored
|
@ -127,7 +127,9 @@ func makePacket(p rxPacket) (requestPacket, error) {
|
|||
return nil, errors.Errorf("unhandled packet type: %s", p.pktType)
|
||||
}
|
||||
if err := pkt.UnmarshalBinary(p.pktBytes); err != nil {
|
||||
return nil, err
|
||||
// Return partially unpacked packet to allow callers to return
|
||||
// error messages appropriately with necessary id() method.
|
||||
return pkt, err
|
||||
}
|
||||
return pkt, nil
|
||||
}
|
||||
|
|
12
vendor/github.com/pkg/sftp/packet.go
generated
vendored
12
vendor/github.com/pkg/sftp/packet.go
generated
vendored
|
@ -875,9 +875,17 @@ type sshFxpExtendedPacket struct {
|
|||
}
|
||||
|
||||
func (p sshFxpExtendedPacket) id() uint32 { return p.ID }
|
||||
func (p sshFxpExtendedPacket) readonly() bool { return p.SpecificPacket.readonly() }
|
||||
func (p sshFxpExtendedPacket) readonly() bool {
|
||||
if p.SpecificPacket == nil {
|
||||
return true
|
||||
}
|
||||
return p.SpecificPacket.readonly()
|
||||
}
|
||||
|
||||
func (p sshFxpExtendedPacket) respond(svr *Server) error {
|
||||
if p.SpecificPacket == nil {
|
||||
return nil
|
||||
}
|
||||
return p.SpecificPacket.respond(svr)
|
||||
}
|
||||
|
||||
|
@ -897,7 +905,7 @@ func (p *sshFxpExtendedPacket) UnmarshalBinary(b []byte) error {
|
|||
case "posix-rename@openssh.com":
|
||||
p.SpecificPacket = &sshFxpExtendedPacketPosixRename{}
|
||||
default:
|
||||
return errUnknownExtendedPacket
|
||||
return errors.Wrapf(errUnknownExtendedPacket, "packet type %v", p.SpecificPacket)
|
||||
}
|
||||
|
||||
return p.SpecificPacket.UnmarshalBinary(bOrig)
|
||||
|
|
9
vendor/github.com/pkg/sftp/request-server.go
generated
vendored
9
vendor/github.com/pkg/sftp/request-server.go
generated
vendored
|
@ -128,10 +128,19 @@ func (rs *RequestServer) Serve() error {
|
|||
|
||||
pkt, err = makePacket(rxPacket{fxp(pktType), pktBytes})
|
||||
if err != nil {
|
||||
switch errors.Cause(err) {
|
||||
case errUnknownExtendedPacket:
|
||||
if err := rs.serverConn.sendError(pkt, ErrSshFxOpUnsupported); err != nil {
|
||||
debug("failed to send err packet: %v", err)
|
||||
rs.conn.Close() // shuts down recvPacket
|
||||
break
|
||||
}
|
||||
default:
|
||||
debug("makePacket err: %v", err)
|
||||
rs.conn.Close() // shuts down recvPacket
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
pktChan <- pkt
|
||||
}
|
||||
|
|
6
vendor/github.com/pkg/sftp/request.go
generated
vendored
6
vendor/github.com/pkg/sftp/request.go
generated
vendored
|
@ -152,9 +152,6 @@ func (r *Request) getLister() ListerAt {
|
|||
|
||||
// Close reader/writer if possible
|
||||
func (r *Request) close() error {
|
||||
if r.cancelCtx != nil {
|
||||
r.cancelCtx()
|
||||
}
|
||||
rd := r.getReader()
|
||||
if c, ok := rd.(io.Closer); ok {
|
||||
return c.Close()
|
||||
|
@ -163,6 +160,9 @@ func (r *Request) close() error {
|
|||
if c, ok := wt.(io.Closer); ok {
|
||||
return c.Close()
|
||||
}
|
||||
if r.cancelCtx != nil {
|
||||
r.cancelCtx()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
11
vendor/github.com/pkg/sftp/server.go
generated
vendored
11
vendor/github.com/pkg/sftp/server.go
generated
vendored
|
@ -134,7 +134,7 @@ func (svr *Server) sftpServerWorker(pktChan chan requestPacket) error {
|
|||
case *sshFxpOpenPacket:
|
||||
readonly = pkt.readonly()
|
||||
case *sshFxpExtendedPacket:
|
||||
readonly = pkt.SpecificPacket.readonly()
|
||||
readonly = pkt.readonly()
|
||||
}
|
||||
|
||||
// If server is operating read-only and a write operation is requested,
|
||||
|
@ -304,10 +304,19 @@ func (svr *Server) Serve() error {
|
|||
|
||||
pkt, err = makePacket(rxPacket{fxp(pktType), pktBytes})
|
||||
if err != nil {
|
||||
switch errors.Cause(err) {
|
||||
case errUnknownExtendedPacket:
|
||||
if err := svr.serverConn.sendError(pkt, ErrSshFxOpUnsupported); err != nil {
|
||||
debug("failed to send err packet: %v", err)
|
||||
svr.conn.Close() // shuts down recvPacket
|
||||
break
|
||||
}
|
||||
default:
|
||||
debug("makePacket err: %v", err)
|
||||
svr.conn.Close() // shuts down recvPacket
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
pktChan <- pkt
|
||||
}
|
||||
|
|
23
vendor/github.com/pkg/sftp/server_test.go
generated
vendored
23
vendor/github.com/pkg/sftp/server_test.go
generated
vendored
|
@ -198,24 +198,29 @@ func (p sshFxpTestBadExtendedPacket) MarshalBinary() ([]byte, error) {
|
|||
}
|
||||
|
||||
// test that errors are sent back when we request an invalid extended packet operation
|
||||
// this validates the following rfc draft is followed https://tools.ietf.org/html/draft-ietf-secsh-filexfer-extensions-00
|
||||
func TestInvalidExtendedPacket(t *testing.T) {
|
||||
client, server := clientServerPair(t)
|
||||
defer client.Close()
|
||||
defer server.Close()
|
||||
|
||||
badPacket := sshFxpTestBadExtendedPacket{client.nextID(), "thisDoesn'tExist", "foobar"}
|
||||
_, _, err := client.clientConn.sendPacket(badPacket)
|
||||
if err == nil {
|
||||
t.Fatal("expected error from bad packet")
|
||||
typ, data, err := client.clientConn.sendPacket(badPacket)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from sendPacket: %s", err)
|
||||
}
|
||||
if typ != ssh_FXP_STATUS {
|
||||
t.Fatalf("received non-FPX_STATUS packet: %v", typ)
|
||||
}
|
||||
|
||||
// try to stat a file; the client should have shut down.
|
||||
filePath := "/etc/passwd"
|
||||
_, err = client.Stat(filePath)
|
||||
if err == nil {
|
||||
t.Fatal("expected error from closed connection")
|
||||
err = unmarshalStatus(badPacket.id(), data)
|
||||
statusErr, ok := err.(*StatusError)
|
||||
if !ok {
|
||||
t.Fatal("failed to convert error from unmarshalStatus to *StatusError")
|
||||
}
|
||||
if statusErr.Code != ssh_FX_OP_UNSUPPORTED {
|
||||
t.Errorf("statusErr.Code => %d, wanted %d", statusErr.Code, ssh_FX_OP_UNSUPPORTED)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// test that server handles concurrent requests correctly
|
||||
|
|
Loading…
Reference in a new issue