summaryrefslogtreecommitdiff
path: root/scp.c
Commit message (Collapse)AuthorAgeFilesLines
* upstream: For open/openat, if the flags parameter does not containderaadt@openbsd.org2021-10-281-2/+2
| | | | | | | | | | | | | | | O_CREAT, the 3rd (variadic) mode_t parameter is irrelevant. Many developers in the past have passed mode_t (0, 044, 0644, or such), which might lead future people to copy this broken idiom, and perhaps even believe this parameter has some meaning or implication or application. Delete them all. This comes out of a conversation where tb@ noticed that a strange (but intentional) pledge behaviour is to always knock-out high-bits from mode_t on a number of system calls as a safety factor, and his bewilderment that this appeared to be happening against valid modes (at least visually), but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef. ok millert OpenBSD-Commit-ID: 503d11633497115688c0c6952686524f01f53121
* upstream: switch scp(1) back to sftp protocol.deraadt@openbsd.org2021-10-221-2/+2
| | | | | | | openbsd 7.0 release shipped with the (hopefully last) scp that uses RCP protocol for copying. Let's get back to testing the SFTP protocol. OpenBSD-Commit-ID: 9eaa35d95fd547b78b0a043b3f518e135f151f30
* upstream: fix missing -s in SYNOPSYS and usage() as well as adjm@openbsd.org2021-09-211-2/+2
| | | | | | capitalisation mistake; spotted by jmc@ OpenBSD-Commit-ID: 0ed8ee085c7503c60578941d8b45f3a61d4c9710
* upstream: Switch scp back to use the old protocol by default, ahead ofdjm@openbsd.org2021-09-201-2/+2
| | | | | | | | release. We'll wait a little longer for people to pick up sftp-server(8) that supports the extension that scp needs for ~user paths to continue working in SFTP protocol mode. Discussed with deraadt@ OpenBSD-Commit-ID: f281f603a705fba317ff076e7b11bcf2df941871
* upstream: better error message for ~user failures when thedjm@openbsd.org2021-09-191-2/+3
| | | | | | sftp-server lacks the expand-path extension; ok deraadt@ OpenBSD-Commit-ID: 9c1d965d389411f7e86f0a445158bf09b8f9e4bc
* upstream: make some more scp-in-SFTP mode better match Unix idiomsdjm@openbsd.org2021-09-191-9/+8
| | | | | | suggested by deraadt@ OpenBSD-Commit-ID: 0f2439404ed4cf0b0be8bf49a1ee734836e1ac87
* upstream: allow log_stderr==2 to prefix log messages with argv[0]djm@openbsd.org2021-09-191-7/+5
| | | | | | | | use this to make scp's SFTP mode error messages more scp-like prompted by and ok deraadt@ OpenBSD-Commit-ID: 0e821dbde423fc2280e47414bdc22aaa5b4e0733
* upstream: when using SFTP protocol, continue transferring files after adjm@openbsd.org2021-09-111-6/+10
| | | | | | transfer error occurs. This matches original scp/rcp behaviour. ok dtucker@ OpenBSD-Commit-ID: dfe4558d71dd09707e9b5d6e7d2e53b793da69fa
* upstream: Use the SFTP protocol by default. The original scp/rcpdjm@openbsd.org2021-09-091-3/+3
| | | | | | | | | | | protocol remains available via the -O flag. Note that ~user/ prefixed paths in SFTP mode require a protocol extension that was first shipped in OpenSSH 8.7. ok deraadt, after baking in snaps for a while without incident OpenBSD-Commit-ID: 23588976e28c281ff5988da0848cb821fec9213c
* upstream: scp: tweak man page and error message for -3 by defaultnaddy@openbsd.org2021-08-121-2/+2
| | | | | | | | | Now that the -3 option is enabled by default, flip the documentation and error message logic from "requires -3" to "blocked by -R". ok djm@ OpenBSD-Commit-ID: a872592118444fb3acda5267b2a8c3d4c4252020
* upstream: scp: do not spawn ssh with two -s flags fornaddy@openbsd.org2021-08-121-14/+13
| | | | | | | | | | | | remote-to-remote copies Do not add another "-s" to the argument vector every time an SFTP connection is initiated. Instead, introduce a subsystem flag to do_cmd() and add "-s" when the flag is set. ok djm@ OpenBSD-Commit-ID: 25df69759f323661d31b2e1e790faa22e27966c1
* upstream: Prepare for a future where scp(1) uses the SFTP protocol bydjm@openbsd.org2021-08-101-13/+10
| | | | | | | | | | default. Replace recently added -M option to select the protocol with -O (olde) and -s (SFTP) flags, and label the -s flag with a clear warning that it will be removed in the near future (so no, don't use it in scripts!). prompted by/feedback from deraadt@ OpenBSD-Commit-ID: 92ad72cc6f0023c9be9e316d8b30eb6d8d749cfc
* upstream: make scp -3 the default for remote-to-remote copies. Itdjm@openbsd.org2021-08-101-4/+7
| | | | | | | | | | | | | provides a much better and more intuitive user experience and doesn't require exposing credentials to the source host. thanks naddy@ for catching the missing argument in usage() "Yes please!" - markus@ "makes a lot of sense" - deraadt@ "the right thing to do" - dtucker@ OpenBSD-Commit-ID: d0d2af5f0965c5192ba5b2fa461c9f9b130e5dd9
* upstream: make scp in SFTP mode try to use relative paths as muchdjm@openbsd.org2021-08-101-71/+26
| | | | | | | | | | as possible. Previosuly, it would try to make relative and ~/-rooted paths absolute before requesting transfers. prompted by and much discussion deraadt@ ok markus@ OpenBSD-Commit-ID: 46639d382ea99546a4914b545fa7b00fa1be5566
* upstream: SFTP protocol extension to allow the server to expanddjm@openbsd.org2021-08-101-6/+11
| | | | | | | | | | ~-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
* upstream: when scp is in SFTP mode, try to deal better with ~djm@openbsd.org2021-08-101-10/+34
| | | | | | | | | | prefixed paths. ~user paths aren't supported, but ~/ paths will be accepted and prefixed with the SFTP server starting directory (more to come) prompted by and discussed with deraadt@ ok markus@ OpenBSD-Commit-ID: 263a071f14555c045fd03132a8fb6cbd983df00d
* upstream: on fatal errors, make scp wait for ssh connection beforedjm@openbsd.org2021-08-101-1/+19
| | | | | | | | | | | exiting avoids LogLevel=verbose (or greater) messages from ssh appearing after scp has returned exited and control has returned to the shell; ok markus@ (this was originally committed as r1.223 along with unrelated stuff that I rolled back in r1.224) OpenBSD-Commit-ID: 1261fd667ad918484889ed3d7aec074f3956a74b
* upstream: rever r1.223 - I accidentally committed unrelated changesdjm@openbsd.org2021-08-101-64/+25
| | | | OpenBSD-Commit-ID: fb73f3865b2647a27dd94db73d6589506a9625f9
* upstream: on fatal errors, make scp wait for ssh connection beforedjm@openbsd.org2021-08-101-25/+64
| | | | | | | | exiting avoids LogLevel=verbose (or greater) messages from ssh appearing after scp has returned exited and control has returned to the shell; ok markus@ OpenBSD-Commit-ID: ef9dab5ef5ae54a6a4c3b15d380568e94263456c
* upstream: Fix prototype mismatch for do_cmd. ok djm@dtucker@openbsd.org2021-08-071-2/+2
| | | | OpenBSD-Commit-ID: 1c1598bb5237a7ae0be99152f185e0071163714d
* upstream: make scp(1) in SFTP mode follow symlinks likedjm@openbsd.org2021-08-071-4/+4
| | | | | | traditional scp(1) ok markus@ OpenBSD-Commit-ID: 97255e55be37e8e26605e4ba1e69f9781765d231
* upstream: make scp(1) in SFTP mode output better match originaldjm@openbsd.org2021-08-071-3/+4
| | | | | | | scp(1) by suppressing "Retrieving [path]" lines that were emitted to support the interactive sftp(1) client. ok markus@ OpenBSD-Commit-ID: 06be293df5f156a18f366079be2f33fa68001acc
* upstream: use sftp_client crossloading to implement scp -3djm@openbsd.org2021-08-071-40/+189
| | | | | | feedback/ok markus@ OpenBSD-Commit-ID: 7db4c0086cfc12afc9cfb71d4c2fd3c7e9416ee9
* upstream: prepare for scp -3 implemented via sftpdjm@openbsd.org2021-08-071-19/+6
| | | | OpenBSD-Commit-ID: 194aac0dd87cb175334b71c2a30623a5ad55bb44
* upstream: Allow for different (but POSIX compliant) behaviour ofdtucker@openbsd.org2021-08-041-3/+4
| | | | | | | | | | | | | | | basename(3) and prevent a use-after-free in that case in the new sftp-compat code. POSIX allows basename(3) to either return a pointer to static storage or modify the passed string and return a pointer to that. OpenBSD does the former and works as is, but on other platforms "filename" points into "tmp" which was just freed. This makes the freeing of tmp consistent with the other variable in the loop. Pinpointed by the -portable Valgrind regress test. ok djm@ deraadt@ OpenBSD-Commit-ID: 750f3c19bd4440e4210e30dd5d7367386e833374
* use openbsd-compat glob.h is requiredDamien Miller2021-08-041-1/+5
|
* upstream: support for using the SFTP protocol for file transfers indjm@openbsd.org2021-08-031-23/+281
| | | | | | | | | | | | | scp, via a new "-M sftp" option. Marked as experimental for now. Some corner-cases exist, in particular there is no attempt to provide bug-compatibility with scp's weird "double shell" quoting rules. Mostly by Jakub Jelen in GHPR#194 with some tweaks by me. ok markus@ Thanks jmc@ for improving the scp.1 bits. OpenBSD-Commit-ID: 6ce4c9157ff17b650ace571c9f7793d92874051c
* upstream: allow spaces to appear in usernames for local to remote,djm@openbsd.org2021-07-051-5/+10
| | | | | | and scp -3 remote to remote copies. with & ok dtucker bz#1164 OpenBSD-Commit-ID: e9b550f3a85ffbb079b6720833da31317901d6dd
* upstream: highly polished whitespace, mostly fixing spaces-for-tabdjm@openbsd.org2021-04-031-4/+3
| | | | | | and bad indentation on continuation lines. Prompted by GHPR#185 OpenBSD-Commit-ID: e5c81f0cbdcc6144df1ce468ec1bac366d8ad6e9
* upstream: use the new variant log macros instead of prependingdjm@openbsd.org2020-10-181-3/+3
| | | | | | __func__ and appending ssh_err(r) manually; ok markus@ OpenBSD-Commit-ID: 1f14b80bcfa85414b2a1a6ff714fb5362687ace8
* upstream: allow -A to explicitly enable agent forwarding in scp anddjm@openbsd.org2020-08-031-4/+7
| | | | | | | sftp. The default remains to not forward an agent, even when ssh_config enables it. ok jmc dtucker markus OpenBSD-Commit-ID: 36cc526aa3b0f94e4704b8d7b969dd63e8576822
* upstream: Fix error message on close(2) and add printf formatmillert@openbsd.org2020-05-301-4/+7
| | | | | | attributes. From Christos Zoulas, OK markus@ OpenBSD-Commit-ID: 41523c999a9e3561fcc7082fd38ea2e0629ee07e
* upstream: another case where a utimes() failure could make scp senddjm@openbsd.org2020-05-071-4/+2
| | | | | | a desynchronising error; reminded by Aymeric Vincent ok deraadt markus OpenBSD-Commit-ID: 2ea611d34d8ff6d703a7a8bf858aa5dbfbfa7381
* upstream: when receving a file in sink(), be careful to send atdjm@openbsd.org2020-05-011-37/+59
| | | | | | | | | | most a single error response after the file has been opened. Otherwise the source() and sink() can become desyncronised. Reported by Daniel Goujot, Georges-Axel Jaloyan, Ryan Lahfa, and David Naccache. ok deraadt@ markus@ OpenBSD-Commit-ID: 6c14d233c97349cb811a8f7921ded3ae7d9e0035
* upstream: run the 2nd ssh with BatchMode for scp -3markus@openbsd.org2020-05-011-1/+2
| | | | OpenBSD-Commit-ID: 77994fc8c7ca02d88e6d0d06d0f0fe842a935748
* upstream: Replace all calls to signal(2) with a wrapper arounddtucker@openbsd.org2020-01-231-11/+11
| | | | | | | | 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
* Hook up fnmatch for platforms that don't have it.Darren Tucker2019-11-011-0/+2
|
* wrap stdint.h include in HAVE_STDINT_HDamien Miller2019-10-091-1/+1
| | | | | | make the indenting a little more consistent too.. Fixes Solaris 2.6; reported by Tom G. Christensen
* upstream: Fix potential truncation warning. ok deraadt.dtucker@openbsd.org2019-09-131-2/+2
| | | | OpenBSD-Commit-ID: d87b7e3a94ec935e8194e7fce41815e22804c3ff
* upstream: When system calls indicate an error they return -1, notderaadt@openbsd.org2019-07-051-12/+12
| | | | | | | | some arbitrary value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future. OpenBSD-Commit-ID: 48081f00db7518e3b712a49dca06efc2a5428075
* upstream: when checking that filenames sent by the server sidedjm@openbsd.org2019-02-101-12/+270
| | | | | | | | | | match what the client requested, be prepared to handle shell-style brace alternations, e.g. "{foo,bar}". "looks good to me" millert@ + in snaps for the last week courtesy deraadt@ OpenBSD-Commit-ID: 3b1ce7639b0b25b2248e3a30f561a548f6815f3e
* upstream: add -T to usage();jmc@openbsd.org2019-02-011-2/+2
| | | | OpenBSD-Commit-ID: a7ae14d9436c64e1bd05022329187ea3a0ce1899
* upstream: check in scp client that filenames sent duringdjm@openbsd.org2019-01-271-9/+30
| | | | | | | | | | | | | | | | remote->local directory copies satisfy the wildcard specified by the user. This checking provides some protection against a malicious server sending unexpected filenames, but it comes at a risk of rejecting wanted files due to differences between client and server wildcard expansion rules. For this reason, this also adds a new -T flag to disable the check. reported by Harry Sintonen fix approach suggested by markus@; has been in snaps for ~1wk courtesy deraadt@ OpenBSD-Commit-ID: 00f44b50d2be8e321973f3c6d014260f8f7a8eda
* upstream: Have progressmeter force an update at the beginning anddtucker@openbsd.org2019-01-251-2/+2
| | | | | | | 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
* upstream: Sanitize scp filenames via snmprintf. To do this we movedtucker@openbsd.org2019-01-241-1/+2
| | | | | | | | 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
* upstream: Add a -J option as a shortcut for -o Proxyjump= to scp(1)tb@openbsd.org2019-01-221-3/+5
| | | | | | | | and sftp(1) to match ssh(1)'s interface. ok djm OpenBSD-Commit-ID: a75bc2d5f329caa7229a7e9fe346c4f41c2663fc
* refactor libcrypto initialisationDamien Miller2018-11-231-0/+2
| | | | | | | | | | 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
* upstream: disallow empty incoming filename or ones that refer to thedjm@openbsd.org2018-11-161-2/+3
| | | | | | current directory; based on report/patch from Harry Sintonen OpenBSD-Commit-ID: f27651b30eaee2df49540ab68d030865c04f6de9
* upstream: Apply umask to all incoming files and directories notdtucker@openbsd.org2018-06-041-1/+3
| | | | | | | just files. This makes sure it gets applied to directories too, and prevents a race where files get chmodded after creation. bz#2839, ok djm@ OpenBSD-Commit-ID: 3168ee6c7c39093adac4fd71039600cfa296203b
* upstream: lots of typos in comments/docs. Patch from Karsten Weissdjm@openbsd.org2018-04-101-2/+2
| | | | | | | after checking with codespell tool (https://github.com/lucasdemarchi/codespell) OpenBSD-Commit-ID: 373222f12d7ab606598a2d36840c60be93568528