]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: allow arguments to sftp -D option, e.g. sftp -D
authordjm@openbsd.org <djm@openbsd.org>
Mon, 27 Jun 2022 21:41:55 +0000 (21:41 +0000)
committerDamien Miller <djm@mindrot.org>
Mon, 27 Jun 2022 21:43:15 +0000 (07:43 +1000)
"/usr/libexec/sftp-server -el debug3"

ok markus@

OpenBSD-Commit-ID: 5a002b9f3a7aef2731fc0ffa9c921cf15f38ecce

sftp.1
sftp.c

diff --git a/sftp.1 b/sftp.1
index 39e7d6ed68a83b0ae723b6d3485f1417930599dc..583a0ee1fc8ab3bd4234d6480ef42764826b6320 100644 (file)
--- a/sftp.1
+++ b/sftp.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sftp.1,v 1.140 2022/03/31 17:27:27 naddy Exp $
+.\" $OpenBSD: sftp.1,v 1.141 2022/06/27 21:41:55 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: March 31 2022 $
+.Dd $Mdocdate: June 27 2022 $
 .Dt SFTP 1
 .Os
 .Sh NAME
@@ -34,7 +34,7 @@
 .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 D Ar sftp_server_command
 .Op Fl F Ar ssh_config
 .Op Fl i Ar identity_file
 .Op Fl J Ar destination
@@ -167,10 +167,12 @@ 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
+.It Fl D Ar sftp_server_command
 Connect directly to a local sftp server
 (rather than via
 .Xr ssh 1 ) .
+A command and arguments may be specified, for example
+.Qq /path/sftp-server -el debug3 .
 This option may be useful in debugging the client and server.
 .It Fl F Ar ssh_config
 Specifies an alternative
diff --git a/sftp.c b/sftp.c
index 41c7f1c9fe3a39d112559af24d042b82ebd4c767..7297e77c1b750819804f56f5f65204c7d39fda78 100644 (file)
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.216 2022/05/13 06:31:50 djm Exp $ */
+/* $OpenBSD: sftp.c,v 1.217 2022/06/27 21:41:55 djm Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
  *
@@ -2387,8 +2387,8 @@ usage(void)
 int
 main(int argc, char **argv)
 {
-       int in, out, ch, err, tmp, port = -1, noisy = 0;
-       char *host = NULL, *user, *cp, *file2 = NULL;
+       int r, in, out, ch, err, tmp, port = -1, noisy = 0;
+       char *host = NULL, *user, *cp, **cpp, *file2 = NULL;
        int debug_level = 0;
        char *file1 = NULL, *sftp_server = NULL;
        char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL;
@@ -2586,10 +2586,12 @@ main(int argc, char **argv)
 
                connect_to_server(ssh_program, args.list, &in, &out);
        } else {
-               args.list = NULL;
-               addargs(&args, "sftp-server");
-
-               connect_to_server(sftp_direct, args.list, &in, &out);
+               if ((r = argv_split(sftp_direct, &tmp, &cpp, 1)) != 0)
+                       fatal_r(r, "Parse -D arguments");
+               if (cpp[0] == 0)
+                       fatal("No sftp server specified via -D");
+               connect_to_server(cpp[0], cpp, &in, &out);
+               argv_free(cpp, tmp);
        }
        freeargs(&args);