From 282b4026cb5c5a229e2c5b33e4ad3ac31fcf3189 Mon Sep 17 00:00:00 2001
From: Darren Tucker <dtucker@zip.com.au>
Date: Wed, 7 Oct 2009 08:23:06 +1100
Subject: [PATCH]    - djm@cvs.openbsd.org 2009/08/13 01:11:19      [sftp.1
 sftp.c]      Swizzle options: "-P sftp_server_path" moves to "-D
 sftp_server_path",      add "-P port" to match scp(1). Fortunately, the -P
 option is only really      used by our regression scripts.      part of
 larger patch from carlosvsilvapt@gmail.com for his Google Summer      of Code
 work; ok deraadt markus

---
 ChangeLog |  7 +++++++
 sftp.1    | 19 +++++++++++--------
 sftp.c    | 10 +++++++---
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7c305d7d6..46f5e9cfa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,13 @@
   - jmc@cvs.openbsd.org 2009/08/12 06:31:42
      [sftp.1]
      sort options;
+   - djm@cvs.openbsd.org 2009/08/13 01:11:19
+     [sftp.1 sftp.c]
+     Swizzle options: "-P sftp_server_path" moves to "-D sftp_server_path",
+     add "-P port" to match scp(1). Fortunately, the -P option is only really
+     used by our regression scripts.
+     part of larger patch from carlosvsilvapt@gmail.com for his Google Summer
+     of Code work; ok deraadt markus
 
 20091002
  - (djm) [Makefile.in] Mention readconf.o in ssh-keysign's make deps.
diff --git a/sftp.1 b/sftp.1
index d47ab1573..6cec52ae1 100644
--- a/sftp.1
+++ b/sftp.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sftp.1,v 1.71 2009/08/12 06:31:42 jmc Exp $
+.\" $OpenBSD: sftp.1,v 1.72 2009/08/13 01:11:19 djm Exp $
 .\"
 .\" 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
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd $Mdocdate: August 12 2009 $
+.Dd $Mdocdate: August 13 2009 $
 .Dt SFTP 1
 .Os
 .Sh NAME
@@ -35,10 +35,11 @@
 .Op Fl B Ar buffer_size
 .Op Fl b Ar batchfile
 .Op Fl c Ar cipher
+.Op Fl D Ar sftp_server_path
 .Op Fl F Ar ssh_config
 .Op Fl i Ar identity_path
 .Op Fl o Ar ssh_option
-.Op Fl P Ar sftp_server_path
+.Op Fl P Ar port
 .Op Fl R Ar num_requests
 .Op Fl S Ar program
 .Op Fl s Ar subsystem | sftp_server
@@ -140,6 +141,11 @@ flag).
 Selects the cipher to use for encrypting the data transfers.
 This option is directly passed to
 .Xr ssh 1 .
+.It Fl D Ar sftp_server_path
+Connect directly to a local sftp server
+(rather than via
+.Xr ssh 1 ) .
+This option may be useful in debugging the client and server.
 .It Fl F Ar ssh_config
 Specifies an alternative
 per-user configuration file for
@@ -215,11 +221,8 @@ For full details of the options listed below, and their possible values, see
 .It UserKnownHostsFile
 .It VerifyHostKeyDNS
 .El
-.It Fl P Ar sftp_server_path
-Connect directly to a local sftp server
-(rather than via
-.Xr ssh 1 ) .
-This option may be useful in debugging the client and server.
+.It Fl P Ar port
+Specifies the port to connect to on the remote host.
 .It Fl q
 Quiet mode: disables the progress meter as well as warning and
 diagnostic messages from
diff --git a/sftp.c b/sftp.c
index 798a72edb..4c1d55389 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.108 2009/08/12 00:13:00 djm Exp $ */
+/* $OpenBSD: sftp.c,v 1.109 2009/08/13 01:11:19 djm Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
  *
@@ -1707,7 +1707,8 @@ main(int argc, char **argv)
 	ll = SYSLOG_LEVEL_INFO;
 	infile = stdin;
 
-	while ((ch = getopt(argc, argv, "1246hqvCc:i:o:s:S:b:B:F:P:R:")) != -1) {
+	while ((ch = getopt(argc, argv,
+	    "1246hqvCc:D:i:o:s:S:b:B:F:P:R:")) != -1) {
 		switch (ch) {
 		/* Passed through to ssh(1) */
 		case '4':
@@ -1726,6 +1727,9 @@ main(int argc, char **argv)
 			showprogress = 0;
 			addargs(&args, "-%c", ch);
 			break;
+		case 'P':
+			addargs(&args, "-oPort %s", optarg);
+			break;
 		case 'v':
 			if (debug_level < 3) {
 				addargs(&args, "-v");
@@ -1758,7 +1762,7 @@ main(int argc, char **argv)
 			batchmode = 1;
 			addargs(&args, "-obatchmode yes");
 			break;
-		case 'P':
+		case 'D':
 			sftp_direct = optarg;
 			break;
 		case 'R':