- djm@cvs.openbsd.org 2007/06/14 22:48:05
[ssh.c] when waiting for the multiplex exit status, read until the master end writes an entire int of data *and* closes the client_fd; fixes mux regression spotted by dtucker, ok dtucker@
This commit is contained in:
parent
d989adadd3
commit
132367f76f
|
@ -7,6 +7,11 @@
|
||||||
- djm@cvs.openbsd.org 2007/06/14 21:43:25
|
- djm@cvs.openbsd.org 2007/06/14 21:43:25
|
||||||
[ssh.c]
|
[ssh.c]
|
||||||
handle EINTR when waiting for mux exit status properly
|
handle EINTR when waiting for mux exit status properly
|
||||||
|
- djm@cvs.openbsd.org 2007/06/14 22:48:05
|
||||||
|
[ssh.c]
|
||||||
|
when waiting for the multiplex exit status, read until the master end
|
||||||
|
writes an entire int of data *and* closes the client_fd; fixes mux
|
||||||
|
regression spotted by dtucker, ok dtucker@
|
||||||
|
|
||||||
20070614
|
20070614
|
||||||
- (dtucker) [cipher-ctr.c umac.c openbsd-compat/openssl-compat.h] Move the
|
- (dtucker) [cipher-ctr.c umac.c openbsd-compat/openssl-compat.h] Move the
|
||||||
|
@ -3082,4 +3087,4 @@
|
||||||
OpenServer 6 and add osr5bigcrypt support so when someone migrates
|
OpenServer 6 and add osr5bigcrypt support so when someone migrates
|
||||||
passwords between UnixWare and OpenServer they will still work. OK dtucker@
|
passwords between UnixWare and OpenServer they will still work. OK dtucker@
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.4704 2007/06/25 08:34:43 dtucker Exp $
|
$Id: ChangeLog,v 1.4705 2007/06/25 08:59:17 dtucker Exp $
|
||||||
|
|
34
ssh.c
34
ssh.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: ssh.c,v 1.299 2007/06/14 21:43:25 djm Exp $ */
|
/* $OpenBSD: ssh.c,v 1.300 2007/06/14 22:48:05 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -1311,7 +1311,7 @@ static void
|
||||||
control_client(const char *path)
|
control_client(const char *path)
|
||||||
{
|
{
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
int i, r, fd, sock, exitval, num_env, addr_len;
|
int i, r, fd, sock, exitval[2], num_env, addr_len;
|
||||||
Buffer m;
|
Buffer m;
|
||||||
char *term;
|
char *term;
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
@ -1460,10 +1460,16 @@ control_client(const char *path)
|
||||||
if (tty_flag)
|
if (tty_flag)
|
||||||
enter_raw_mode();
|
enter_raw_mode();
|
||||||
|
|
||||||
/* Stick around until the controlee closes the client_fd */
|
/*
|
||||||
exitval = 0;
|
* Stick around until the controlee closes the client_fd.
|
||||||
|
* Before it does, it is expected to write this process' exit
|
||||||
|
* value (one int). This process must read the value and wait for
|
||||||
|
* the closure of the client_fd; if this one closes early, the
|
||||||
|
* multiplex master will terminate early too (possibly losing data).
|
||||||
|
*/
|
||||||
|
exitval[0] = 0;
|
||||||
for (i = 0; !control_client_terminate && i < (int)sizeof(exitval);) {
|
for (i = 0; !control_client_terminate && i < (int)sizeof(exitval);) {
|
||||||
r = read(sock, (char *)&exitval + i, sizeof(exitval) - i);
|
r = read(sock, (char *)exitval + i, sizeof(exitval) - i);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
debug2("Received EOF from master");
|
debug2("Received EOF from master");
|
||||||
break;
|
break;
|
||||||
|
@ -1475,21 +1481,23 @@ control_client(const char *path)
|
||||||
}
|
}
|
||||||
i += r;
|
i += r;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(sock);
|
close(sock);
|
||||||
leave_raw_mode();
|
leave_raw_mode();
|
||||||
|
if (i > (int)sizeof(int))
|
||||||
|
fatal("%s: master returned too much data (%d > %lu)",
|
||||||
|
__func__, i, sizeof(int));
|
||||||
if (control_client_terminate) {
|
if (control_client_terminate) {
|
||||||
debug2("Exiting on signal %d", control_client_terminate);
|
debug2("Exiting on signal %d", control_client_terminate);
|
||||||
exitval = 255;
|
exitval[0] = 255;
|
||||||
} else if (i < (int)sizeof(exitval)) {
|
} else if (i < (int)sizeof(int)) {
|
||||||
debug2("Control master terminated unexpectedly");
|
debug2("Control master terminated unexpectedly");
|
||||||
exitval = 255;
|
exitval[0] = 255;
|
||||||
} else
|
} else
|
||||||
debug2("Received exit status from master %d", exitval);
|
debug2("Received exit status from master %d", exitval[0]);
|
||||||
|
|
||||||
if (tty_flag && options.log_level != SYSLOG_LEVEL_QUIET)
|
if (tty_flag && options.log_level != SYSLOG_LEVEL_QUIET)
|
||||||
fprintf(stderr, "Shared connection to %s closed.\r\n",
|
fprintf(stderr, "Shared connection to %s closed.\r\n", host);
|
||||||
host);
|
|
||||||
|
|
||||||
exit(exitval);
|
exit(exitval[0]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue