From f17522be6c3e22feedcaacd8b03b5f738fd7fb31 Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Fri, 13 Aug 2004 01:08:34 +0000 Subject: [PATCH] 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] --- ssh.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ssh.c b/ssh.c index 3616d211..91e968cb 100644 --- a/ssh.c +++ b/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); addrstr = snewn(peeraddrlen+1, char); memcpy(addrstr, peeraddr, peeraddrlen); - peeraddr[peeraddrlen] = '\0'; + addrstr[peeraddrlen] = '\0'; peerport = ssh_pkt_getuint32(ssh); + logeventf(ssh, "Received X11 connect request from %s:%d", + addrstr, peerport); + if (!ssh->X11_fwd_enabled) error = "X11 forwarding is not enabled"; 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) { error = "Unable to open an X11 connection"; } else { + logevent("Opening X11 forward connection succeeded"); 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); peerport = ssh_pkt_getuint32(ssh); realpf = find234(ssh->rportfwds, &pf, NULL); + logeventf(ssh, "Received remote port %d open request " + "from %s:%d", pf.sport, peeraddr, peerport); if (realpf == NULL) { error = "Remote port is not recognised"; } else { @@ -6191,8 +6197,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt) realpf->dhost, realpf->dport, c, &ssh->cfg); - logeventf(ssh, "Received remote port open request" - " for %s:%d", realpf->dhost, realpf->dport); + logeventf(ssh, "Attempting to forward remote port to " + "%s:%d", realpf->dhost, realpf->dport); if (e != NULL) { logeventf(ssh, "Port open failed: %s", e); 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, "en"); /* language tag */ ssh2_pkt_send(ssh); + logeventf(ssh, "Rejected channel open: %s", error); sfree(c); } else { c->localid = alloc_channel_id(ssh);