- djm@cvs.openbsd.org 2009/08/12 00:13:00

[sftp.c sftp.1]
     support most of scp(1)'s commandline arguments in sftp(1), as a first
     step towards making sftp(1) a drop-in replacement for scp(1).
     One conflicting option (-P) has not been changed, pending further
     discussion.
     Patch from carlosvsilvapt@gmail.com as part of his work in the
     Google Summer of Code
This commit is contained in:
Darren Tucker 2009-10-07 08:21:48 +11:00
parent 350666d300
commit 46bbbe3326
3 changed files with 75 additions and 24 deletions

View File

@ -1,3 +1,14 @@
20091007
- (dtucker) OpenBSD CVS Sync
- djm@cvs.openbsd.org 2009/08/12 00:13:00
[sftp.c sftp.1]
support most of scp(1)'s commandline arguments in sftp(1), as a first
step towards making sftp(1) a drop-in replacement for scp(1).
One conflicting option (-P) has not been changed, pending further
discussion.
Patch from carlosvsilvapt@gmail.com as part of his work in the
Google Summer of Code
20091002 20091002
- (djm) [Makefile.in] Mention readconf.o in ssh-keysign's make deps. - (djm) [Makefile.in] Mention readconf.o in ssh-keysign's make deps.
spotted by des AT des.no spotted by des AT des.no

31
sftp.1
View File

@ -1,4 +1,4 @@
.\" $OpenBSD: sftp.1,v 1.69 2008/12/09 15:35:00 sobrado Exp $ .\" $OpenBSD: sftp.1,v 1.70 2009/08/12 00:13:00 djm Exp $
.\" .\"
.\" Copyright (c) 2001 Damien Miller. All rights reserved. .\" Copyright (c) 2001 Damien Miller. All rights reserved.
.\" .\"
@ -22,7 +22,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: December 9 2008 $ .Dd $Mdocdate: August 12 2009 $
.Dt SFTP 1 .Dt SFTP 1
.Os .Os
.Sh NAME .Sh NAME
@ -31,10 +31,12 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm sftp .Nm sftp
.Bk -words .Bk -words
.Op Fl 1Cv .Op Fl 1246Cqv
.Op Fl B Ar buffer_size .Op Fl B Ar buffer_size
.Op Fl b Ar batchfile .Op Fl b Ar batchfile
.Op Fl c Ar cipher
.Op Fl F Ar ssh_config .Op Fl F Ar ssh_config
.Op Fl i Ar identity_path
.Op Fl o Ar ssh_option .Op Fl o Ar ssh_option
.Op Fl P Ar sftp_server_path .Op Fl P Ar sftp_server_path
.Op Fl R Ar num_requests .Op Fl R Ar num_requests
@ -87,6 +89,16 @@ The options are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl 1 .It Fl 1
Specify the use of protocol version 1. Specify the use of protocol version 1.
.It Fl 2
Specify the use of protocol version 2.
.It Fl 4
Forces
.Nm
to use IPv4 addresses only.
.It Fl 6
Forces
.Nm
to use IPv6 addresses only.
.It Fl B Ar buffer_size .It Fl B Ar buffer_size
Specify the size of the buffer that Specify the size of the buffer that
.Nm .Nm
@ -120,6 +132,10 @@ prefixing the command with a
.Sq \- .Sq \-
character (for example, character (for example,
.Ic -rm /tmp/blah* ) . .Ic -rm /tmp/blah* ) .
.It Fl c Ar cipher
Selects the cipher to use for encrypting the data transfers.
This option is directly passed to
.Xr ssh 1 .
.It Fl C .It Fl C
Enables compression (via ssh's Enables compression (via ssh's
.Fl C .Fl C
@ -130,6 +146,11 @@ per-user configuration file for
.Xr ssh 1 . .Xr ssh 1 .
This option is directly passed to This option is directly passed to
.Xr ssh 1 . .Xr ssh 1 .
.It Fl i Ar identity_file
Selects the file from which the identity (private key) for public key
authentication is read.
This option is directly passed to
.Xr ssh 1 .
.It Fl o Ar ssh_option .It Fl o Ar ssh_option
Can be used to pass options to Can be used to pass options to
.Nm ssh .Nm ssh
@ -199,6 +220,10 @@ Connect directly to a local sftp server
(rather than via (rather than via
.Xr ssh 1 ) . .Xr ssh 1 ) .
This option may be useful in debugging the client and server. This option may be useful in debugging the client and server.
.It Fl q
Quiet mode: disables the progress meter as well as warning and
diagnostic messages from
.Xr ssh 1 .
.It Fl R Ar num_requests .It Fl R Ar num_requests
Specify how many requests may be outstanding at any one time. Specify how many requests may be outstanding at any one time.
Increasing this may slightly improve file transfer speed Increasing this may slightly improve file transfer speed

57
sftp.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: sftp.c,v 1.107 2009/02/02 11:15:14 dtucker Exp $ */ /* $OpenBSD: sftp.c,v 1.108 2009/08/12 00:13:00 djm Exp $ */
/* /*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
* *
@ -1668,12 +1668,14 @@ usage(void)
extern char *__progname; extern char *__progname;
fprintf(stderr, fprintf(stderr,
"usage: %s [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]\n" "usage: %s [-1246Cqv] [-B buffer_size] [-b batchfile] [-c cipher]\n"
" [-o ssh_option] [-P sftp_server_path] [-R num_requests]\n" " [-F ssh_config] [-i identify_file] [-o ssh_option]\n"
" [-S program] [-s subsystem | sftp_server] host\n" " [-P sftp_server_path] [-R num_requests] [-S program]\n"
" [-s subsystem | sftp_server] host\n"
" %s [user@]host[:file ...]\n" " %s [user@]host[:file ...]\n"
" %s [user@]host[:dir[/]]\n" " %s [user@]host[:dir[/]]\n"
" %s -b batchfile [user@]host\n", __progname, __progname, __progname, __progname); " %s -b batchfile [user@]host\n",
__progname, __progname, __progname, __progname);
exit(1); exit(1);
} }
@ -1705,10 +1707,24 @@ main(int argc, char **argv)
ll = SYSLOG_LEVEL_INFO; ll = SYSLOG_LEVEL_INFO;
infile = stdin; infile = stdin;
while ((ch = getopt(argc, argv, "1hvCo:s:S:b:B:F:P:R:")) != -1) { while ((ch = getopt(argc, argv, "1246hqvCc:i:o:s:S:b:B:F:P:R:")) != -1) {
switch (ch) { switch (ch) {
/* Passed through to ssh(1) */
case '4':
case '6':
case 'C': case 'C':
addargs(&args, "-C"); addargs(&args, "-%c", ch);
break;
/* Passed through to ssh(1) with argument */
case 'F':
case 'c':
case 'i':
case 'o':
addargs(&args, "-%c%s", ch, optarg);
break;
case 'q':
showprogress = 0;
addargs(&args, "-%c", ch);
break; break;
case 'v': case 'v':
if (debug_level < 3) { if (debug_level < 3) {
@ -1717,21 +1733,18 @@ main(int argc, char **argv)
} }
debug_level++; debug_level++;
break; break;
case 'F':
case 'o':
addargs(&args, "-%c%s", ch, optarg);
break;
case '1': case '1':
sshver = 1; sshver = 1;
if (sftp_server == NULL) if (sftp_server == NULL)
sftp_server = _PATH_SFTP_SERVER; sftp_server = _PATH_SFTP_SERVER;
break; break;
case 's': case '2':
sftp_server = optarg; sshver = 2;
break; break;
case 'S': case 'B':
ssh_program = optarg; copy_buffer_len = strtol(optarg, &cp, 10);
replacearg(&args, 0, "%s", ssh_program); if (copy_buffer_len == 0 || *cp != '\0')
fatal("Invalid buffer size \"%s\"", optarg);
break; break;
case 'b': case 'b':
if (batchmode) if (batchmode)
@ -1748,17 +1761,19 @@ main(int argc, char **argv)
case 'P': case 'P':
sftp_direct = optarg; sftp_direct = optarg;
break; break;
case 'B':
copy_buffer_len = strtol(optarg, &cp, 10);
if (copy_buffer_len == 0 || *cp != '\0')
fatal("Invalid buffer size \"%s\"", optarg);
break;
case 'R': case 'R':
num_requests = strtol(optarg, &cp, 10); num_requests = strtol(optarg, &cp, 10);
if (num_requests == 0 || *cp != '\0') if (num_requests == 0 || *cp != '\0')
fatal("Invalid number of requests \"%s\"", fatal("Invalid number of requests \"%s\"",
optarg); optarg);
break; break;
case 's':
sftp_server = optarg;
break;
case 'S':
ssh_program = optarg;
replacearg(&args, 0, "%s", ssh_program);
break;
case 'h': case 'h':
default: default:
usage(); usage();