]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Extra logging in SSH-2 port-forwarding. Most obviously, the opening of a
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Fri, 13 Aug 2004 01:08:34 +0000 (01:08 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Fri, 13 Aug 2004 01:08:34 +0000 (01:08 +0000)
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

diff --git a/ssh.c b/ssh.c
index 3616d21155120bf577f29537c69a257f7ee4ed34..91e968cb87a28a6e8b9380302aca4a0623427533 100644 (file)
--- 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);