- djm@cvs.openbsd.org 2009/11/20 00:54:01

[sftp.c]
     bz#1588 change "Connecting to host..." message to "Connected to host."
     and delay it until after the sftp protocol connection has been established.
     Avoids confusing sequence of messages when the underlying ssh connection
     experiences problems. ok dtucker@
This commit is contained in:
Darren Tucker 2010-01-08 17:10:36 +11:00
parent c3dc404113
commit 210631922f
2 changed files with 27 additions and 19 deletions

View File

@ -72,6 +72,12 @@
Warn but do not fail if stat()ing the subsystem binary fails. This helps Warn but do not fail if stat()ing the subsystem binary fails. This helps
with chrootdirectory+forcecommand=sftp-server and restricted shells. with chrootdirectory+forcecommand=sftp-server and restricted shells.
bz #1599, ok djm. bz #1599, ok djm.
- djm@cvs.openbsd.org 2009/11/20 00:54:01
[sftp.c]
bz#1588 change "Connecting to host..." message to "Connected to host."
and delay it until after the sftp protocol connection has been established.
Avoids confusing sequence of messages when the underlying ssh connection
experiences problems. ok dtucker@
20091226 20091226
- (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1 - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1

40
sftp.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: sftp.c,v 1.111 2009/08/18 18:36:21 djm Exp $ */ /* $OpenBSD: sftp.c,v 1.112 2009/11/20 00:54:01 djm Exp $ */
/* /*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
* *
@ -68,18 +68,15 @@ typedef void EditLine;
#include "sftp-common.h" #include "sftp-common.h"
#include "sftp-client.h" #include "sftp-client.h"
#define DEFAULT_COPY_BUFLEN 32768 /* Size of buffer for up/download */
#define DEFAULT_NUM_REQUESTS 64 /* # concurrent outstanding requests */
/* File to read commands from */ /* File to read commands from */
FILE* infile; FILE* infile;
/* Are we in batchfile mode? */ /* Are we in batchfile mode? */
int batchmode = 0; int batchmode = 0;
/* Size of buffer used when copying files */
size_t copy_buffer_len = 32768;
/* Number of concurrent outstanding requests */
size_t num_requests = 64;
/* PID of ssh transport process */ /* PID of ssh transport process */
static pid_t sshpid = -1; static pid_t sshpid = -1;
@ -187,7 +184,7 @@ static const struct CMD cmds[] = {
{ NULL, -1} { NULL, -1}
}; };
int interactive_loop(int fd_in, int fd_out, char *file1, char *file2); int interactive_loop(struct sftp_conn *, char *file1, char *file2);
/* ARGSUSED */ /* ARGSUSED */
static void static void
@ -1472,12 +1469,11 @@ prompt(EditLine *el)
#endif #endif
int int
interactive_loop(int fd_in, int fd_out, char *file1, char *file2) interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
{ {
char *pwd; char *pwd;
char *dir = NULL; char *dir = NULL;
char cmd[2048]; char cmd[2048];
struct sftp_conn *conn;
int err, interactive; int err, interactive;
EditLine *el = NULL; EditLine *el = NULL;
#ifdef USE_LIBEDIT #ifdef USE_LIBEDIT
@ -1501,10 +1497,6 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
} }
#endif /* USE_LIBEDIT */ #endif /* USE_LIBEDIT */
conn = do_init(fd_in, fd_out, copy_buffer_len, num_requests);
if (conn == NULL)
fatal("Couldn't initialise connection to server");
pwd = do_realpath(conn, "."); pwd = do_realpath(conn, ".");
if (pwd == NULL) if (pwd == NULL)
fatal("Need cwd"); fatal("Need cwd");
@ -1694,6 +1686,9 @@ main(int argc, char **argv)
arglist args; arglist args;
extern int optind; extern int optind;
extern char *optarg; extern char *optarg;
struct sftp_conn *conn;
size_t copy_buffer_len = DEFAULT_COPY_BUFLEN;
size_t num_requests = DEFAULT_NUM_REQUESTS;
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
sanitise_stdfd(); sanitise_stdfd();
@ -1837,20 +1832,27 @@ main(int argc, char **argv)
addargs(&args, "%s", (sftp_server != NULL ? addargs(&args, "%s", (sftp_server != NULL ?
sftp_server : "sftp")); sftp_server : "sftp"));
if (!batchmode)
fprintf(stderr, "Connecting to %s...\n", host);
connect_to_server(ssh_program, args.list, &in, &out); connect_to_server(ssh_program, args.list, &in, &out);
} else { } else {
args.list = NULL; args.list = NULL;
addargs(&args, "sftp-server"); addargs(&args, "sftp-server");
if (!batchmode)
fprintf(stderr, "Attaching to %s...\n", sftp_direct);
connect_to_server(sftp_direct, args.list, &in, &out); connect_to_server(sftp_direct, args.list, &in, &out);
} }
freeargs(&args); freeargs(&args);
err = interactive_loop(in, out, file1, file2); conn = do_init(in, out, copy_buffer_len, num_requests);
if (conn == NULL)
fatal("Couldn't initialise connection to server");
if (!batchmode) {
if (sftp_direct == NULL)
fprintf(stderr, "Connected to %s.\n", host);
else
fprintf(stderr, "Attached to %s.\n", sftp_direct);
}
err = interactive_loop(conn, file1, file2);
#if !defined(USE_PIPES) #if !defined(USE_PIPES)
shutdown(in, SHUT_RDWR); shutdown(in, SHUT_RDWR);