mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Extra logging in SSH-2 port-forwarding. Most obviously, the opening of a
forwarded X11 connection is now logged as well as the closing; but we also log the peer IP/port in case it's interesting, and log the reason for refusing to honour a channel open. [originally from svn r4451]
This commit is contained in:
parent
fabc2b32bb
commit
f17522be6c
13
ssh.c
13
ssh.c
@ -6160,9 +6160,12 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
ssh_pkt_getstring(ssh, &peeraddr, &peeraddrlen);
|
ssh_pkt_getstring(ssh, &peeraddr, &peeraddrlen);
|
||||||
addrstr = snewn(peeraddrlen+1, char);
|
addrstr = snewn(peeraddrlen+1, char);
|
||||||
memcpy(addrstr, peeraddr, peeraddrlen);
|
memcpy(addrstr, peeraddr, peeraddrlen);
|
||||||
peeraddr[peeraddrlen] = '\0';
|
addrstr[peeraddrlen] = '\0';
|
||||||
peerport = ssh_pkt_getuint32(ssh);
|
peerport = ssh_pkt_getuint32(ssh);
|
||||||
|
|
||||||
|
logeventf(ssh, "Received X11 connect request from %s:%d",
|
||||||
|
addrstr, peerport);
|
||||||
|
|
||||||
if (!ssh->X11_fwd_enabled)
|
if (!ssh->X11_fwd_enabled)
|
||||||
error = "X11 forwarding is not enabled";
|
error = "X11 forwarding is not enabled";
|
||||||
else if (x11_init(&c->u.x11.s, ssh->cfg.x11_display, c,
|
else if (x11_init(&c->u.x11.s, ssh->cfg.x11_display, c,
|
||||||
@ -6170,6 +6173,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
&ssh->cfg) != NULL) {
|
&ssh->cfg) != NULL) {
|
||||||
error = "Unable to open an X11 connection";
|
error = "Unable to open an X11 connection";
|
||||||
} else {
|
} else {
|
||||||
|
logevent("Opening X11 forward connection succeeded");
|
||||||
c->type = CHAN_X11;
|
c->type = CHAN_X11;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6184,6 +6188,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
ssh_pkt_getstring(ssh, &peeraddr, &peeraddrlen);
|
ssh_pkt_getstring(ssh, &peeraddr, &peeraddrlen);
|
||||||
peerport = ssh_pkt_getuint32(ssh);
|
peerport = ssh_pkt_getuint32(ssh);
|
||||||
realpf = find234(ssh->rportfwds, &pf, NULL);
|
realpf = find234(ssh->rportfwds, &pf, NULL);
|
||||||
|
logeventf(ssh, "Received remote port %d open request "
|
||||||
|
"from %s:%d", pf.sport, peeraddr, peerport);
|
||||||
if (realpf == NULL) {
|
if (realpf == NULL) {
|
||||||
error = "Remote port is not recognised";
|
error = "Remote port is not recognised";
|
||||||
} else {
|
} else {
|
||||||
@ -6191,8 +6197,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
realpf->dhost,
|
realpf->dhost,
|
||||||
realpf->dport, c,
|
realpf->dport, c,
|
||||||
&ssh->cfg);
|
&ssh->cfg);
|
||||||
logeventf(ssh, "Received remote port open request"
|
logeventf(ssh, "Attempting to forward remote port to "
|
||||||
" for %s:%d", realpf->dhost, realpf->dport);
|
"%s:%d", realpf->dhost, realpf->dport);
|
||||||
if (e != NULL) {
|
if (e != NULL) {
|
||||||
logeventf(ssh, "Port open failed: %s", e);
|
logeventf(ssh, "Port open failed: %s", e);
|
||||||
error = "Port open failed";
|
error = "Port open failed";
|
||||||
@ -6221,6 +6227,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
ssh2_pkt_addstring(ssh, error);
|
ssh2_pkt_addstring(ssh, error);
|
||||||
ssh2_pkt_addstring(ssh, "en"); /* language tag */
|
ssh2_pkt_addstring(ssh, "en"); /* language tag */
|
||||||
ssh2_pkt_send(ssh);
|
ssh2_pkt_send(ssh);
|
||||||
|
logeventf(ssh, "Rejected channel open: %s", error);
|
||||||
sfree(c);
|
sfree(c);
|
||||||
} else {
|
} else {
|
||||||
c->localid = alloc_channel_id(ssh);
|
c->localid = alloc_channel_id(ssh);
|
||||||
|
Loading…
Reference in New Issue
Block a user