Commit Graph

241 Commits

Author SHA1 Message Date
djm@openbsd.org 9d95252911
upstream: use users-groups-by-id@openssh.com sftp-server extension
(when available) to fill in user/group names for directory listings.
Implement a client-side cache of see uid/gid=>user/group names. ok markus@

OpenBSD-Commit-ID: f239aeeadfa925a37ceee36ee8b256b8ccf4466e
2022-09-19 20:51:14 +10:00
djm@openbsd.org 488f6e1c58
upstream: extend sftp-common.c:extend ls_file() to support supplied
user/group names; ok markus@

OpenBSD-Commit-ID: c70c70498b1fdcf158531117e405b6245863bfb0
2022-09-19 20:49:13 +10:00
djm@openbsd.org ac1ec95459
upstream: sftp: Be a bit more clever about completions
There are commands (e.g. "get" or "put") that accept two
arguments, a local path and a remote path. However, the way
current completion is written doesn't take this distinction into
account and always completes remote or local paths.

By expanding CMD struct and "cmds" array this distinction can be
reflected and with small adjustment to completer code the correct
path can be completed.

By Michal Privoznik, ok dtucker@

OpenBSD-Commit-ID: 1396d921c4eb1befd531f5c4a8ab47e7a74b610b
2022-09-16 13:35:22 +10:00
djm@openbsd.org 590db83384
upstream: sftp: Don't attempt to complete arguments for
non-existent commands

If user entered a non-existent command (e.g. because they made a
typo) there is no point in trying to complete its arguments. Skip
calling complete_match() if that's the case.

From Michal Privoznik

OpenBSD-Commit-ID: cf39c811a68cde2aeb98fc85addea4000ef6b07a
2022-09-16 13:35:21 +10:00
Darren Tucker 1bdf86725b Remove seed_rng calls from scp, sftp, sftp-server.
These binaries don't use OpenSSL's random functions.  The next step
will be to stop linking them against libcrypto.  ok djm@
2022-07-27 16:22:30 +10:00
jmc@openbsd.org 33efac790f upstream: reflect the update to -D arg name in usage();
OpenBSD-Commit-ID: abdcde4f92b1ef094ae44210ee99d3b0155aad9c
2022-07-01 10:37:46 +10:00
djm@openbsd.org 2a822f2930 upstream: allow arguments to sftp -D option, e.g. sftp -D
"/usr/libexec/sftp-server -el debug3"

ok markus@

OpenBSD-Commit-ID: 5a002b9f3a7aef2731fc0ffa9c921cf15f38ecce
2022-06-28 07:43:15 +10:00
djm@openbsd.org 56a0697fe0 upstream: arrange for scp, when in sftp mode, to not ftruncate(3) files
early

previous behavious of unconditionally truncating the destination file
would cause "scp ~/foo localhost:" and "scp localhost:foo ~/" to
delete all the contents of their destination.

spotted by solene@ sthen@, also bz3431; ok dtucker@

OpenBSD-Commit-ID: ca39fdd39e0ec1466b9666f15cbcfddea6aaa179
2022-05-13 17:00:56 +10:00
djm@openbsd.org deb506d00d upstream: When performing operations that glob(3) a remote path, ensure
that the implicit working directory used to construct that path escapes
glob(3) characters.

This prevents glob characters from being processed in places they
shouldn't, e.g. "cd /tmp/a*/", "get *.txt" should have the get operation
treat the path "/tmp/a*" literally and not attempt to expand it.

Reported by Lusia Kundel; ok markus@

OpenBSD-Commit-ID: 4f647f58482cbad3d58b1eab7f6a1691433deeef
2022-05-09 08:33:59 +10:00
djm@openbsd.org 3fa539c3ff upstream: add a sftp client "cp" command that supports server-side
copying of files. Useful for this task and for testing the copy-data
extension. Patch from Mike Frysinger; ok dtucker@

OpenBSD-Commit-ID: 1bb1b950af0d49f0d5425b1f267e197aa1b57444
2022-03-31 14:09:42 +11:00
djm@openbsd.org 1c83c08212 upstream: remove blank line
OpenBSD-Commit-ID: d5e0182965b2fbfb03ad5f256d1a1ce5706bcddf
2022-03-20 19:54:35 +11:00
Damien Miller 715c892f0a remove sys/param.h in -portable, after upstream 2021-12-22 09:02:50 +11:00
schwarze@openbsd.org 19b3d846f0 upstream: Do not ignore SIGINT while waiting for input if editline(3)
is not used. Instead, in non-interactive mode, exit sftp(1), like for other
serious errors. As pointed out by dtucker@, when compiled without editline(3)
support in portable OpenSSH, the el == NULL branch is also used for
interactive mode. In that case, discard the input line and provide a fresh
prompt to the user just like in the case where editline(3) is used. OK djm@

OpenBSD-Commit-ID: 7d06f4d3ebba62115527fafacf38370d09dfb393
2021-09-11 20:26:51 +10:00
schwarze@openbsd.org 090a82486e upstream: In the editline(3) branch of the sftp(1) event loop,
handle SIGINT rather than ignoring it, such that the user can use Ctrl-C to
discard the currently edited command line and get a fresh prompt, just like
in ftp(1), bc(1), and in shells.

It is critical to not use ssl_signal() for this particular case
because that function unconditionally sets SA_RESTART, but here we
need the signal to interrupt the read(2) in the el_gets(3) event loop.

OK dtucker@ deraadt@

OpenBSD-Commit-ID: 8025115a773f52e9bb562eaab37ea2e021cc7299
2021-08-12 23:05:33 +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 dc1b45841f upstream: typos in comments; GHPR#180 from Vill
=?UTF-8?q?e=20Skytt=C3=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

OpenBSD-Commit-ID: 93c732381ae0e2b680c79e67c40c1814b7ceed2c
2021-04-03 17:59:32 +11:00
Damien Miller 57ed647ee0 polish whitespace for portable files 2021-04-03 17:47:37 +11: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 64ddd0fe68 upstream: don't try to use timespeccmp(3) directly as a qsort(3)
comparison function - it returns 0/1 and not the -1/0/1 that qsort expectes.

fixes sftp "ls -ltr" under some circumstances.

Based on patch by Masahiro Matsuya via bz3248.

OpenBSD-Commit-ID: 65b5e9f18bb0d10573868c3516de6e5170adb163
2021-01-08 13:50:46 +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
djm@openbsd.org 1a14c13147 upstream: whitespace; no code change
OpenBSD-Commit-ID: efefc1c47e880887bdee8cd2127ca93177eaad79
2020-10-29 13:54:13 +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
dtucker@openbsd.org 2d39fc9f7e upstream: Allow full range of UIDs and GIDs for sftp chown and
chgrp on 32bit platforms instead of being limited by LONG_MAX.  bz#3206,
found by booking00 at sina.cn, ok markus@

OpenBSD-Commit-ID: 373b7bbf1f15ae482d39567ce30d18b51c9229b5
2020-10-07 13:33:12 +11:00
djm@openbsd.org a8732d74cb upstream: allow -A to explicitly enable agent forwarding in scp and
sftp. The default remains to not forward an agent, even when ssh_config
enables it. ok jmc dtucker markus

OpenBSD-Commit-ID: 36cc526aa3b0f94e4704b8d7b969dd63e8576822
2020-08-03 14:27:59 +10:00
jmc@openbsd.org 668cb3585c upstream: sort -N and add it to usage();
OpenBSD-Commit-ID: 5b00e8db37c2b0a54c7831fed9e5f4db53ada332
2020-04-03 17:09:42 +11:00
djm@openbsd.org 9cd40b829a upstream: Add a flag to re-enable verbose output when in batch
mode; requested in bz3135; ok dtucker

OpenBSD-Commit-ID: 5ad2ed0e6440562ba9c84b666a5bbddc1afe2e2b
2020-04-03 15:41:28 +11:00
dtucker@openbsd.org 9e3220b585 upstream: Have sftp reject "-1" in the same way as ssh(1) and
scp(1) do instead of accepting and silently ignoring it since protocol 1
support has been removed.  Spotted by shivakumar2696 at gmail.com, ok
deraadt@

OpenBSD-Commit-ID: b79f95559a1c993214f4ec9ae3c34caa87e9d5de
2020-02-26 23:07:02 +11:00
dtucker@openbsd.org 3bf2a6ac79 upstream: Replace all calls to signal(2) with a wrapper around
sigaction(2). This wrapper blocks all other signals during the handler
preventing races between handlers, and sets SA_RESTART which should reduce
the potential for short read/write operations.

OpenBSD-Commit-ID: 5e047663fd77a40d7b07bdabe68529df51fd2519
2020-01-23 18:51:25 +11:00
djm@openbsd.org 4332b4fe49 upstream: fix a race condition in the SIGCHILD handler that could turn
in to a kill(-1); bz3084, reported by Gao Rui, ok dtucker@

OpenBSD-Commit-ID: ac2742e04a69d4c34223505b6a32f6d686e18896
2019-11-01 14:56:38 +11:00
djm@openbsd.org d0c3ac427f upstream: remove some duplicate #includes
OpenBSD-Commit-ID: ed6827ab921eff8027669848ef4f70dc1da4098c
2019-10-02 10:43:47 +10:00
tb@openbsd.org b9b0f2ac96 upstream: Fix a typo and make <esc><right> move right to the
closest end of a word just like <esc><left> moves left to the closest
beginning of a word.

ok djm

OpenBSD-Commit-ID: 6afe01b05ed52d8b12eb1fda6e9af5afb5e198ee
2019-07-12 14:07:31 +10:00
jmc@openbsd.org 5f68ab436b upstream: from tim: - for reput, it is remote-path which is
optional, not local-path - sync help

from deraadt:
- prefer -R and undocument -r (but add a comment for future editors)

from schwarze:
- prefer -p and undocument -P (as above. the comment was schwarze's too)

more:
- add the -f flag to reput and reget
- sort help (i can;t remember who suggested this originally)

djm and deraadt were ok with earlier versions of this;
tim and schwarze ok

OpenBSD-Commit-ID: 3c699b53b46111f5c57eed4533f132e7e58bacdd
2019-06-21 13:21:13 +10:00
dtucker@openbsd.org 25e3bccbaa upstream: Check for user@host when parsing sftp target. This
allows user@[1.2.3.4] to work without a path in addition to with one.
bz#2999, ok djm@

OpenBSD-Commit-ID: d989217110932490ba8ce92127a9a6838878928b
2019-06-08 00:25:42 +10:00
otto@openbsd.org 0323d9b619 upstream: Replace calls to ssh_malloc_init() by a static init of
malloc_options. Prepares for changes in the way malloc is initialized.  ok
guenther@ dtucker@

OpenBSD-Commit-ID: 154f4e3e174f614b09f792d4d06575e08de58a6b
2019-06-08 00:25:42 +10:00
tb@openbsd.org 622dedf1a8 upstream: Add a -J option as a shortcut for -o Proxyjump= to scp(1)
and sftp(1) to match ssh(1)'s interface.

ok djm

OpenBSD-Commit-ID: a75bc2d5f329caa7229a7e9fe346c4f41c2663fc
2019-01-22 22:42:01 +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
Damien Miller 42c5ec4b97 refactor libcrypto initialisation
Don't call OpenSSL_add_all_algorithms() unless OpenSSL actually
supports it.

Move all libcrypto initialisation to a single function, and call that
from seed_rng() that is called early in each tool's main().

Prompted by patch from Rosen Penev
2018-11-23 10:42:05 +11:00
djm@openbsd.org 2a35862e66 upstream: use path_absolute() for pathname checks; from Manoj Ampalam
OpenBSD-Commit-ID: 482ce71a5ea5c5f3bc4d00fd719481a6a584d925
2018-11-16 14:37:33 +11:00
djm@openbsd.org 5c1a63562c upstream: support a prefix of '@' to suppress echo of sftp batch
commands; bz#2926; ok dtucker@

OpenBSD-Commit-ID: 9d635636bc84aeae796467e059f7634de990a79d
2018-11-16 13:51:58 +11:00
dtucker@openbsd.org de37ca9094 upstream: Add FALLTHROUGH comments where appropriate. Patch from
jjelen at redhat via bz#2687.

OpenBSD-Commit-ID: c48eb457be697a19d6d2950c6d0879f3ccc851d3
2018-09-09 14:50:32 +10:00
bluhm@openbsd.org e7751aa409 upstream: Since the previous commit, ssh regress test sftp-chroot was
failing. The sftp program terminated with the wrong exit code as sftp called
fatal() instad of exit(0).  So when the sigchld handler waits for the child,
remember that it was found.  Then don't expect that main() can wait again. OK
dtucker@

OpenBSD-Commit-ID: bfafd940c0de5297940c71ddf362053db0232266
2018-05-11 13:10:49 +10:00
djm@openbsd.org 3455f1e7c4 upstream: notify user immediately when underlying ssh process dies;
patch from Thomas Kuthan in bz2719; ok dtucker@

OpenBSD-Commit-ID: 78fac88c2f08054d1fc5162c43c24162b131cf78
2018-04-15 07:52:56 +10:00
djm@openbsd.org 001aa55484 upstream: lots of typos in comments/docs. Patch from Karsten Weiss
after checking with codespell tool
(https://github.com/lucasdemarchi/codespell)

OpenBSD-Commit-ID: 373222f12d7ab606598a2d36840c60be93568528
2018-04-10 10:17:15 +10:00
djm@openbsd.org@openbsd.org fbe8e7ac94 upstream commit
allow "cd" and "lcd" commands with no explicit path
argument. lcd will change to the local user's home directory as usual. cd
will change to the starting directory for session (because the protocol
offers no way to obtain the remote user's home directory). bz#2760 ok
dtucker@

OpenBSD-Commit-ID: 15333f5087cee8c1ed1330cac1bd0a3e6a767393
2017-11-03 16:20:41 +11:00
millert@openbsd.org 887669ef03 upstream commit
Add URI support to ssh, sftp and scp.  For example
ssh://user@host or sftp://user@host/path.  The connection parameters
described in draft-ietf-secsh-scp-sftp-ssh-uri-04 are not implemented since
the ssh fingerprint format in the draft uses md5 with no way to specify the
hash function type.  OK djm@

Upstream-ID: 4ba3768b662d6722de59e6ecb00abf2d4bf9cacc
2017-10-23 16:10:08 +11:00
Damien Miller bcd1485075 portability for sftp globbed ls sort by mtime
Include replacement timespeccmp() for systems that lack it.
Support time_t struct stat->st_mtime in addition to
timespec stat->st_mtim, as well as unsorted fallback.
2017-06-10 23:41:25 +10:00
djm@openbsd.org 72be5b2f8e upstream commit
implement sorting for globbed ls; bz#2649 ok dtucker@

Upstream-ID: ed3110f351cc9703411bf847ba864041fb7216a8
2017-06-10 16:40:11 +10:00
djm@openbsd.org 3575f0b12a upstream commit
remove -1 / -2 options; pointed out by jmc@

Upstream-ID: 65d2a816000741a95df1c7cfdb5fa8469fcc7daa
2017-05-08 09:18:04 +10:00
djm@openbsd.org 6d5a41b38b upstream commit
fix division by zero crash in "df" output when server
returns zero total filesystem blocks/inodes. Spotted by Guido Vranken; ok
dtucker@

Upstream-ID: 6fb6c2ae6b289aa07b6232dbc0be54682ef5419f
2017-02-17 14:52:24 +11:00