Example #1
0
static void
chan_shutdown_read(Channel *c)
{
	if (compat20 && c->type == SSH_CHANNEL_LARVAL)
		return;
	debug("channel %d: close_read", c->self);
	if (c->sock != -1) {
		/*
		 * shutdown(sock, SHUT_READ) may return ENOTCONN if the
		 * write side has been closed already. (bug on Linux)
		 * HP-UX may return ENOTCONN also.
		 */
		if (shutdown(c->sock, SHUT_RD) < 0
		    && errno != ENOTCONN)
			error("channel %d: chan_shutdown_read: "
			    "shutdown() failed for fd%d [i%d o%d]: %.100s",
			    c->self, c->sock, c->istate, c->ostate,
			    strerror(errno));
	} else {
		if (channel_close_fd(&c->rfd) < 0)
			log("channel %d: chan_shutdown_read: "
			    "close() failed for fd%d: %.100s",
			    c->self, c->rfd, strerror(errno));
	}
}
Example #2
0
static void
chan_shutdown_read(struct ssh *ssh, Channel *c)
{
	if (c->type == SSH_CHANNEL_LARVAL)
		return;
	debug2("channel %d: %s (i%d o%d sock %d wfd %d efd %d [%s])",
	    c->self, __func__, c->istate, c->ostate, c->sock, c->rfd, c->efd,
	    channel_format_extended_usage(c));
	if (c->sock != -1) {
		/*
		 * shutdown(sock, SHUT_READ) may return ENOTCONN if the
		 * write side has been closed already. (bug on Linux)
		 * HP-UX may return ENOTCONN also.
		 */
		if (shutdown(c->sock, SHUT_RD) < 0 && errno != ENOTCONN) {
			error("channel %d: %s: shutdown() failed for "
			    "fd %d [i%d o%d]: %.100s",
			    c->self, __func__, c->sock, c->istate, c->ostate,
 			    strerror(errno));
		}
	} else {
		if (channel_close_fd(ssh, &c->rfd) < 0) {
			logit("channel %d: %s: close() failed for "
			    "fd %d [i%d o%d]: %.100s",
			    c->self, __func__, c->rfd, c->istate, c->ostate,
			    strerror(errno));
		}
	}
}
Example #3
0
/* helper */
static void
chan_shutdown_write(struct ssh *ssh, Channel *c)
{
	sshbuf_reset(c->output);
	if (c->type == SSH_CHANNEL_LARVAL)
		return;
	/* shutdown failure is allowed if write failed already */
	debug2("channel %d: %s (i%d o%d sock %d wfd %d efd %d [%s])",
	    c->self, __func__, c->istate, c->ostate, c->sock, c->wfd, c->efd,
	    channel_format_extended_usage(c));
	if (c->sock != -1) {
		if (shutdown(c->sock, SHUT_WR) < 0) {
			debug2("channel %d: %s: shutdown() failed for "
			    "fd %d [i%d o%d]: %.100s", c->self, __func__,
			    c->sock, c->istate, c->ostate,
			    strerror(errno));
		}
	} else {
		if (channel_close_fd(ssh, &c->wfd) < 0) {
			logit("channel %d: %s: close() failed for "
			    "fd %d [i%d o%d]: %.100s",
			    c->self, __func__, c->wfd, c->istate, c->ostate,
			    strerror(errno));
		}
	}
}
Example #4
0
static void
chan_shutdown_extended_read(struct ssh *ssh, Channel *c)
{
	if (c->type == SSH_CHANNEL_LARVAL || c->efd == -1)
		return;
	if (c->extended_usage != CHAN_EXTENDED_READ &&
	    c->extended_usage != CHAN_EXTENDED_IGNORE)
		return;
	debug2("channel %d: %s (i%d o%d sock %d wfd %d efd %d [%s])",
	    c->self, __func__, c->istate, c->ostate, c->sock, c->rfd, c->efd,
	    channel_format_extended_usage(c));
	if (channel_close_fd(ssh, &c->efd) < 0) {
		logit("channel %d: %s: close() failed for "
		    "extended fd %d [i%d o%d]: %.100s",
		    c->self, __func__, c->efd, c->istate, c->ostate,
		    strerror(errno));
	}
}
Example #5
0
static void
chan_shutdown_read(Channel *c)
{
	if (compat20 && c->type == SSH_CHANNEL_LARVAL)
		return;
	debug2("channel %d: close_read", c->self);
	if (c->sock != -1) {
		if (shutdown(c->sock, SHUT_RD) < 0)
			error("channel %d: chan_shutdown_read: "
			    "shutdown() failed for fd %d [i%d o%d]: %.100s",
			    c->self, c->sock, c->istate, c->ostate,
			    strerror(errno));
	} else {
		if (channel_close_fd(&c->rfd) < 0)
			logit("channel %d: chan_shutdown_read: "
			    "close() failed for fd %d: %.100s",
			    c->self, c->rfd, strerror(errno));
	}
}
Example #6
0
/* helper */
static void
chan_shutdown_write(Channel *c)
{
	buffer_clear(&c->output);
	if (compat20 && c->type == SSH_CHANNEL_LARVAL)
		return;
	/* shutdown failure is allowed if write failed already */
	debug2("channel %d: close_write", c->self);
	if (c->sock != -1) {
		if (shutdown(c->sock, SHUT_WR) < 0)
			debug2("channel %d: chan_shutdown_write: "
			    "shutdown() failed for fd %d: %.100s",
			    c->self, c->sock, strerror(errno));
	} else {
		if (channel_close_fd(&c->wfd) < 0)
			logit("channel %d: chan_shutdown_write: "
			    "close() failed for fd %d: %.100s",
			    c->self, c->wfd, strerror(errno));
	}
}