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 = [
|
packages = [
|
||||||
"dropbox",
|
"dropbox",
|
||||||
"dropbox/async",
|
"dropbox/async",
|
||||||
|
"dropbox/common",
|
||||||
"dropbox/file_properties",
|
"dropbox/file_properties",
|
||||||
"dropbox/files"
|
"dropbox/files",
|
||||||
|
"dropbox/sharing",
|
||||||
|
"dropbox/team_common",
|
||||||
|
"dropbox/team_policies",
|
||||||
|
"dropbox/users",
|
||||||
|
"dropbox/users_common"
|
||||||
]
|
]
|
||||||
revision = "f0b3f3ded6d415a94e83e9a514fb8025e4e6be31"
|
revision = "f0b3f3ded6d415a94e83e9a514fb8025e4e6be31"
|
||||||
|
|
||||||
|
@ -254,8 +260,8 @@
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/pkg/sftp"
|
name = "github.com/pkg/sftp"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "49488377fa2f14143ba3067cf7555f60f6c7b550"
|
revision = "43ec6c679d353f6e077d3965dc74f6d996eb4a09"
|
||||||
version = "1.5.0"
|
version = "1.5.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/pmezard/go-difflib"
|
name = "github.com/pmezard/go-difflib"
|
||||||
|
@ -375,7 +381,8 @@
|
||||||
"idna",
|
"idna",
|
||||||
"lex/httplex",
|
"lex/httplex",
|
||||||
"webdav",
|
"webdav",
|
||||||
"webdav/internal/xml"
|
"webdav/internal/xml",
|
||||||
|
"websocket"
|
||||||
]
|
]
|
||||||
revision = "92b859f39abd2d91a854c9f9c4621b2f5054a92d"
|
revision = "92b859f39abd2d91a854c9f9c4621b2f5054a92d"
|
||||||
|
|
||||||
|
@ -468,6 +475,6 @@
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "a91eff17e50d8733124875c68dbe771833cb9d8d07d545ba75fc4dd561f9bfe2"
|
inputs-digest = "50d82f1173802259032be4dddb962f1b7ed8eebdbc24c73febcde47d8deecb30"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
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)
|
return nil, errors.Errorf("unhandled packet type: %s", p.pktType)
|
||||||
}
|
}
|
||||||
if err := pkt.UnmarshalBinary(p.pktBytes); err != nil {
|
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
|
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) 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 {
|
func (p sshFxpExtendedPacket) respond(svr *Server) error {
|
||||||
|
if p.SpecificPacket == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return p.SpecificPacket.respond(svr)
|
return p.SpecificPacket.respond(svr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +905,7 @@ func (p *sshFxpExtendedPacket) UnmarshalBinary(b []byte) error {
|
||||||
case "posix-rename@openssh.com":
|
case "posix-rename@openssh.com":
|
||||||
p.SpecificPacket = &sshFxpExtendedPacketPosixRename{}
|
p.SpecificPacket = &sshFxpExtendedPacketPosixRename{}
|
||||||
default:
|
default:
|
||||||
return errUnknownExtendedPacket
|
return errors.Wrapf(errUnknownExtendedPacket, "packet type %v", p.SpecificPacket)
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.SpecificPacket.UnmarshalBinary(bOrig)
|
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})
|
pkt, err = makePacket(rxPacket{fxp(pktType), pktBytes})
|
||||||
if err != nil {
|
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)
|
debug("makePacket err: %v", err)
|
||||||
rs.conn.Close() // shuts down recvPacket
|
rs.conn.Close() // shuts down recvPacket
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pktChan <- pkt
|
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
|
// Close reader/writer if possible
|
||||||
func (r *Request) close() error {
|
func (r *Request) close() error {
|
||||||
if r.cancelCtx != nil {
|
|
||||||
r.cancelCtx()
|
|
||||||
}
|
|
||||||
rd := r.getReader()
|
rd := r.getReader()
|
||||||
if c, ok := rd.(io.Closer); ok {
|
if c, ok := rd.(io.Closer); ok {
|
||||||
return c.Close()
|
return c.Close()
|
||||||
|
@ -163,6 +160,9 @@ func (r *Request) close() error {
|
||||||
if c, ok := wt.(io.Closer); ok {
|
if c, ok := wt.(io.Closer); ok {
|
||||||
return c.Close()
|
return c.Close()
|
||||||
}
|
}
|
||||||
|
if r.cancelCtx != nil {
|
||||||
|
r.cancelCtx()
|
||||||
|
}
|
||||||
return nil
|
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:
|
case *sshFxpOpenPacket:
|
||||||
readonly = pkt.readonly()
|
readonly = pkt.readonly()
|
||||||
case *sshFxpExtendedPacket:
|
case *sshFxpExtendedPacket:
|
||||||
readonly = pkt.SpecificPacket.readonly()
|
readonly = pkt.readonly()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If server is operating read-only and a write operation is requested,
|
// 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})
|
pkt, err = makePacket(rxPacket{fxp(pktType), pktBytes})
|
||||||
if err != nil {
|
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)
|
debug("makePacket err: %v", err)
|
||||||
svr.conn.Close() // shuts down recvPacket
|
svr.conn.Close() // shuts down recvPacket
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pktChan <- pkt
|
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
|
// 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) {
|
func TestInvalidExtendedPacket(t *testing.T) {
|
||||||
client, server := clientServerPair(t)
|
client, server := clientServerPair(t)
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
badPacket := sshFxpTestBadExtendedPacket{client.nextID(), "thisDoesn'tExist", "foobar"}
|
badPacket := sshFxpTestBadExtendedPacket{client.nextID(), "thisDoesn'tExist", "foobar"}
|
||||||
_, _, err := client.clientConn.sendPacket(badPacket)
|
typ, data, err := client.clientConn.sendPacket(badPacket)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Fatal("expected error from bad packet")
|
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.
|
err = unmarshalStatus(badPacket.id(), data)
|
||||||
filePath := "/etc/passwd"
|
statusErr, ok := err.(*StatusError)
|
||||||
_, err = client.Stat(filePath)
|
if !ok {
|
||||||
if err == nil {
|
t.Fatal("failed to convert error from unmarshalStatus to *StatusError")
|
||||||
t.Fatal("expected error from closed connection")
|
}
|
||||||
|
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
|
// test that server handles concurrent requests correctly
|
||||||
|
|
Loading…
Reference in a new issue