Esempio n. 1
0
void
packet_write_poll(void)
{
	int r;

	if ((r = ssh_packet_write_poll(active_state)) != 0)
		sshpkt_fatal(active_state, __func__, r);
}
Esempio n. 2
0
int
packet_write_poll(void)
{
	int r;

	if ((r = ssh_packet_write_poll(active_state)) < 0)
		sshpkt_fatal(active_state, __func__, r);
	return r;
}
Esempio n. 3
0
/*
 * Sends data from internal buffers to client program stdin.
 */
static void
process_output(struct ssh *ssh, fd_set *writeset)
{
	struct termios tio;
	const u_char *data;
	u_int dlen;
	int r, len;

	/* Write buffered data to program stdin. */
	if (!compat20 && fdin != -1 && FD_ISSET(fdin, writeset)) {
		data = sshbuf_ptr(stdin_buffer);
		dlen = sshbuf_len(stdin_buffer);
		len = write(fdin, data, dlen);
		if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
			/* do nothing */
		} else if (len <= 0) {
			if (fdin != fdout)
				close(fdin);
			else
				shutdown(fdin, SHUT_WR); /* We will no longer send. */
			fdin = -1;
		} else {
			/* Successful write. */
			if (fdin_is_tty && dlen >= 1 && data[0] != '\r' &&
			    tcgetattr(fdin, &tio) == 0 &&
			    !(tio.c_lflag & ECHO) && (tio.c_lflag & ICANON)) {
				/*
				 * Simulate echo to reduce the impact of
				 * traffic analysis
				 */
				ssh_packet_send_ignore(ssh, len);
				if ((r = sshpkt_send(ssh)) != 0)
					fatal("%s: %s", __func__, ssh_err(r));
			}
			/* Consume the data from the buffer. */
			if ((r = sshbuf_consume(stdin_buffer, len)) != 0)
				fatal("%s: buffer error: %s", __func__,
				    ssh_err(r));
			/* Update the count of bytes written to the program. */
			stdin_bytes += len;
		}
	}
	/* Send any buffered packet data to the client. */
	if (FD_ISSET(connection_out, writeset))
		ssh_packet_write_poll(ssh);
}