Commit Graph

750 Commits

Author SHA1 Message Date
John Eikenberry 36cbb62432 make sure request is always closed properly 2018-02-05 12:46:27 -08:00
Allan Feid 87f773b0e3 Add context to request lifecycle 2018-02-05 12:46:27 -08:00
John Eikenberry e435bb6886
Merge pull request #226 from tamird/remove-gccgo-tags
Remove gccgo special cases
2018-02-05 12:45:24 -08:00
Tamir Duberstein 83a859a04e Remove gccgo special cases
This was fixed in a different way in 4d0e916.
2018-02-02 15:01:09 -05:00
John Eikenberry 738e088bbd support handlers returning explicit error codes
Add errors for all the SSH_FXP_STATUS codes to give the developer
implementing request server handlers greater control over the returned
codes. Most helpful in cases where nothing currently would work (eg.
unsupported).

Fixes #223
2018-01-26 17:26:44 -08:00
John Eikenberry 0cf318853f drop support for go versions <= 1.7 2018-01-25 17:44:22 -08:00
John Eikenberry 4ab81b0271 improve statusFromError readability 2018-01-25 17:29:36 -08:00
John Eikenberry f128182572 skip timestamp field in server comparison test
Timestamps on some directories can vary during the test (eg. /tmp).
2018-01-17 11:43:54 -08:00
John Eikenberry 9917fead0c handler type documenation improvements
Fixes #221
2018-01-16 14:42:06 -08:00
John Eikenberry 02e35135dc test errors now set in a more uniform manner
request_test and request-server_test set mocked/fake errors differently.
This makes them use the same basic API for simplicity.
2018-01-16 14:18:45 -08:00
John Eikenberry b2b7fdff00 test custom error message returns 2018-01-16 14:12:00 -08:00
John Eikenberry 72ec6e8559 Add example about ReadFrom + bufio interaction
Fixes #125
2018-01-11 18:24:04 -08:00
John Eikenberry f6a9258a0f add helper methods for request flags/attrs data 2018-01-09 15:31:54 -08:00
John Eikenberry c40e9cd1ca split out FileStat creation
Allows me to reuse code.
2018-01-09 15:29:55 -08:00
John Eikenberry 01df3f4dbd remove old comment 2018-01-09 10:58:58 -08:00
John Eikenberry 30b632cf56 handle errors in file creation from open packet
open packet w/ the create flag would create the file but was ignoring
any errors from that. this fixes that and adds a test for it.
2018-01-07 18:30:26 -08:00
John Eikenberry 1a8a095942 add hooks for returning errors from test handlers
for use in tests, when I want to test error handling
2018-01-07 18:29:18 -08:00
John Eikenberry 5d6c28a24a file fetch failure check 2018-01-07 18:05:50 -08:00
John Eikenberry 65c300dda8 remove some redundant code 2018-01-07 17:34:08 -08:00
John Eikenberry c33862bb7d remove special handling of Fstat/Fsetstat
Recent refactoring has eliminated the need for Fstat and Fsetstat (stat
operations on file handle instead of path)to be special cased. They will
now just work with the normal case for any packet with a file handle.
2018-01-07 16:04:33 -08:00
John Eikenberry 49c117d57a Fix volume name mangling on windows.
Fixes #217, where the path cleaning code was mangling the volume name on
windows; ie. "c:/some/path" was turned into "/c:/some/path". Using the
filepath.IsAbs() (vs path.IsAbs()) uses OS specific tests and fixes
this.

This goes against strict POSIX paths, but this used to work and fixing
it breaks nothing on other platforms. And we have still standardized on
POSIX style delimiters.
2018-01-07 15:23:55 -08:00
John Eikenberry 937c489fca tests should just fail, not panic 2018-01-06 19:47:44 -08:00
John Eikenberry aae30a2509 factor out unnecessary data structure
packet_data structure was a leftover from previous code and it is no
longer necessary as the packets are available to use. I kept
packetData() to simplify grabing the data off the packets.
2018-01-06 16:12:05 -08:00
John Eikenberry 4f3501551d gofmt-ing 2018-01-05 22:53:15 -08:00
John Eikenberry 9ff3538709 store open packet's pflags to request.Flags 2018-01-05 17:55:57 -08:00
John Eikenberry 5d3a486231 update Request structure docs for path and flag changes 2018-01-04 13:30:43 -08:00
John Eikenberry ce0184a233 mention pflags and file attributes access in request readme 2018-01-02 15:52:16 -08:00
John Eikenberry fb7a319a82
Merge pull request #216 from pkg/issue214/empty-file
respect create flag in open packet
2017-12-24 13:52:53 -08:00
John Eikenberry 0e667a77c5 add test for uploading empty file 2017-12-24 13:43:57 -08:00
John Eikenberry fa2d0c3125 respect create flag in open packet
When the SSH_FXP_OPEN packet has the SSH_FXF_CREAT pflag set the file
should get created even if no data is sent. We do this by having the
Open method call through to the FilePut Handler with empty packet data.

Fixes #214
2017-12-23 19:14:16 -08:00
John Eikenberry a6c60b2061 Split setFileState into separate, typed functions.
Fixes #215 where the user had an object that was their reader and writer
and thing wouldn't work right.
2017-12-23 16:50:46 -08:00
John Eikenberry 8722020a70 simpify Request struct and Method updating
In #192 we normalized all Request use to have pointer receivers. This
simplified reasoning and allowed for a simpler Request struct. This
change completes that work by eliminating the need for the
state/stackLock pointers and also removes the need for a new Request
each packet, reducing the pressure on the GC.

The main bit is that the RequestServer.openRequests[] map now stores Request
pointers and it only creates new Requests (replacing the mapped entry) when the
Method changes. It never updates/modifies an existing Request and the packet to
Method mapping is now all in place place (requestMethod).
2017-12-23 16:34:22 -08:00
John Eikenberry 9e9438a691
Merge pull request #213 from vansante/master
Add PosixRename method which uses the posix-rename@openssh.com extension (without server support)
2017-12-21 12:10:58 -08:00
John Eikenberry 3030aca5da Fix issue with path 'cleaning' and adds tests
Fix #207

The primary issue of the resolved ticket was path cleaning code returned
the path of '/.' instead of '/'.

We also reviewed and clarified the use of filepath/path and how OS
specific paths are handled in the server code. All paths are converted
to POSIX paths as they come into the server. They are then POSIX paths
for all internal operations.
2017-12-21 12:05:53 -08:00
Paul c2bca6d357
Merge pull request #1 from pkg/master
Update from pkg/sftp
2017-12-20 15:29:39 +01:00
Paul van Santen 97614f0b4c Revert server side support for rename@openssh.com extension 2017-12-20 15:22:30 +01:00
John Eikenberry 1d5374a61d update travis go versions 2017-12-12 11:47:49 -08:00
John Eikenberry 4ff50438a2
Merge pull request #210 from Mayank1791989/master
fix(request-server): handle file close error
fixes #208
2017-12-12 11:47:14 -08:00
Mayank Agarwal 1816888769 fix(request-server): handle file close error 2017-12-12 23:35:18 +05:30
John Eikenberry f6ec992e48 expand docs on InternalInconsistency
Fixes #190

Add notes on possible causes and state of client object.
2017-11-04 12:48:40 -07:00
John Eikenberry 7c1f7a3707 use ietf link for sftp spec everywhere
Fixes #202
2017-10-01 17:55:39 -07:00
Iain Wade 9b6cdb8fab Add PosixRename method which uses the posix-rename@openssh.com extension
to support actual rename() operations rather than the link() call
effectively mandated by the sftp v3/draft-2 requirement that targets
not be overwritten.
2017-09-05 04:46:03 -07:00
John Eikenberry 98203f5a83 remove ssh-agent requirement for integration tests
Thanks @tv42 for this code. I took it from his PR; #92.
2017-08-23 14:46:20 -07:00
John Eikenberry 13ec2164f5 mispelling in test output 2017-08-23 14:20:45 -07:00
John Eikenberry 87518d071d remove vestigial packets channel from request
Request object had a packet channel where it stored packets for
read/write/readdir handling. It was required in an earlier version of
the code (that was refactored before merging) and never got cleaned up.

This removes that channel and just passes the packet through the methods
instead. This is much simpler and would have eliminated the chance of
issue #195. It also looks like it should allow for a few more
simplifications as well.
2017-08-22 19:24:14 -07:00
John Eikenberry 98dd8fc859 remove dead end-of-dir code 2017-08-22 17:32:37 -07:00
John Eikenberry 19d66c2d96 change request.handle() to request.callHandler()
Handle was already used for sftp's session 'handle' which is the name
used in the other code and sftp specs.
2017-08-20 17:51:45 -07:00
John Eikenberry 06477cae89 minor fix to doc comment 2017-08-20 17:47:32 -07:00
John Eikenberry 6eeffbb805 don't use read locks when making a change 2017-08-20 17:38:09 -07:00
John Eikenberry db5d9a73ca Merge pull request #197 from mjgarton/master
Fix #196; Increase offset correctly
2017-08-20 17:33:02 -07:00