Commit Graph

110 Commits

Author SHA1 Message Date
dustin-ward 8411183d33 address review set 2 2024-04-05 16:07:40 -04:00
dustin-ward 96b29c55dd address review set 1 2024-04-05 12:37:27 -04:00
tanishq.singhal f96a7bef95 Handling error & Test func with working tree 2023-05-15 21:08:16 +05:30
tanishq.singhal 628da3e118 Adding Tests to test the func & resolving comment 2023-05-15 11:43:30 +05:30
Nicola Murino c7fdf5e5c6 writeToSequential: improve tests for write errors 2022-03-03 12:30:24 +01:00
Hilari Moragrega 65f24bcee4 Improved test with CR feedback 2022-03-03 09:43:16 +01:00
Hilari Moragrega c2c0f6090e Return writer error if not nil in writeSequential 2022-03-03 09:43:11 +01:00
Cassondra Foesch bb06e29d17 get integration tests passing on WSL for GOOS=windows 2022-01-31 21:12:49 +00:00
Gleb Teterin dad23755af Fix missing io.EOF when concurency is disabled #489 2022-01-20 07:55:17 +13:00
greatroar 1fffa629f6 Add File.ReadFrom test with a Sized Reader
This tests ReadFrom's determining concurrency from the estimated input
size. go test -cover -integration, before:

coverage: 77.3% of statements

After:

coverage: 79.2% of statements
2021-12-24 08:42:10 +01:00
Cassondra Foesch f525d180b6
Merge pull request #456 from pkg/refactor/regroup-and-lint
Regroup marshling/unmarshaling and lint
2021-08-20 22:59:08 +00:00
codesoap 997499abb6 Fix a few misspells 2021-08-20 21:00:33 +02:00
Cassondra Foesch 1b6d816185 remove min function 2021-08-11 13:29:16 +00:00
Cassondra Foesch 96bf4d30dc
Merge pull request #422 from greatroar/cleanup
Minor cleanup
2021-03-21 13:12:55 +00:00
greatroar 95591b2015 Remove unnecessary TeeReader from readHash 2021-03-20 11:43:59 +01:00
Cassondra Foesch d26c4bc2a7
Merge pull request #421 from pkg/benchmarks-and-errors
Improve benchmarks and errors
2021-03-20 03:11:49 +00:00
Cassondra Foesch addaabd30b give the bytes.Buffer a preallocated slice to use for less variance 2021-03-17 20:18:50 +00:00
greatroar 846e27dc7f Implement File.Chmod via setfstat 2021-03-17 18:50:51 +01:00
Cassondra Foesch b22b9e472e remove writeToBuffer, the bytes.Buffer.Grow I saw in the memprofile was elsewhere 2021-03-17 13:18:17 +00:00
Cassondra Foesch 39e1161d12 address my own code review comments 2021-03-17 12:05:00 +00:00
Cassondra Foesch f1e28f8a88 Improve benchmarks and errors 2021-03-17 11:03:51 +00:00
Cassondra Foesch 460ad57385
Merge pull request #416 from greatroar/match-cleanup
Clean up matching/globbing code
2021-03-16 01:20:24 +00:00
greatroar d3695c2587 Fix Glob handling of backslashes
\m\a\t\c\h\.\g\o would be interpreted as a literal path, because the
backslash was missing in the check.
2021-03-15 18:11:02 +01:00
greatroar 2573693ec5 Support os.Mode{Setuid,Setgid,Sticky} in Chmod
Previously, these bits were ignored by Chmod, which sent the numerical
value of the mode argument as-is to the server. As a result, callers had
to supply POSIX values for setuid, setgid and sticky to Chmod.

The new version supports both the POSIX values and the Go values.

Also added a note to the docs to clarify that the umask is not
subtracted from the mode, and why that is. The only portable way to get
the umask is to set it, then reset it, but that's racy. On Linux, we
could parse /proc/self/status, but that doesn't work portably and will
fail where /proc is not available (some Docker containers, notably).
2021-03-12 16:17:56 +01:00
Nicola Murino e1e59da6e3 add readAtSequential: used if concurrent reads are disabled ...
... and the requested buffer is bigger than maxPacket
2021-03-05 15:04:17 +01:00
Nicola Murino 5f2c008b8e add an option to disable concurrent reads
Fixs #345
2021-02-23 19:13:26 +01:00
Cassondra Foesch 29c556e3a6 WriteTo benchmarks 2021-02-22 12:04:43 +00:00
Cassondra Foesch 59de31242c more robust tests, fix typos 2021-02-22 12:04:43 +00:00
Cassondra Foesch d178e4730e avoid panic if double call to Close 2021-02-22 12:04:43 +00:00
Cassondra Foesch 27538347e7 defers in a for loop don't execute until the end of the function 2021-02-22 12:04:43 +00:00
Cassondra Foesch 4f2503d286 using sftp-server these tests hang without this close 2021-02-22 12:04:43 +00:00
Nicola Murino f5fd2fb058 normalise permission denied error as file not found error 2020-12-08 12:14:21 +01:00
greatroar 06d60c4c06 Test disconnect handling in open files 2020-11-04 10:17:06 +01:00
greatroar 7f43671909 Rename remaining temps in client integration test 2020-10-31 14:34:16 +01:00
greatroar 360f7af3e6 {assert,require}.Nil(t, err) => NoError, NotNil => Error 2020-10-29 16:02:25 +01:00
greatroar 4c4fa330bb First check for uid 0, then lookup daemon's uid 2020-10-29 16:00:27 +01:00
greatroar 7c0f7eea70 Comment out path matching test that breaks on Go tip 2020-10-29 14:47:28 +01:00
greatroar eb20cfe9bc Clean up temporary files in client tests 2020-10-23 22:14:32 +02:00
greatroar 83e0eb8f30 Fix typos in clients tests 2020-10-23 22:14:05 +02:00
greatroar d352a1d176 Add Client.Sync method
This uses the fsync@openssh.com extension:
https://github.com/openssh/openssh-portable/blob/master/PROTOCOL, §3.6.
2020-10-23 13:09:54 +02:00
Nicola Murino b4ea0fd6f6 fix lint issues
These lint issues remain:

- request-errors.go, aliases for new error types
- request-attrs.go, UidGid. Changing this will break compatibility
2019-08-30 17:04:37 +02:00
Tommie Gannert 2c24eaad1c Implement the hardlink@openssh.com extension.
Both client and server. This is documented in

  https://github.com/openssh/openssh-portable/blob/master/PROTOCOL

Draft 7 of SFTP added support for SSH_FXP_LINK which supports both
symlinks and hardlinks, but unfortunately OpenSSH doesn't support
that:

  https://tools.ietf.org/html/draft-ietf-secsh-filexfer-07#section-7.7

Adding support for this as an option would be a nice extension to
this.
2019-08-25 20:16:37 -07:00
Daniel Theophanes d8ec5de5ee sftp: update tests to finish and not panic on windows
Many Unix assuptions have been made when testing.
Previously running tests on windows threw a panic
part way through the tests. After these changes
many more tests pass when the fix was isolated
to the test itself, and none panic.

Some tests are skipped because they do make sense
on windows (chmod, chown), while others are skipped
just to how the test was implemented.

Lastly, some of the external executables were hard coded.
Change these to look paths in TestMain first. This is done
to better support windows, where openssh may be installed and
sftp and sftp-server may both be in the PATH.
2019-01-18 16:29:07 -08:00
Urjit Singh Bhatia 831654e4aa Client.MkdirAll - mimic os.MkdirAll code for consistency & perf 2018-04-25 08:13:19 -07:00
Urjit Singh Bhatia a03704e892 Add mkdirall implementation 2018-04-24 23:58:10 -07:00
John Eikenberry 49488377fa fix client deadlock on server death during writes
Fixes #234

Similar to #181 (which was about read methods), the client deadlocks on
server drop on write methods (Write/ReadFrom). This is another case of
broadcastErr() and dispatchRequest() deadlocking.

The fix is to bump up the channel used to communicate about inflight
packets to maxConcurrentRequests+1 (+1 is new). It seems that it can
have the full set of packets going and hit the error (triggering
broadcastErr) yet it still tries to call dispatchRequest again. More
details in that ticket.

I'm also bumping up the chan buffer in the read methods to keep them
consistent. I can't reproduce the problem, but it looks like it should
have it. So it might just be a much harder race to trigger.

This also includes 2 tests which reprocuded the issue for ReadFrom and
Write.
2018-03-15 13:53:30 -07:00
John Eikenberry 161bbaf9a8 a few code simplifications
ran gosimple over the code and made suggested adjustments
2018-02-15 11:17:19 -08:00
John Eikenberry 9fa3832aa2 update seek constants 2018-02-15 10:27:33 -08: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 4f3e725e88 Fixes #188; eliminates duplicated core code
match contained lots of cut-n-pasted code from filepath/match.go in the
core libraries. Particularly Match() and Join() were changed in such a
way that made them functionally equivalent to the versions in
path/match.go. This removes the duplicate code and just calls the path
versions.
2017-07-20 15:28:11 -07:00