diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | sftp.c | 40 |
2 files changed, 27 insertions, 19 deletions
@@ -72,6 +72,12 @@ | |||
72 | Warn but do not fail if stat()ing the subsystem binary fails. This helps | 72 | Warn but do not fail if stat()ing the subsystem binary fails. This helps |
73 | with chrootdirectory+forcecommand=sftp-server and restricted shells. | 73 | with chrootdirectory+forcecommand=sftp-server and restricted shells. |
74 | bz #1599, ok djm. | 74 | bz #1599, ok djm. |
75 | - djm@cvs.openbsd.org 2009/11/20 00:54:01 | ||
76 | [sftp.c] | ||
77 | bz#1588 change "Connecting to host..." message to "Connected to host." | ||
78 | and delay it until after the sftp protocol connection has been established. | ||
79 | Avoids confusing sequence of messages when the underlying ssh connection | ||
80 | experiences problems. ok dtucker@ | ||
75 | 81 | ||
76 | 20091226 | 82 | 20091226 |
77 | - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1 | 83 | - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1 |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.111 2009/08/18 18:36:21 djm Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.112 2009/11/20 00:54:01 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -68,18 +68,15 @@ typedef void EditLine; | |||
68 | #include "sftp-common.h" | 68 | #include "sftp-common.h" |
69 | #include "sftp-client.h" | 69 | #include "sftp-client.h" |
70 | 70 | ||
71 | #define DEFAULT_COPY_BUFLEN 32768 /* Size of buffer for up/download */ | ||
72 | #define DEFAULT_NUM_REQUESTS 64 /* # concurrent outstanding requests */ | ||
73 | |||
71 | /* File to read commands from */ | 74 | /* File to read commands from */ |
72 | FILE* infile; | 75 | FILE* infile; |
73 | 76 | ||
74 | /* Are we in batchfile mode? */ | 77 | /* Are we in batchfile mode? */ |
75 | int batchmode = 0; | 78 | int batchmode = 0; |
76 | 79 | ||
77 | /* Size of buffer used when copying files */ | ||
78 | size_t copy_buffer_len = 32768; | ||
79 | |||
80 | /* Number of concurrent outstanding requests */ | ||
81 | size_t num_requests = 64; | ||
82 | |||
83 | /* PID of ssh transport process */ | 80 | /* PID of ssh transport process */ |
84 | static pid_t sshpid = -1; | 81 | static pid_t sshpid = -1; |
85 | 82 | ||
@@ -187,7 +184,7 @@ static const struct CMD cmds[] = { | |||
187 | { NULL, -1} | 184 | { NULL, -1} |
188 | }; | 185 | }; |
189 | 186 | ||
190 | int interactive_loop(int fd_in, int fd_out, char *file1, char *file2); | 187 | int interactive_loop(struct sftp_conn *, char *file1, char *file2); |
191 | 188 | ||
192 | /* ARGSUSED */ | 189 | /* ARGSUSED */ |
193 | static void | 190 | static void |
@@ -1472,12 +1469,11 @@ prompt(EditLine *el) | |||
1472 | #endif | 1469 | #endif |
1473 | 1470 | ||
1474 | int | 1471 | int |
1475 | interactive_loop(int fd_in, int fd_out, char *file1, char *file2) | 1472 | interactive_loop(struct sftp_conn *conn, char *file1, char *file2) |
1476 | { | 1473 | { |
1477 | char *pwd; | 1474 | char *pwd; |
1478 | char *dir = NULL; | 1475 | char *dir = NULL; |
1479 | char cmd[2048]; | 1476 | char cmd[2048]; |
1480 | struct sftp_conn *conn; | ||
1481 | int err, interactive; | 1477 | int err, interactive; |
1482 | EditLine *el = NULL; | 1478 | EditLine *el = NULL; |
1483 | #ifdef USE_LIBEDIT | 1479 | #ifdef USE_LIBEDIT |
@@ -1501,10 +1497,6 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2) | |||
1501 | } | 1497 | } |
1502 | #endif /* USE_LIBEDIT */ | 1498 | #endif /* USE_LIBEDIT */ |
1503 | 1499 | ||
1504 | conn = do_init(fd_in, fd_out, copy_buffer_len, num_requests); | ||
1505 | if (conn == NULL) | ||
1506 | fatal("Couldn't initialise connection to server"); | ||
1507 | |||
1508 | pwd = do_realpath(conn, "."); | 1500 | pwd = do_realpath(conn, "."); |
1509 | if (pwd == NULL) | 1501 | if (pwd == NULL) |
1510 | fatal("Need cwd"); | 1502 | fatal("Need cwd"); |
@@ -1694,6 +1686,9 @@ main(int argc, char **argv) | |||
1694 | arglist args; | 1686 | arglist args; |
1695 | extern int optind; | 1687 | extern int optind; |
1696 | extern char *optarg; | 1688 | extern char *optarg; |
1689 | struct sftp_conn *conn; | ||
1690 | size_t copy_buffer_len = DEFAULT_COPY_BUFLEN; | ||
1691 | size_t num_requests = DEFAULT_NUM_REQUESTS; | ||
1697 | 1692 | ||
1698 | /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ | 1693 | /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ |
1699 | sanitise_stdfd(); | 1694 | sanitise_stdfd(); |
@@ -1837,20 +1832,27 @@ main(int argc, char **argv) | |||
1837 | addargs(&args, "%s", (sftp_server != NULL ? | 1832 | addargs(&args, "%s", (sftp_server != NULL ? |
1838 | sftp_server : "sftp")); | 1833 | sftp_server : "sftp")); |
1839 | 1834 | ||
1840 | if (!batchmode) | ||
1841 | fprintf(stderr, "Connecting to %s...\n", host); | ||
1842 | connect_to_server(ssh_program, args.list, &in, &out); | 1835 | connect_to_server(ssh_program, args.list, &in, &out); |
1843 | } else { | 1836 | } else { |
1844 | args.list = NULL; | 1837 | args.list = NULL; |
1845 | addargs(&args, "sftp-server"); | 1838 | addargs(&args, "sftp-server"); |
1846 | 1839 | ||
1847 | if (!batchmode) | ||
1848 | fprintf(stderr, "Attaching to %s...\n", sftp_direct); | ||
1849 | connect_to_server(sftp_direct, args.list, &in, &out); | 1840 | connect_to_server(sftp_direct, args.list, &in, &out); |
1850 | } | 1841 | } |
1851 | freeargs(&args); | 1842 | freeargs(&args); |
1852 | 1843 | ||
1853 | err = interactive_loop(in, out, file1, file2); | 1844 | conn = do_init(in, out, copy_buffer_len, num_requests); |
1845 | if (conn == NULL) | ||
1846 | fatal("Couldn't initialise connection to server"); | ||
1847 | |||
1848 | if (!batchmode) { | ||
1849 | if (sftp_direct == NULL) | ||
1850 | fprintf(stderr, "Connected to %s.\n", host); | ||
1851 | else | ||
1852 | fprintf(stderr, "Attached to %s.\n", sftp_direct); | ||
1853 | } | ||
1854 | |||
1855 | err = interactive_loop(conn, file1, file2); | ||
1854 | 1856 | ||
1855 | #if !defined(USE_PIPES) | 1857 | #if !defined(USE_PIPES) |
1856 | shutdown(in, SHUT_RDWR); | 1858 | shutdown(in, SHUT_RDWR); |