Commit Graph

169 Commits

Author SHA1 Message Date
djm@openbsd.org 2ab864010e upstream: SFTP protocol extension to allow the server to expand
~-prefixed paths, in particular ~user ones. Allows scp in sftp mode to accept
these paths, like scp in rcp mode does.

prompted by and much discussion deraadt@
ok markus@

OpenBSD-Commit-ID: 7d794def9e4de348e1e777f6030fc9bafdfff392
2021-08-10 12:47:46 +10:00
djm@openbsd.org 986abe94d4 upstream: show only the final path component in the progress meter;
more useful with long paths (that may truncate) and better matches
traditional scp behaviour; spotted by naddy@ ok deraadt@

OpenBSD-Commit-ID: 26b544d0074f03ebb8a3ebce42317d8d7ee291a3
2021-08-10 12:47:39 +10:00
djm@openbsd.org 85de69f646 upstream: sftp-client.c needs poll.h
remove unused variable

OpenBSD-Commit-ID: 233ac6c012cd23af62f237167a661db391055a16
2021-08-07 11:57:13 +10:00
Darren Tucker 397c4d72e5 Include poll.h and friends for struct pollfd. 2021-08-07 11:30:57 +10:00
djm@openbsd.org a9e2c53319 upstream: do_upload() used a near-identical structure for
tracking expected status replies from the server to what do_download() was
using.

Refactor it to use the same structure and factor out some common
code into helper functions.

OpenBSD-Commit-ID: 0c167df8ab6df4a5292c32421922b0cf379e9054
2021-08-07 10:20:31 +10:00
djm@openbsd.org 7b1cbcb759 upstream: make scp(1) in SFTP mode follow symlinks like
traditional scp(1) ok markus@

OpenBSD-Commit-ID: 97255e55be37e8e26605e4ba1e69f9781765d231
2021-08-07 10:20:31 +10:00
djm@openbsd.org 133b44e500 upstream: fix incorrect directory permissions on scp -3
transfers; ok markus@

OpenBSD-Commit-ID: 64b2abaa5635a2be65ee2e77688ad9bcebf576c2
2021-08-07 10:20:31 +10:00
djm@openbsd.org 98b59244ca upstream: a bit more debugging of file attributes being
sent/received over the wire

OpenBSD-Commit-ID: f68c4e207b08ef95200a8b2de499d422808e089b
2021-08-07 10:20:31 +10:00
djm@openbsd.org c677e65365 upstream: make scp(1) in SFTP mode output better match original
scp(1) by suppressing "Retrieving [path]" lines that were emitted to support
the interactive sftp(1) client. ok markus@

OpenBSD-Commit-ID: 06be293df5f156a18f366079be2f33fa68001acc
2021-08-07 10:20:31 +10:00
djm@openbsd.org 48cd39b7a4 upstream: factor out a structure duplicated between downloading
and crossloading; ok markus@

OpenBSD-Commit-ID: 96eede24d520569232086a129febe342e4765d39
2021-08-07 10:20:31 +10:00
djm@openbsd.org de7115b373 upstream: support for "cross"-loading files/directories, i.e.
downloading from one SFTP server while simultaneously uploading to another.

feedback & ok markus@

OpenBSD-Commit-ID: 3982878e29d8df0fa4ddc502f5ff6126ac714235
2021-08-07 10:20:24 +10:00
djm@openbsd.org a50bd0367f upstream: factor our SSH2_FXP_OPEN calls into their own function;
"looks fine" markus@

OpenBSD-Commit-ID: d3dea2153f08855c6d9dacc01973248944adeffb
2021-08-07 10:20:24 +10:00
djm@openbsd.org bda270d7fb upstream: degrade gracefully if a sftp-server offers the
limits@openssh.com extension but fails when the client tries to invoke it.
Reported by Hector Martin via bz3318

OpenBSD-Commit-ID: bd9d1839c41811616ede4da467e25746fcd9b967
2021-06-06 13:24:38 +10:00
djm@openbsd.org 31d8d231eb upstream: highly polished whitespace, mostly fixing spaces-for-tab
and bad indentation on continuation lines. Prompted by GHPR#185

OpenBSD-Commit-ID: e5c81f0cbdcc6144df1ce468ec1bac366d8ad6e9
2021-04-03 17:23:02 +11:00
djm@openbsd.org 1339800fef upstream: Use new limits@openssh.com protocol extension to let the
client select good limits based on what the server supports. Split the
download and upload buffer sizes to allow them to be chosen independently.

In practice (and assuming upgraded sftp/sftp-server at each end), this
increases the download buffer 32->64KiB and the upload buffer
32->255KiB.

Patches from Mike Frysinger; ok dtucker@

OpenBSD-Commit-ID: ebd61c80d85b951b794164acc4b2f2fd8e88606c
2021-04-01 09:20:57 +11:00
djm@openbsd.org e5895e8ecf upstream: no need to reset buffer after send_msg() as that is done
for us; patch from Mike Frysinger

OpenBSD-Commit-ID: 565516495ff8362a38231e0f1a087b8ae66da59c
2021-03-13 13:06:10 +11:00
djm@openbsd.org e4d1a0b40a upstream: shuffle a few utility functions into sftp-client.c; from
Jakub Jelen

OpenBSD-Commit-ID: fdeb1aae1f6149b193f12cd2af158f948c514a2a
2020-12-04 13:43:01 +11:00
dtucker@openbsd.org 41935882f4 upstream: When doing an sftp recursive upload or download of a
read-only directory, ensure that the directory is created with write and
execute permissions in the interim so that we can actually complete the
transfer, then set the directory permission as the final step.  (The execute
bit is only likely to be an issue with a non-POSIX server).  bz#3222, ok djm@

OpenBSD-Commit-ID: a82606212f2796e31f0e1af94a63355a7ad5d903
2020-11-20 16:58:18 +11:00
djm@openbsd.org 816036f142 upstream: use the new variant log macros instead of prepending
__func__ and appending ssh_err(r) manually; ok markus@

OpenBSD-Commit-ID: 1f14b80bcfa85414b2a1a6ff714fb5362687ace8
2020-10-18 23:46:29 +11:00
djm@openbsd.org af8b16fb2c upstream: fix off-by-one error that caused sftp downloads to make
one more concurrent request that desired. This prevented using sftp(1) in
unpipelined request/response mode, which is useful when debugging. Patch from
Stephen Goetze in bz#3054

OpenBSD-Commit-ID: 41b394ebe57037dbc43bdd0eef21ff0511191f28
2020-05-27 10:09:19 +10:00
djm@openbsd.org 07f2c7f349 upstream: fix memory leak in error path; bz#3074 patch from
krishnaiah.bommu@intel.com, ok dtucker

OpenBSD-Commit-ID: d031853f3ecf47b35a0669588f4d9d8e3b307b3c
2019-10-04 14:34:05 +10:00
djm@openbsd.org a0876bd994 upstream: print explicit "not modified" message if a file was
requested for resumed download but was considered already complete.

bz#2978 ok dtucker

OpenBSD-Commit-ID: f32084b26a662f16215ee4ca4a403d67e49ab986
2019-07-12 14:07:31 +10:00
dtucker@openbsd.org bdc6c63c80 upstream: Have progressmeter force an update at the beginning and
end of each transfer.  Fixes the problem recently introduces where very quick
transfers do not display the progressmeter at all.  Spotted by naddy@

OpenBSD-Commit-ID: 68dc46c259e8fdd4f5db3ec2a130f8e4590a7a9a
2019-01-25 06:32:14 +11:00
dtucker@openbsd.org 8976f1c4b2 upstream: Sanitize scp filenames via snmprintf. To do this we move
the progressmeter formatting outside of signal handler context and have the
atomicio callback called for EINTR too.  bz#2434 with contributions from djm
and jjelen at redhat.com, ok djm@

OpenBSD-Commit-ID: 1af61c1f70e4f3bd8ab140b9f1fa699481db57d8
2019-01-24 12:30:30 +11:00
djm@openbsd.org 60d8c84e08 upstream: Add "-h" flag to sftp chown/chgrp/chmod commands to
request they do not follow symlinks. Requires recently-committed
lsetstat@openssh.com extension on the server side.

ok markus@ dtucker@

OpenBSD-Commit-ID: f93bb3f6f7eb2fb7ef1e59126e72714f1626d604
2019-01-17 11:08:13 +11:00
djm@openbsd.org 1a66079c06 upstream: fix some memory leaks spotted by Coverity via Jakub Jelen
in bz#2366 feedback and ok dtucker@

OpenBSD-Commit-ID: 8402bbae67d578bedbadb0ce68ff7c5a136ef563
2018-07-31 13:13:26 +10:00
djm@openbsd.org f6a59a22b0 upstream: Fix return value confusion in several functions (readdir,
download and fsync). These should return -1 on error, not a sftp status code.

patch from Petr Cerny in bz#2871

OpenBSD-Commit-ID: 651aa0220ad23c9167d9297a436162d741f97a09
2018-05-25 14:27:50 +10:00
dtucker@openbsd.org 3dde09ab38 upstream commit
Have sftp print a warning about shell cleanliness when
decoding the first packet fails, which is usually caused by shells polluting
stdout of non-interactive starups.  bz#2800, ok markus@ deraadt@.

OpenBSD-Commit-ID: 88d6a9bf3470f9324b76ba1cbd53e50120f685b5
2017-12-07 11:38:50 +11:00
djm@openbsd.org 4b3ecbb663 upstream commit
don't print verbose error message when ssh disconnects
under sftp; bz#2750; ok dtucker@

Upstream-ID: 6d83708aed77b933c47cf155a87dc753ec01f370
2017-08-12 16:47:10 +10:00
Damien Miller 89f04852db on Cygwin, check paths from server for backslashes
Pointed out by Jann Horn of Google Project Zero
2017-03-20 11:53:34 +11:00
djm@openbsd.org c7995f296b upstream commit
check number of entries in SSH2_FXP_NAME response; avoids
unreachable overflow later. Reported by Jann Horn

Upstream-ID: b6b2b434a6d6035b1644ca44f24cd8104057420f
2017-01-04 13:23:04 +11:00
deraadt@openbsd.org 9136ec134c upstream commit
Add MAXIMUM(), MINIMUM(), and ROUNDUP() to misc.h, then
use those definitions rather than pulling <sys/param.h> and unknown namespace
pollution. ok djm markus dtucker

Upstream-ID: 712cafa816c9f012a61628b66b9fbd5687223fb8
2016-09-12 13:46:29 +10:00
schwarze@openbsd.org 0e059cdf5f upstream commit
To prevent screwing up terminal settings when printing to
 the terminal, for ASCII and UTF-8, escape bytes not forming characters and
 bytes forming non-printable characters with vis(3) VIS_OCTAL. For other
 character sets, abort printing of the current string in these cases.  In
 particular, * let scp(1) respect the local user's LC_CTYPE locale(1); *
 sanitize data received from the remote host; * sanitize filenames, usernames,
 and similar data even locally; * take character display widths into account
 for the progressmeter.

This is believed to be sufficient to keep the local terminal safe
on OpenBSD, but bad things can still happen on other systems with
state-dependent locales because many places in the code print
unencoded ASCII characters into the output stream.

Using feedback from djm@ and martijn@,
various aspects discussed with many others.

deraadt@ says it should go in now, i probably already hesitated too long

Upstream-ID: e66afbc94ee396ddcaffd433b9a3b80f387647e0
2016-06-06 11:27:38 +10:00
djm@openbsd.org 1a31d02b24 upstream commit
fix signed/unsigned errors reported by clang-3.7; add
 sshbuf_dup_string() to replace a common idiom of strdup(sshbuf_ptr()) with
 better safety checking; feedback and ok markus@

Upstream-ID: 71f926d9bb3f1efed51319a6daf37e93d57c8820
2016-05-02 20:35:04 +10:00
djm@openbsd.org 34a01b2cf7 upstream commit
whitespace at EOL

Upstream-ID: 5beffd4e001515da12851b974e2323ae4aa313b6
2016-04-08 18:21:51 +10:00
djm@openbsd.org e30cabfa4a upstream commit
fix regression in openssh-6.8 sftp client: existing
 destination directories would incorrectly terminate recursive uploads;
 bz#2528

Upstream-ID: 3306be469f41f26758e3d447987ac6d662623e18
2016-02-11 13:22:05 +11:00
djm@openbsd.org 9cc6842493 upstream commit
add error message on ftruncate failure; bz#2176

Upstream-ID: cbcc606e0b748520c74a210d8f3cc9718d3148cf
2015-05-28 18:54:55 +10:00
jsg@openbsd.org 64a89ec076 upstream commit
fix a memory leak in an error path ok markus@ dtucker@

Upstream-ID: bc1da0f205494944918533d8780fde65dff6c598
2015-05-25 09:49:46 +10:00
deraadt@openbsd.org 657a5fbc0d upstream commit
rename xrealloc() to xreallocarray() since it follows
 that form. ok djm
2015-04-29 18:15:23 +10:00
deraadt@openbsd.org 087266ec33 upstream commit
Reduce use of <sys/param.h> and transition to <limits.h>
 throughout. ok djm markus
2015-01-26 23:58:53 +11:00
djm@openbsd.org 7d845f4a0b upstream commit
update sftp client and server to new buffer API. pretty
 much just mechanical changes; with & ok markus
2015-01-15 02:22:18 +11:00
Damien Miller d8accc0aa7 - logan@cvs.openbsd.org 2014/04/21 14:36:16
[sftp-client.c sftp-client.h sftp.c]
     Implement sftp upload resume support.
     OK from djm@, with input from guenther@, mlarkin@ and
     okan@
2014-05-15 13:46:25 +10:00
Damien Miller 1d2c456426 - tedu@cvs.openbsd.org 2014/01/31 16:39:19
[auth2-chall.c authfd.c authfile.c bufaux.c bufec.c canohost.c]
     [channels.c cipher-chachapoly.c clientloop.c configure.ac hostfile.c]
     [kexc25519.c krl.c monitor.c sandbox-systrace.c session.c]
     [sftp-client.c ssh-keygen.c ssh.c sshconnect2.c sshd.c sshlogin.c]
     [openbsd-compat/explicit_bzero.c openbsd-compat/openbsd-compat.h]
     replace most bzero with explicit_bzero, except a few that cna be memset
     ok djm dtucker
2014-02-04 11:18:20 +11:00
Darren Tucker 5f1c57a7a7 - djm@cvs.openbsd.org 2014/01/17 00:21:06
[sftp-client.c]
     signed/unsigned comparison warning fix; from portable (Id sync only)
2014-01-17 16:29:45 +11:00
Damien Miller c3d483f9a8 - (djm) [sftp-client.c] signed/unsigned comparison fix 2014-01-17 11:20:26 +11:00
Damien Miller 52c371cd6d - djm@cvs.openbsd.org 2014/01/16 07:31:09
[sftp-client.c]
     needless and incorrect cast to size_t can break resumption of
     large download; patch from tobias@
2014-01-16 18:42:10 +11:00
Damien Miller 393920745f - djm@cvs.openbsd.org 2013/12/05 22:59:45
[sftp-client.c]
     fix memory leak in error path in do_readdir(); pointed out by
     Loganaden Velvindron @ AfriNIC in bz#2163
2013-12-07 10:31:08 +11:00
Damien Miller 9275df3e0a - djm@cvs.openbsd.org 2013/12/04 04:20:01
[sftp-client.c]
     bz#2171: don't leak local_fd on error; from Loganaden Velvindron @
     AfriNIC
2013-12-05 10:26:32 +11:00
Damien Miller 0600c7020f - dtucker@cvs.openbsd.org 2013/11/08 11:15:19
[bufaux.c bufbn.c buffer.c sftp-client.c sftp-common.c sftp-glob.c]
     [uidswap.c] Include stdlib.h for free() as per the man page.
2013-11-21 13:55:43 +11:00
Damien Miller 6c81fee693 - djm@cvs.openbsd.org 2013/11/08 00:39:15
[auth-options.c auth2-chall.c authfd.c channels.c cipher-3des1.c]
     [clientloop.c gss-genr.c monitor_mm.c packet.c schnorr.c umac.c]
     [sftp-client.c sftp-glob.c]
     use calloc for all structure allocations; from markus@
2013-11-08 12:19:55 +11:00