version 1.39.2.2, 2001/02/19 17:18:48 |
version 1.39.2.3, 2001/03/21 19:46:24 |
|
|
*/ |
*/ |
if ((u_char) buf[0] == escape_char) |
if ((u_char) buf[0] == escape_char) |
escape_pending = 1; |
escape_pending = 1; |
else { |
else |
buffer_append(&stdin_buffer, buf, 1); |
buffer_append(&stdin_buffer, buf, 1); |
stdin_bytes += 1; |
|
} |
|
} |
} |
leave_non_blocking(); |
leave_non_blocking(); |
} |
} |
|
|
packet_put_string(buffer_ptr(&stdin_buffer), len); |
packet_put_string(buffer_ptr(&stdin_buffer), len); |
packet_send(); |
packet_send(); |
buffer_consume(&stdin_buffer, len); |
buffer_consume(&stdin_buffer, len); |
|
stdin_bytes += len; |
/* If we have a pending EOF, send it now. */ |
/* If we have a pending EOF, send it now. */ |
if (stdin_eof && buffer_len(&stdin_buffer) == 0) { |
if (stdin_eof && buffer_len(&stdin_buffer) == 0) { |
packet_start(SSH_CMSG_EOF); |
packet_start(SSH_CMSG_EOF); |
|
|
/* Note: we might still have data in the buffers. */ |
/* Note: we might still have data in the buffers. */ |
snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno)); |
snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
stderr_bytes += strlen(buf); |
|
quit_pending = 1; |
quit_pending = 1; |
} |
} |
} |
} |
|
|
snprintf(buf, sizeof buf, "Connection to %.300s closed by remote host.\r\n", |
snprintf(buf, sizeof buf, "Connection to %.300s closed by remote host.\r\n", |
host); |
host); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
stderr_bytes += strlen(buf); |
|
quit_pending = 1; |
quit_pending = 1; |
return; |
return; |
} |
} |
|
|
* There is a kernel bug on Solaris that causes select to |
* There is a kernel bug on Solaris that causes select to |
* sometimes wake up even though there is no data available. |
* sometimes wake up even though there is no data available. |
*/ |
*/ |
if (len < 0 && errno == EAGAIN) |
if (len < 0 && (errno == EAGAIN || errno == EINTR)) |
len = 0; |
len = 0; |
|
|
if (len < 0) { |
if (len < 0) { |
|
|
snprintf(buf, sizeof buf, "Read from remote host %.300s: %.100s\r\n", |
snprintf(buf, sizeof buf, "Read from remote host %.300s: %.100s\r\n", |
host, strerror(errno)); |
host, strerror(errno)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
stderr_bytes += strlen(buf); |
|
quit_pending = 1; |
quit_pending = 1; |
return; |
return; |
} |
} |
|
|
/* Terminate the connection. */ |
/* Terminate the connection. */ |
snprintf(string, sizeof string, "%c.\r\n", escape_char); |
snprintf(string, sizeof string, "%c.\r\n", escape_char); |
buffer_append(berr, string, strlen(string)); |
buffer_append(berr, string, strlen(string)); |
/*stderr_bytes += strlen(string); XXX*/ |
|
|
|
quit_pending = 1; |
quit_pending = 1; |
return -1; |
return -1; |
|
|
/* Print a message to that effect to the user. */ |
/* Print a message to that effect to the user. */ |
snprintf(string, sizeof string, "%c^Z [suspend ssh]\r\n", escape_char); |
snprintf(string, sizeof string, "%c^Z [suspend ssh]\r\n", escape_char); |
buffer_append(berr, string, strlen(string)); |
buffer_append(berr, string, strlen(string)); |
/*stderr_bytes += strlen(string); XXX*/ |
|
|
|
/* Restore terminal modes and suspend. */ |
/* Restore terminal modes and suspend. */ |
client_suspend_self(bin, bout, berr); |
client_suspend_self(bin, bout, berr); |
|
|
void |
void |
client_process_input(fd_set * readset) |
client_process_input(fd_set * readset) |
{ |
{ |
int ret; |
|
int len; |
int len; |
char buf[8192]; |
char buf[8192]; |
|
|
|
|
if (len < 0) { |
if (len < 0) { |
snprintf(buf, sizeof buf, "read: %.100s\r\n", strerror(errno)); |
snprintf(buf, sizeof buf, "read: %.100s\r\n", strerror(errno)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
stderr_bytes += strlen(buf); |
|
} |
} |
/* Mark that we have seen EOF. */ |
/* Mark that we have seen EOF. */ |
stdin_eof = 1; |
stdin_eof = 1; |
|
|
* Just append the data to buffer. |
* Just append the data to buffer. |
*/ |
*/ |
buffer_append(&stdin_buffer, buf, len); |
buffer_append(&stdin_buffer, buf, len); |
stdin_bytes += len; |
|
} else { |
} else { |
/* |
/* |
* Normal, successful read. But we have an escape character |
* Normal, successful read. But we have an escape character |
* and have to process the characters one by one. |
* and have to process the characters one by one. |
*/ |
*/ |
ret = process_escapes(&stdin_buffer, &stdout_buffer, &stderr_buffer, buf, len); |
if (process_escapes(&stdin_buffer, &stdout_buffer, |
if (ret == -1) |
&stderr_buffer, buf, len) == -1) |
return; |
return; |
stdout_bytes += ret; |
|
} |
} |
} |
} |
} |
} |
|
|
*/ |
*/ |
snprintf(buf, sizeof buf, "write stdout: %.50s\r\n", strerror(errno)); |
snprintf(buf, sizeof buf, "write stdout: %.50s\r\n", strerror(errno)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
stderr_bytes += strlen(buf); |
|
quit_pending = 1; |
quit_pending = 1; |
return; |
return; |
} |
} |
} |
} |
/* Consume printed data from the buffer. */ |
/* Consume printed data from the buffer. */ |
buffer_consume(&stdout_buffer, len); |
buffer_consume(&stdout_buffer, len); |
|
stdout_bytes += len; |
} |
} |
/* Write buffered output to stderr. */ |
/* Write buffered output to stderr. */ |
if (FD_ISSET(fileno(stderr), writeset)) { |
if (FD_ISSET(fileno(stderr), writeset)) { |
|
|
} |
} |
/* Consume printed characters from the buffer. */ |
/* Consume printed characters from the buffer. */ |
buffer_consume(&stderr_buffer, len); |
buffer_consume(&stderr_buffer, len); |
|
stderr_bytes += len; |
} |
} |
} |
} |
|
|
|
|
if (have_pty && options.log_level != SYSLOG_LEVEL_QUIET) { |
if (have_pty && options.log_level != SYSLOG_LEVEL_QUIET) { |
snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host); |
snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
buffer_append(&stderr_buffer, buf, strlen(buf)); |
stderr_bytes += strlen(buf); |
|
} |
} |
/* Output any buffered data for stdout. */ |
/* Output any buffered data for stdout. */ |
while (buffer_len(&stdout_buffer) > 0) { |
while (buffer_len(&stdout_buffer) > 0) { |
|
|
break; |
break; |
} |
} |
buffer_consume(&stdout_buffer, len); |
buffer_consume(&stdout_buffer, len); |
|
stdout_bytes += len; |
} |
} |
|
|
/* Output any buffered data for stderr. */ |
/* Output any buffered data for stderr. */ |
|
|
break; |
break; |
} |
} |
buffer_consume(&stderr_buffer, len); |
buffer_consume(&stderr_buffer, len); |
|
stderr_bytes += len; |
} |
} |
|
|
if (have_pty) |
if (have_pty) |
|
|
char *data = packet_get_string(&data_len); |
char *data = packet_get_string(&data_len); |
packet_integrity_check(plen, 4 + data_len, type); |
packet_integrity_check(plen, 4 + data_len, type); |
buffer_append(&stdout_buffer, data, data_len); |
buffer_append(&stdout_buffer, data, data_len); |
stdout_bytes += data_len; |
|
memset(data, 0, data_len); |
memset(data, 0, data_len); |
xfree(data); |
xfree(data); |
} |
} |
|
|
char *data = packet_get_string(&data_len); |
char *data = packet_get_string(&data_len); |
packet_integrity_check(plen, 4 + data_len, type); |
packet_integrity_check(plen, 4 + data_len, type); |
buffer_append(&stderr_buffer, data, data_len); |
buffer_append(&stderr_buffer, data, data_len); |
stdout_bytes += data_len; |
|
memset(data, 0, data_len); |
memset(data, 0, data_len); |
xfree(data); |
xfree(data); |
} |
} |