mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-27 15:54:22 +02:00
upstream: factor out channel status formatting from
channel_open_message() so we can use it in other debug messages OpenBSD-Commit-ID: 9c3903ca28fcabad57f566c9d0045b41ab7d52ba
This commit is contained in:
parent
f1dd179e12
commit
6f1aabb128
37
channels.c
37
channels.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: channels.c,v 1.385 2018/10/04 00:10:11 djm Exp $ */
|
/* $OpenBSD: channels.c,v 1.386 2018/10/04 01:04:52 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
|
||||||
@ -818,6 +818,22 @@ channel_format_extended_usage(const Channel *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
channel_format_status(const Channel *c)
|
||||||
|
{
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
|
xasprintf(&ret, "t%d %s%u i%u/%zu o%u/%zu e[%s]/%zu "
|
||||||
|
"fd %d/%d/%d sock %d cc %d",
|
||||||
|
c->type,
|
||||||
|
c->have_remote_id ? "r" : "nr", c->remote_id,
|
||||||
|
c->istate, sshbuf_len(c->input),
|
||||||
|
c->ostate, sshbuf_len(c->output),
|
||||||
|
channel_format_extended_usage(c), sshbuf_len(c->extended),
|
||||||
|
c->rfd, c->wfd, c->efd, c->sock, c->ctl_chan);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a message describing the currently open forwarded connections,
|
* Returns a message describing the currently open forwarded connections,
|
||||||
* suitable for sending to the client. The message contains crlf pairs for
|
* suitable for sending to the client. The message contains crlf pairs for
|
||||||
@ -830,7 +846,7 @@ channel_open_message(struct ssh *ssh)
|
|||||||
Channel *c;
|
Channel *c;
|
||||||
u_int i;
|
u_int i;
|
||||||
int r;
|
int r;
|
||||||
char *ret;
|
char *cp, *ret;
|
||||||
|
|
||||||
if ((buf = sshbuf_new()) == NULL)
|
if ((buf = sshbuf_new()) == NULL)
|
||||||
fatal("%s: sshbuf_new", __func__);
|
fatal("%s: sshbuf_new", __func__);
|
||||||
@ -863,19 +879,14 @@ channel_open_message(struct ssh *ssh)
|
|||||||
case SSH_CHANNEL_X11_OPEN:
|
case SSH_CHANNEL_X11_OPEN:
|
||||||
case SSH_CHANNEL_MUX_PROXY:
|
case SSH_CHANNEL_MUX_PROXY:
|
||||||
case SSH_CHANNEL_MUX_CLIENT:
|
case SSH_CHANNEL_MUX_CLIENT:
|
||||||
if ((r = sshbuf_putf(buf, " #%d %.300s "
|
cp = channel_format_status(c);
|
||||||
"(t%d %s%u i%u/%zu o%u/%zu "
|
if ((r = sshbuf_putf(buf, " #%d %.300s (%s)\r\n",
|
||||||
"fd %d/%d/%d [%s] sock %d cc %d)\r\n",
|
c->self, c->remote_name, cp)) != 0) {
|
||||||
c->self, c->remote_name,
|
free(cp);
|
||||||
c->type,
|
|
||||||
c->have_remote_id ? "r" : "nr", c->remote_id,
|
|
||||||
c->istate, sshbuf_len(c->input),
|
|
||||||
c->ostate, sshbuf_len(c->output),
|
|
||||||
c->rfd, c->wfd, c->efd,
|
|
||||||
channel_format_extended_usage(c),
|
|
||||||
c->sock, c->ctl_chan)) != 0)
|
|
||||||
fatal("%s: sshbuf_putf: %s",
|
fatal("%s: sshbuf_putf: %s",
|
||||||
__func__, ssh_err(r));
|
__func__, ssh_err(r));
|
||||||
|
}
|
||||||
|
free(cp);
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
fatal("%s: bad channel type %d", __func__, c->type);
|
fatal("%s: bad channel type %d", __func__, c->type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user