Ver código fonte

Merge branch 'thirdparty_dev' into dev

# Conflicts:
#	source/putty/WINDOWS/winnet.c
#	source/putty/proxy.c
#	source/putty/putty.h
#	source/putty/ssh.c
#	source/putty/sshverstring.c

Source commit: bec055381ca051974fc5a45a7691225bccf9b5b1
Martin Prikryl 6 anos atrás
pai
commit
8c53e971df

+ 3 - 2
source/putty/be_misc.c

@@ -8,7 +8,8 @@
 #include "putty.h"
 #include "network.h"
 
-void backend_socket_log(Frontend *frontend, int type, SockAddr *addr, int port,
+void backend_socket_log(Frontend *frontend, LogContext *logctx,
+                        int type, SockAddr *addr, int port,
                         const char *error_msg, int error_code, Conf *conf,
                         int session_started)
 {
@@ -53,7 +54,7 @@ void backend_socket_log(Frontend *frontend, int type, SockAddr *addr, int port,
     }
 
     if (msg) {
-        logevent(frontend, msg);
+        logevent(logctx, msg);
         sfree(msg);
     }
 }

+ 3 - 1
source/putty/defs.h

@@ -49,7 +49,9 @@ typedef struct Backend Backend;
 typedef struct BackendVtable BackendVtable;
 
 typedef struct Ldisc_tag Ldisc;
-typedef struct LogContext_tag LogContext;
+typedef struct LogContext LogContext;
+typedef struct LogPolicy LogPolicy;
+typedef struct LogPolicyVtable LogPolicyVtable;
 
 typedef struct Frontend Frontend;
 

+ 35 - 29
source/putty/logging.c

@@ -12,12 +12,12 @@
 #include "putty.h"
 
 /* log session to file stuff ... */
-struct LogContext_tag {
+struct LogContext {
     FILE *lgfp;
     enum { L_CLOSED, L_OPENING, L_OPEN, L_ERROR } state;
     bufchain queue;
     Filename *currlogfilename;
-    Frontend *frontend;
+    LogPolicy *lp;
     Conf *conf;
     int logtype;		       /* cached out of conf */
 };
@@ -48,9 +48,8 @@ static void logwrite(LogContext *ctx, void *data, int len)
 	if (fwrite(data, 1, len, ctx->lgfp) < (size_t)len) {
 	    logfclose(ctx);
 	    ctx->state = L_ERROR;
-	    /* Log state is L_ERROR so this won't cause a loop */
-	    logevent(ctx->frontend,
-		     "Disabled writing session log due to error while writing");
+            lp_eventlog(ctx->lp, "Disabled writing session log "
+                        "due to error while writing");
 	}
     }				       /* else L_ERROR, so ignore the write */
 }
@@ -121,23 +120,14 @@ static void logfopen_callback(void *vctx, int mode)
 		       ctx->logtype == LGTYP_SSHRAW ? "SSH raw data" :
 		       "unknown"),
 		      filename_to_str(ctx->currlogfilename));
-    logevent(ctx->frontend, event);
+    lp_eventlog(ctx->lp, event);
     if (shout) {
         /*
          * If we failed to open the log file due to filesystem error
          * (as opposed to user action such as clicking Cancel in the
-         * askappend box), we should log it more prominently. We do
-         * this by sending it to the same place that stderr output
-         * from the main session goes (so, either a console tool's
-         * actual stderr, or a terminal window).
-         *
-         * Of course this is one case in which that policy won't cause
-         * it to turn up embarrassingly in a log file of real server
-         * output, because the whole point is that we haven't managed
-         * to open any such log file :-)
+         * askappend box), we should log it more prominently.
          */
-        from_backend(ctx->frontend, 1, event, strlen(event));
-        from_backend(ctx->frontend, 1, "\r\n", 2);
+        lp_logging_error(ctx->lp, event);
     }
     sfree(event);
 
@@ -188,8 +178,8 @@ void logfopen(LogContext *ctx)
 	if (logxfovr != LGXF_ASK) {
 	    mode = ((logxfovr == LGXF_OVR) ? 2 : 1);
 	} else
-	    mode = askappend(ctx->frontend, ctx->currlogfilename,
-			     logfopen_callback, ctx);
+            mode = lp_askappend(ctx->lp, ctx->currlogfilename,
+                                logfopen_callback, ctx);
     } else
 	mode = 2;		       /* create == overwrite */
 
@@ -223,16 +213,32 @@ void logtraffic(LogContext *ctx, unsigned char c, int logmode)
  * Log an Event Log entry. Used in SSH packet logging mode, to copy
  * the Event Log entries into the same log file as the packet data.
  */
-void log_eventlog(LogContext *ctx, const char *event)
+void logevent(LogContext *ctx, const char *event)
 {
-    /* If we don't have a context yet (eg winnet.c init) then skip entirely */
     if (!ctx)
-	return;
-    if (ctx->logtype != LGTYP_PACKETS &&
-	ctx->logtype != LGTYP_SSHRAW)
-	return;
-    logprintf(ctx, "Event Log: %s\r\n", event);
-    logflush(ctx);
+        return;
+    if (ctx->logtype == LGTYP_PACKETS || ctx->logtype == LGTYP_SSHRAW) {
+        logprintf(ctx, "Event Log: %s\r\n", event);
+        logflush(ctx);
+    }
+    lp_eventlog(ctx->lp, event);
+}
+
+void logevent_and_free(LogContext *ctx, char *event)
+{
+    logevent(ctx, event);
+    sfree(event);
+}
+
+void logeventf(LogContext *ctx, const char *fmt, ...)
+{
+    va_list ap;
+    char *buf;
+
+    va_start(ap, fmt);
+    buf = dupvprintf(fmt, ap);
+    va_end(ap);
+    logevent_and_free(ctx, buf);
 }
 
 /*
@@ -359,12 +365,12 @@ void log_packet(LogContext *ctx, int direction, int type,
     logflush(ctx);
 }
 
-LogContext *log_init(Frontend *frontend, Conf *conf)
+LogContext *log_init(LogPolicy *lp, Conf *conf)
 {
     LogContext *ctx = snew(LogContext);
     ctx->lgfp = NULL;
     ctx->state = L_CLOSED;
-    ctx->frontend = frontend;
+    ctx->lp = lp;
     ctx->conf = conf_copy(conf);
     ctx->logtype = conf_get_int(ctx->conf, CONF_logtype);
     ctx->currlogfilename = NULL;

+ 0 - 6
source/putty/misc.c

@@ -337,12 +337,6 @@ void burnstr(char *string)             /* sfree(str), only clear it first */
     }
 }
 
-void logevent_and_free(Frontend *frontend, char *s)
-{
-    logevent(frontend, s);
-    sfree(s);
-}
-
 int toint(unsigned u)
 {
     /*

+ 0 - 7
source/putty/misc.h

@@ -31,13 +31,6 @@ char *dupprintf(const char *fmt, ...)
 char *dupvprintf(const char *fmt, va_list ap);
 void burnstr(char *string);
 
-/*
- * Pass a dynamically allocated string to logevent and immediately
- * free it. Intended for use by wrapper macros which pass the return
- * value of dupprintf straight to this.
- */
-void logevent_and_free(Frontend *frontend, char *msg);
-
 struct strbuf {
     char *s;
     unsigned char *u;

+ 3 - 3
source/putty/network.h

@@ -106,8 +106,7 @@ Socket *new_connection(SockAddr *addr, const char *hostname,
 Socket *new_listener(const char *srcaddr, int port, Plug *plug,
                      int local_host_only, Conf *conf, int addressfamily);
 SockAddr *name_lookup(const char *host, int port, char **canonicalname,
-                      Conf *conf, int addressfamily,
-                      Frontend *frontend_for_logging,
+                      Conf *conf, int addressfamily, LogContext *logctx,
                       const char *lookup_reason_for_logging);
 int proxy_for_destination (SockAddr *addr, const char *hostname, int port,
                            Conf *conf);
@@ -246,7 +245,8 @@ extern Plug *const nullplug;
 /*
  * Exports from be_misc.c.
  */
-void backend_socket_log(Frontend *frontend, int type, SockAddr *addr, int port,
+void backend_socket_log(Frontend *frontend, LogContext *logctx,
+                        int type, SockAddr *addr, int port,
                         const char *error_msg, int error_code, Conf *conf,
                         int session_started);
 void log_proxy_stderr(Plug *plug, bufchain *buf, const void *vdata, int len);

+ 8 - 20
source/putty/portfwd.c

@@ -10,18 +10,6 @@
 #include "ssh.h"
 #include "sshchan.h"
 
-static void logeventf(Frontend *frontend, const char *fmt, ...)
-{
-    va_list ap;
-    char *buf;
-
-    va_start(ap, fmt);
-    buf = dupvprintf(fmt, ap);
-    va_end(ap);
-    logevent(frontend, buf);
-    sfree(buf);
-}
-
 /*
  * Enumeration of values that live in the 'socks_state' field of
  * struct PortForwarding.
@@ -641,7 +629,7 @@ static void pfd_open_failure(Channel *chan, const char *errtext)
     pinitassert(chan->vt == &PortForwarding_channelvt);
     PortForwarding *pf = container_of(chan, PortForwarding, chan);
 
-    logeventf(pf->cl->frontend,
+    logeventf(pf->cl->logctx,
               "Forwarded connection refused by server%s%s",
               errtext ? ": " : "", errtext ? errtext : "");
 }
@@ -803,7 +791,7 @@ void portfwdmgr_config(PortFwdManager *mgr, Conf *conf)
             sserv = 1;
             sport = net_service_lookup(sports);
             if (!sport) {
-                logeventf(mgr->cl->frontend, "Service lookup failed for source"
+                logeventf(mgr->cl->logctx, "Service lookup failed for source"
                           " port \"%s\"", sports);
             }
         }
@@ -829,7 +817,7 @@ void portfwdmgr_config(PortFwdManager *mgr, Conf *conf)
                 dserv = 1;
                 dport = net_service_lookup(dports);
                 if (!dport) {
-                    logeventf(mgr->cl->frontend,
+                    logeventf(mgr->cl->logctx,
                               "Service lookup failed for destination"
                               " port \"%s\"", dports);
                 }
@@ -901,7 +889,7 @@ void portfwdmgr_config(PortFwdManager *mgr, Conf *conf)
                 message = msg2;
             }
 
-            logeventf(mgr->cl->frontend, "Cancelling %s", message);
+            logeventf(mgr->cl->logctx, "Cancelling %s", message);
             sfree(message);
 
             /* pfr->remote or pfr->local may be NULL if setting up a
@@ -961,7 +949,7 @@ void portfwdmgr_config(PortFwdManager *mgr, Conf *conf)
                                        mgr->cl, conf, &pfr->local,
                                        pfr->addressfamily);
 
-                logeventf(mgr->cl->frontend,
+                logeventf(mgr->cl->logctx,
                           "Local %sport %s forwarding to %s%s%s",
                           pfr->addressfamily == ADDRTYPE_IPV4 ? "IPv4 " :
                           pfr->addressfamily == ADDRTYPE_IPV6 ? "IPv6 " : "",
@@ -974,7 +962,7 @@ void portfwdmgr_config(PortFwdManager *mgr, Conf *conf)
                                        mgr->cl, conf, &pfr->local,
                                        pfr->addressfamily);
 
-                logeventf(mgr->cl->frontend,
+                logeventf(mgr->cl->logctx,
                           "Local %sport %s SOCKS dynamic forwarding%s%s",
                           pfr->addressfamily == ADDRTYPE_IPV4 ? "IPv4 " :
                           pfr->addressfamily == ADDRTYPE_IPV6 ? "IPv6 " : "",
@@ -999,12 +987,12 @@ void portfwdmgr_config(PortFwdManager *mgr, Conf *conf)
                     pfr->addressfamily, sportdesc, pfr, NULL);
 
                 if (!pfr->remote) {
-                    logeventf(mgr->cl->frontend,
+                    logeventf(mgr->cl->logctx,
                               "Duplicate remote port forwarding to %s:%d",
                               pfr->daddr, pfr->dport);
                     pfr_free(pfr);
                 } else {
-                    logeventf(mgr->cl->frontend, "Requesting remote port %s"
+                    logeventf(mgr->cl->logctx, "Requesting remote port %s"
                               " forward to %s", sportdesc, dportdesc);
                 }
             }

+ 7 - 13
source/putty/proxy.c

@@ -367,29 +367,23 @@ static char *dns_log_msg(const char *host, int addressfamily,
 }
 
 SockAddr *name_lookup(const char *host, int port, char **canonicalname,
-                     Conf *conf, int addressfamily, Frontend *frontend,
+                     Conf *conf, int addressfamily, LogContext *logctx,
                      const char *reason)
 {
-    char *logmsg;
     if (conf_get_int(conf, CONF_proxy_type) != PROXY_NONE &&
 	do_proxy_dns(conf) &&
 	proxy_for_destination(NULL, host, port, conf)) {
 
-        if (frontend) {
-            logmsg = dupprintf("Leaving host lookup to proxy of \"%s\""
-                               " (for %s)", host, reason);
-            logevent(frontend, logmsg);
-            sfree(logmsg);
-        }
+        if (logctx)
+            logeventf(logctx, "Leaving host lookup to proxy of \"%s\""
+                      " (for %s)", host, reason);
 
 	*canonicalname = dupstr(host);
 	return sk_nonamelookup(host);
     } else {
-        if (frontend) {
-            logmsg = dns_log_msg(host, addressfamily, reason);
-            logevent(frontend, logmsg);
-            sfree(logmsg);
-        }
+        if (logctx)
+            logevent_and_free(
+                logctx, dns_log_msg(host, addressfamily, reason));
 
         return sk_namelookup(host, canonicalname, addressfamily);
     }

+ 60 - 22
source/putty/putty.h

@@ -480,7 +480,8 @@ struct Backend {
 };
 struct BackendVtable {
     const char *(*init) (Frontend *frontend, Backend **backend_out,
-			 Conf *conf, const char *host, int port,
+                         LogContext *logctx, Conf *conf,
+                         const char *host, int port,
                          char **realhost, int nodelay, int keepalive);
 
     void (*free) (Backend *be);
@@ -501,7 +502,6 @@ struct BackendVtable {
     int (*sendok) (Backend *be);
     int (*ldisc_option_state) (Backend *be, int);
     void (*provide_ldisc) (Backend *be, Ldisc *ldisc);
-    void (*provide_logctx) (Backend *be, LogContext *logctx);
     /* Tells the back end that the front end  buffer is clearing. */
     void (*unthrottle) (Backend *be, int bufsize);
     int (*cfg_info) (Backend *be);
@@ -515,8 +515,8 @@ struct BackendVtable {
     int default_port;
 };
 
-#define backend_init(vt, fe, out, conf, host, port, rhost, nd, ka) \
-    ((vt)->init(fe, out, conf, host, port, rhost, nd, ka))
+#define backend_init(vt, fe, out, logctx, conf, host, port, rhost, nd, ka) \
+    ((vt)->init(fe, out, logctx, conf, host, port, rhost, nd, ka))
 #define backend_free(be) ((be)->vt->free(be))
 #define backend_reconfig(be, conf) ((be)->vt->reconfig(be, conf))
 #define backend_send(be, buf, len) ((be)->vt->send(be, buf, len))
@@ -530,8 +530,6 @@ struct BackendVtable {
 #define backend_ldisc_option_state(be, opt) \
     ((be)->vt->ldisc_option_state(be, opt))
 #define backend_provide_ldisc(be, ldisc) ((be)->vt->provide_ldisc(be, ldisc))
-#define backend_provide_logctx(be, logctx) \
-    ((be)->vt->provide_logctx(be, logctx))
 #define backend_unthrottle(be, bufsize) ((be)->vt->unthrottle(be, bufsize))
 #define backend_cfg_info(be) ((be)->vt->cfg_info(be))
 
@@ -730,10 +728,8 @@ void modalfatalbox(const char *, ...);
 #pragma noreturn(modalfatalbox)
 #endif
 void do_beep(Frontend *frontend, int);
-void begin_session(Frontend *frontend);
 void sys_cursor(Frontend *frontend, int x, int y);
 void frontend_request_paste(Frontend *frontend, int clipboard);
-void frontend_keypress(Frontend *frontend);
 void frontend_echoedit_update(Frontend *frontend, int echo, int edit);
 /* It's the backend's responsibility to invoke this at the start of a
  * connection, if necessary; it can also invoke it later if the set of
@@ -1176,14 +1172,64 @@ int format_arrow_key(char *buf, Terminal *term, int xkey, int ctrl);
 /*
  * Exports from logging.c.
  */
-LogContext *log_init(Frontend *frontend, Conf *conf);
+struct LogPolicyVtable {
+    /*
+     * Pass Event Log entries on from LogContext to the front end,
+     * which might write them to standard error or save them for a GUI
+     * list box or other things.
+     */
+    void (*eventlog)(LogPolicy *lp, const char *event);
+
+    /*
+     * Ask what to do about the specified output log file already
+     * existing. Can return four values:
+     *
+     *  - 2 means overwrite the log file
+     *  - 1 means append to the log file
+     *  - 0 means cancel logging for this session
+     *  - -1 means please wait, and callback() will be called with one
+     *    of those options.
+     */
+    int (*askappend)(LogPolicy *lp, Filename *filename,
+                     void (*callback)(void *ctx, int result), void *ctx);
+
+    /*
+     * Emergency logging when the log file itself can't be opened,
+     * which typically means we want to shout about it more loudly
+     * than a mere Event Log entry.
+     *
+     * One reasonable option is to send it to the same place that
+     * stderr output from the main session goes (so, either a console
+     * tool's actual stderr, or a terminal window). In many cases this
+     * is unlikely to cause this error message to turn up
+     * embarrassingly in a log file of real server output, because the
+     * whole point is that we haven't managed to open any such log
+     * file :-)
+     */
+    void (*logging_error)(LogPolicy *lp, const char *event);
+};
+struct LogPolicy {
+    const LogPolicyVtable *vt;
+};
+#define lp_eventlog(lp, event) ((lp)->vt->eventlog(lp, event))
+#define lp_askappend(lp, fn, cb, ctx) ((lp)->vt->askappend(lp, fn, cb, ctx))
+#define lp_logging_error(lp, event) ((lp)->vt->logging_error(lp, event))
+
+LogContext *log_init(LogPolicy *lp, Conf *conf);
 void log_free(LogContext *logctx);
 void log_reconfig(LogContext *logctx, Conf *conf);
 void logfopen(LogContext *logctx);
 void logfclose(LogContext *logctx);
 void logtraffic(LogContext *logctx, unsigned char c, int logmode);
 void logflush(LogContext *logctx);
-void log_eventlog(LogContext *logctx, const char *string);
+void logevent(LogContext *logctx, const char *event);
+void logeventf(LogContext *logctx, const char *fmt, ...);
+/*
+ * Pass a dynamically allocated string to logevent and immediately
+ * free it. Intended for use by wrapper macros which pass the return
+ * value of dupprintf straight to this.
+ */
+void logevent_and_free(LogContext *logctx, char *event);
 enum { PKT_INCOMING, PKT_OUTGOING };
 enum { PKTLOG_EMIT, PKTLOG_BLANK, PKTLOG_OMIT };
 struct logblank_t {
@@ -1197,6 +1243,10 @@ void log_packet(LogContext *logctx, int direction, int type,
 		const unsigned long *sequence,
                 unsigned downstream_id, const char *additional_log_text);
 
+/* This is defined by applications that have an obvious logging
+ * destination like standard error or the GUI. */
+extern LogPolicy default_logpolicy[1];
+
 /*
  * Exports from testback.c
  */
@@ -1358,7 +1408,6 @@ int wc_unescape(char *output, const char *wildcard);
 /*
  * Exports from frontend (windlg.c etc)
  */
-void logevent(Frontend *frontend, const char *);
 void pgp_fingerprints(void);
 /*
  * verify_ssh_host_key() can return one of three values:
@@ -1396,16 +1445,6 @@ int askalg(Frontend *frontend, const char *algtype, const char *algname,
 	   void (*callback)(void *ctx, int result), void *ctx);
 int askhk(Frontend *frontend, const char *algname, const char *betteralgs,
           void (*callback)(void *ctx, int result), void *ctx);
-/*
- * askappend can return four values:
- *
- *  - 2 means overwrite the log file
- *  - 1 means append to the log file
- *  - 0 means cancel logging for this session
- *  - -1 means please wait.
- */
-int askappend(Frontend *frontend, Filename *filename,
-	      void (*callback)(void *ctx, int result), void *ctx);
 
 #ifdef MPEXT
 void display_banner(Frontend *frontend, const char* banner, int size);
@@ -1416,7 +1455,6 @@ void display_banner(Frontend *frontend, const char* banner, int size);
  */
 extern int console_batch_mode;
 int console_get_userpass_input(prompts_t *p);
-void console_provide_logctx(LogContext *logctx);
 int is_interactive(void);
 
 /*

+ 17 - 24
source/putty/ssh.c

@@ -114,15 +114,15 @@ struct Ssh {
 
 
 #define ssh_logevent(params) ( \
-        logevent_and_free((ssh)->frontend, dupprintf params))
+        logevent_and_free((ssh)->logctx, dupprintf params))
 
 static void ssh_shutdown(Ssh *ssh);
 static void ssh_throttle_all(Ssh *ssh, int enable, int bufsize);
 static void ssh_bpp_output_raw_data_callback(void *vctx);
 
-Frontend *ssh_get_frontend(Ssh *ssh)
+LogContext *ssh_get_logctx(Ssh *ssh)
 {
-    return ssh->frontend;
+    return ssh->logctx;
 }
 
 static void ssh_connect_bpp(Ssh *ssh)
@@ -179,7 +179,7 @@ static void ssh_got_ssh_version(struct ssh_version_receiver *rcv,
             int is_simple =
                 (conf_get_int(ssh->conf, CONF_ssh_simple) && !ssh->connshare);
 
-            ssh->bpp = ssh2_bpp_new(ssh->frontend, &ssh->stats);
+            ssh->bpp = ssh2_bpp_new(ssh->logctx, &ssh->stats);
             ssh_connect_bpp(ssh);
 
 #ifndef NO_GSSAPI
@@ -256,7 +256,7 @@ static void ssh_got_ssh_version(struct ssh_version_receiver *rcv,
 
         } else {
 
-            ssh->bpp = ssh1_bpp_new(ssh->frontend);
+            ssh->bpp = ssh1_bpp_new(ssh->logctx);
             ssh_connect_bpp(ssh);
 
             connection_layer = ssh1_connection_new(ssh, ssh->conf, &ssh->cl);
@@ -269,7 +269,7 @@ static void ssh_got_ssh_version(struct ssh_version_receiver *rcv,
         }
 
     } else {
-        ssh->bpp = ssh2_bare_bpp_new(ssh->frontend);
+        ssh->bpp = ssh2_bare_bpp_new(ssh->logctx);
         ssh_connect_bpp(ssh);
 
         connection_layer = ssh2_connection_new(
@@ -409,7 +409,7 @@ void ssh_remote_error(Ssh *ssh, const char *fmt, ...)
          * closed its end (or is about to). */
         ssh_shutdown(ssh);
 
-        logevent(ssh->frontend, msg);
+        logevent(ssh->logctx, msg);
         connection_fatal(ssh->frontend, "%s", msg);
         sfree(msg);
     }
@@ -428,7 +428,7 @@ void ssh_remote_eof(Ssh *ssh, const char *fmt, ...)
          * closed its end. */
         ssh_shutdown(ssh);
 
-        logevent(ssh->frontend, msg);
+        logevent(ssh->logctx, msg);
         sfree(msg);
         notify_remote_exit(ssh->frontend);
     } else {
@@ -449,7 +449,7 @@ void ssh_proto_error(Ssh *ssh, const char *fmt, ...)
                                  SSH2_DISCONNECT_PROTOCOL_ERROR);
         ssh_initiate_connection_close(ssh);
 
-        logevent(ssh->frontend, msg);
+        logevent(ssh->logctx, msg);
         connection_fatal(ssh->frontend, "%s", msg);
         sfree(msg);
     }
@@ -464,7 +464,7 @@ void ssh_sw_abort(Ssh *ssh, const char *fmt, ...)
 
         ssh_initiate_connection_close(ssh);
 
-        logevent(ssh->frontend, msg);
+        logevent(ssh->logctx, msg);
         connection_fatal(ssh->frontend, "%s", msg);
         sfree(msg);
 
@@ -488,7 +488,7 @@ void ssh_user_close(Ssh *ssh, const char *fmt, ...)
 
         ssh_initiate_connection_close(ssh);
 
-        logevent(ssh->frontend, msg);
+        logevent(ssh->logctx, msg);
         sfree(msg);
 
         notify_remote_exit(ssh->frontend);
@@ -510,7 +510,7 @@ static void ssh_socket_log(Plug *plug, int type, SockAddr *addr, int port,
      */
 
     if (!ssh->attempting_connshare)
-        backend_socket_log(ssh->frontend, type, addr, port,
+        backend_socket_log(ssh->frontend, ssh->logctx, type, addr, port,
                            error_msg, error_code, ssh->conf,
                            ssh->session_started);
 }
@@ -652,7 +652,7 @@ static const char *connect_to_host(Ssh *ssh, const char *host, int port,
     ssh->connshare = NULL;
     ssh->attempting_connshare = TRUE;  /* affects socket logging behaviour */
     ssh->s = ssh_connection_sharing_init(
-        ssh->savedhost, ssh->savedport, ssh->conf, ssh->frontend,
+        ssh->savedhost, ssh->savedport, ssh->conf, ssh->logctx,
         &ssh->plug, &ssh->connshare);
     if (ssh->connshare)
         ssh_connshare_provide_connlayer(ssh->connshare, &ssh->cl_dummy);
@@ -684,7 +684,7 @@ static const char *connect_to_host(Ssh *ssh, const char *host, int port,
          */
         addressfamily = conf_get_int(ssh->conf, CONF_addressfamily);
         addr = name_lookup(host, port, realhost, ssh->conf, addressfamily,
-                           ssh->frontend, "SSH connection");
+                           ssh->logctx, "SSH connection");
         if ((err = sk_addr_error(addr)) != NULL) {
             sk_addr_free(addr);
             return err;
@@ -722,7 +722,7 @@ static const char *connect_to_host(Ssh *ssh, const char *host, int port,
      */
     ssh->version_receiver.got_ssh_version = ssh_got_ssh_version;
     ssh->bpp = ssh_verstring_new(
-        ssh->conf, ssh->frontend, ssh->bare_connection,
+        ssh->conf, ssh->logctx, ssh->bare_connection,
         ssh->version == 1 ? "1.5" : "2.0", &ssh->version_receiver);
     ssh_connect_bpp(ssh);
     queue_idempotent_callback(&ssh->bpp->ic_in_raw);
@@ -796,7 +796,7 @@ static void ssh_cache_conf_values(Ssh *ssh)
  * Returns an error message, or NULL on success.
  */
 static const char *ssh_init(Frontend *frontend, Backend **backend_handle,
-			    Conf *conf,
+                            LogContext *logctx, Conf *conf,
                             const char *host, int port, char **realhost,
 			    int nodelay, int keepalive)
 {
@@ -822,7 +822,7 @@ static const char *ssh_init(Frontend *frontend, Backend **backend_handle,
     *backend_handle = &ssh->backend;
 
     ssh->frontend = frontend;
-    ssh->cl_dummy.frontend = frontend;
+    ssh->cl_dummy.logctx = ssh->logctx = logctx;
 
     random_ref(); /* do this now - may be needed by sharing setup code */
     ssh->need_random_unref = TRUE;
@@ -1053,12 +1053,6 @@ static void ssh_provide_ldisc(Backend *be, Ldisc *ldisc)
     ssh->ldisc = ldisc;
 }
 
-static void ssh_provide_logctx(Backend *be, LogContext *logctx)
-{
-    Ssh *ssh = container_of(be, Ssh, backend);
-    ssh->logctx = logctx;
-}
-
 void ssh_got_exitcode(Ssh *ssh, int exitcode)
 {
     ssh->exitcode = exitcode;
@@ -1119,7 +1113,6 @@ const struct BackendVtable ssh_backend = {
     ssh_sendok,
     ssh_ldisc,
     ssh_provide_ldisc,
-    ssh_provide_logctx,
     ssh_unthrottle,
     ssh_cfg_info,
     ssh_test_for_upstream,

+ 4 - 4
source/putty/ssh.h

@@ -167,8 +167,8 @@ int ssh2_censor_packet(
 PktOut *ssh_new_packet(void);
 void ssh_free_pktout(PktOut *pkt);
 
-extern Socket *ssh_connection_sharing_init(
-    const char *host, int port, Conf *conf, Frontend *frontend,
+Socket *ssh_connection_sharing_init(
+    const char *host, int port, Conf *conf, LogContext *logctx,
     Plug *sshplug, ssh_sharing_state **state);
 void ssh_connshare_provide_connlayer(ssh_sharing_state *sharestate,
                                      ConnectionLayer *cl);
@@ -270,7 +270,7 @@ struct ConnectionLayerVtable {
 };
 
 struct ConnectionLayer {
-    Frontend *frontend;
+    LogContext *logctx;
     const struct ConnectionLayerVtable *vt;
 };
 
@@ -313,7 +313,7 @@ char *portfwdmgr_connect(PortFwdManager *mgr, Channel **chan_ret,
                          char *hostname, int port, SshChannel *c,
                          int addressfamily);
 
-Frontend *ssh_get_frontend(Ssh *ssh);
+LogContext *ssh_get_logctx(Ssh *ssh);
 
 /* Communications back to ssh.c from connection layers */
 void ssh_throttle_conn(Ssh *ssh, int adjust);

+ 2 - 5
source/putty/ssh1bpp.c

@@ -43,12 +43,12 @@ static const struct BinaryPacketProtocolVtable ssh1_bpp_vtable = {
     ssh1_bpp_queue_disconnect,
 };
 
-BinaryPacketProtocol *ssh1_bpp_new(Frontend *frontend)
+BinaryPacketProtocol *ssh1_bpp_new(LogContext *logctx)
 {
     struct ssh1_bpp_state *s = snew(struct ssh1_bpp_state);
     memset(s, 0, sizeof(*s));
     s->bpp.vt = &ssh1_bpp_vtable;
-    s->bpp.frontend = frontend;
+    s->bpp.logctx = logctx;
     ssh_bpp_common_setup(&s->bpp);
     return &s->bpp;
 }
@@ -68,9 +68,6 @@ static void ssh1_bpp_free(BinaryPacketProtocol *bpp)
     sfree(s);
 }
 
-#define bpp_logevent(printf_args) \
-    logevent_and_free(s->bpp.frontend, dupprintf printf_args)
-
 void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
                          const struct ssh1_cipheralg *cipher,
                          const void *session_key)

+ 2 - 2
source/putty/ssh1connection.c

@@ -260,11 +260,11 @@ PacketProtocolLayer *ssh1_connection_new(
 
     s->x11authtree = newtree234(x11_authcmp);
 
-    /* Need to get the frontend for s->cl now, because we won't be
+    /* Need to get the log context for s->cl now, because we won't be
      * helpfully notified when a copy is written into s->ppl by our
      * owner. */
     s->cl.vt = &ssh1_connlayer_vtable;
-    s->cl.frontend = ssh_get_frontend(ssh);
+    s->cl.logctx = ssh_get_logctx(ssh);
 
     s->portfwdmgr = portfwdmgr_new(&s->cl);
     s->rportfwds = newtree234(ssh1_rportfwd_cmp);

+ 2 - 2
source/putty/ssh2bpp-bare.c

@@ -33,12 +33,12 @@ static const struct BinaryPacketProtocolVtable ssh2_bare_bpp_vtable = {
     ssh2_bpp_queue_disconnect, /* in sshcommon.c */
 };
 
-BinaryPacketProtocol *ssh2_bare_bpp_new(Frontend *frontend)
+BinaryPacketProtocol *ssh2_bare_bpp_new(LogContext *logctx)
 {
     struct ssh2_bare_bpp_state *s = snew(struct ssh2_bare_bpp_state);
     memset(s, 0, sizeof(*s));
     s->bpp.vt = &ssh2_bare_bpp_vtable;
-    s->bpp.frontend = frontend;
+    s->bpp.logctx = logctx;
     ssh_bpp_common_setup(&s->bpp);
     return &s->bpp;
 }

+ 2 - 5
source/putty/ssh2bpp.c

@@ -54,12 +54,12 @@ static const struct BinaryPacketProtocolVtable ssh2_bpp_vtable = {
 };
 
 BinaryPacketProtocol *ssh2_bpp_new(
-    Frontend *frontend, struct DataTransferStats *stats)
+    LogContext *logctx, struct DataTransferStats *stats)
 {
     struct ssh2_bpp_state *s = snew(struct ssh2_bpp_state);
     memset(s, 0, sizeof(*s));
     s->bpp.vt = &ssh2_bpp_vtable;
-    s->bpp.frontend = frontend;
+    s->bpp.logctx = logctx;
     s->stats = stats;
     ssh_bpp_common_setup(&s->bpp);
     return &s->bpp;
@@ -85,9 +85,6 @@ static void ssh2_bpp_free(BinaryPacketProtocol *bpp)
     sfree(s);
 }
 
-#define bpp_logevent(printf_args) \
-    logevent_and_free(s->bpp.frontend, dupprintf printf_args)
-
 void ssh2_bpp_new_outgoing_crypto(
     BinaryPacketProtocol *bpp,
     const struct ssh2_cipheralg *cipher, const void *ckey, const void *iv,

+ 2 - 2
source/putty/ssh2connection.c

@@ -390,11 +390,11 @@ PacketProtocolLayer *ssh2_connection_new(
 
     s->x11authtree = newtree234(x11_authcmp);
 
-    /* Need to get the frontend for s->cl now, because we won't be
+    /* Need to get the log context for s->cl now, because we won't be
      * helpfully notified when a copy is written into s->ppl by our
      * owner. */
     s->cl.vt = &ssh2_connlayer_vtable;
-    s->cl.frontend = ssh_get_frontend(ssh);
+    s->cl.logctx = ssh_get_logctx(ssh);
 
     s->portfwdmgr = portfwdmgr_new(&s->cl);
     s->rportfwds = newtree234(ssh2_rportfwd_cmp);

+ 11 - 20
source/putty/ssh2userauth.c

@@ -40,7 +40,6 @@ struct ssh2_userauth_state {
         AUTH_TYPE_KEYBOARD_INTERACTIVE,
         AUTH_TYPE_KEYBOARD_INTERACTIVE_QUIET
     } type;
-    int done_service_req;
     int need_pw, can_pubkey, can_passwd, can_keyb_inter;
     int userpass_ret;
     int tried_pubkey_config, done_agent;
@@ -211,7 +210,6 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
 
     crBegin(s->crState);
 
-    s->done_service_req = FALSE;
 #ifndef NO_GSSAPI
     s->tried_gssapi = FALSE;
     s->tried_gssapi_keyex_auth = FALSE;
@@ -414,7 +412,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
 
         s->pktout = ssh_bpp_new_pktout(s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
         put_stringz(s->pktout, s->username);
-        put_stringz(s->pktout, "ssh-connection");/* service requested */
+        put_stringz(s->pktout, s->successor_layer->vt->name);
         put_stringz(s->pktout, "none");    /* method */
         pq_push(s->ppl.out_pq, s->pktout);
         s->type = AUTH_TYPE_NONE;
@@ -639,8 +637,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                 s->pktout = ssh_bpp_new_pktout(
                     s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
                 put_stringz(s->pktout, s->username);
-                put_stringz(s->pktout, "ssh-connection");
-                                                    /* service requested */
+                put_stringz(s->pktout, s->successor_layer->vt->name);
                 put_stringz(s->pktout, "publickey");
                                                     /* method */
                 put_bool(s->pktout, FALSE); /* no signature included */
@@ -671,8 +668,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                     s->pktout = ssh_bpp_new_pktout(
                         s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
                     put_stringz(s->pktout, s->username);
-                    put_stringz(s->pktout, "ssh-connection");
-                                                        /* service requested */
+                    put_stringz(s->pktout, s->successor_layer->vt->name);
                     put_stringz(s->pktout, "publickey");
                                                         /* method */
                     put_bool(s->pktout, TRUE);  /* signature included */
@@ -746,8 +742,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                 s->pktout = ssh_bpp_new_pktout(
                     s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
                 put_stringz(s->pktout, s->username);
-                put_stringz(s->pktout, "ssh-connection");
-                                                /* service requested */
+                put_stringz(s->pktout, s->successor_layer->vt->name);
                 put_stringz(s->pktout, "publickey");    /* method */
                 put_bool(s->pktout, FALSE);
                                                 /* no signature included */
@@ -855,8 +850,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                     s->pktout = ssh_bpp_new_pktout(
                         s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
                     put_stringz(s->pktout, s->username);
-                    put_stringz(s->pktout, "ssh-connection");
-                                                    /* service requested */
+                    put_stringz(s->pktout, s->successor_layer->vt->name);
                     put_stringz(s->pktout, "publickey"); /* method */
                     put_bool(s->pktout, TRUE); /* signature follows */
                     put_stringz(s->pktout, ssh_key_ssh_id(key->key));
@@ -913,7 +907,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                 s->pktout = ssh_bpp_new_pktout(
                     s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
                 put_stringz(s->pktout, s->username);
-                put_stringz(s->pktout, "ssh-connection");
+                put_stringz(s->pktout, s->successor_layer->vt->name);
                 put_stringz(s->pktout, "gssapi-with-mic");
                 ppl_logevent(("Attempting GSSAPI authentication"));
 
@@ -1076,8 +1070,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                 s->pktout = ssh_bpp_new_pktout(
                     s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
                 put_stringz(s->pktout, s->username);
-                put_stringz(s->pktout, "ssh-connection");
-                                                        /* service requested */
+                put_stringz(s->pktout, s->successor_layer->vt->name);
                 put_stringz(s->pktout, "keyboard-interactive");
                                                         /* method */
                 put_stringz(s->pktout, "");     /* lang */
@@ -1301,8 +1294,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                 s->pktout = ssh_bpp_new_pktout(
                     s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
                 put_stringz(s->pktout, s->username);
-                put_stringz(s->pktout, "ssh-connection");
-                                                        /* service requested */
+                put_stringz(s->pktout, s->successor_layer->vt->name);
                 put_stringz(s->pktout, "password");
                 put_bool(s->pktout, FALSE);
                 put_stringz(s->pktout, s->password);
@@ -1441,8 +1433,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                     s->pktout = ssh_bpp_new_pktout(
                         s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
                     put_stringz(s->pktout, s->username);
-                    put_stringz(s->pktout, "ssh-connection");
-                                                        /* service requested */
+                    put_stringz(s->pktout, s->successor_layer->vt->name);
                     put_stringz(s->pktout, "password");
                     put_bool(s->pktout, TRUE);
                     put_stringz(s->pktout, s->password);
@@ -1645,7 +1636,7 @@ static PktOut *ssh2_userauth_gss_packet(
     put_stringpl(sb, s->session_id);
     put_byte(sb, SSH2_MSG_USERAUTH_REQUEST);
     put_stringz(sb, s->username);
-    put_stringz(sb, "ssh-connection");
+    put_stringz(sb, s->successor_layer->vt->name);
     put_stringz(sb, authtype);
 
     /* Compute the mic */
@@ -1660,7 +1651,7 @@ static PktOut *ssh2_userauth_gss_packet(
     } else {
         p = ssh_bpp_new_pktout(s->ppl.bpp, SSH2_MSG_USERAUTH_REQUEST);
         put_stringz(p, s->username);
-        put_stringz(p, "ssh-connection");
+        put_stringz(p, s->successor_layer->vt->name);
         put_stringz(p, authtype);
     }
     put_string(p, mic.value, mic.length);

+ 11 - 5
source/putty/sshbpp.h

@@ -23,7 +23,6 @@ struct BinaryPacketProtocol {
     PacketLogSettings *pls;
     LogContext *logctx;
     Ssh *ssh;
-    Frontend *frontend;
 
     /* ic_in_raw is filled in by the BPP (probably by calling
      * ssh_bpp_common_setup). The BPP's owner triggers it when data is
@@ -53,7 +52,7 @@ struct BinaryPacketProtocol {
  * does centralised parts of the freeing too. */
 void ssh_bpp_free(BinaryPacketProtocol *bpp);
 
-BinaryPacketProtocol *ssh1_bpp_new(Frontend *frontend);
+BinaryPacketProtocol *ssh1_bpp_new(LogContext *logctx);
 void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
                          const struct ssh1_cipheralg *cipher,
                          const void *session_key);
@@ -72,6 +71,13 @@ void ssh2_bpp_queue_disconnect(BinaryPacketProtocol *bpp,
                                const char *msg, int category);
 int ssh2_bpp_check_unimplemented(BinaryPacketProtocol *bpp, PktIn *pktin);
 
+/* Convenience macro for BPPs to send formatted strings to the Event
+ * Log. Assumes a function parameter called 'bpp' is in scope, and
+ * takes a double pair of parens because it passes a whole argument
+ * list to dupprintf. */
+#define bpp_logevent(params) ( \
+        logevent_and_free((bpp)->logctx, dupprintf params))
+
 /*
  * Structure that tracks how much data is sent and received, for
  * purposes of triggering an SSH-2 rekey when either one gets over a
@@ -98,7 +104,7 @@ struct DataTransferStats {
      ((stats)->direction.remaining -= (size), FALSE))
 
 BinaryPacketProtocol *ssh2_bpp_new(
-    Frontend *frontend, struct DataTransferStats *stats);
+    LogContext *logctx, struct DataTransferStats *stats);
 void ssh2_bpp_new_outgoing_crypto(
     BinaryPacketProtocol *bpp,
     const struct ssh2_cipheralg *cipher, const void *ckey, const void *iv,
@@ -121,7 +127,7 @@ void ssh2_bpp_new_incoming_crypto(
  */
 int ssh2_bpp_rekey_inadvisable(BinaryPacketProtocol *bpp);
 
-BinaryPacketProtocol *ssh2_bare_bpp_new(Frontend *frontend);
+BinaryPacketProtocol *ssh2_bare_bpp_new(LogContext *logctx);
 
 /*
  * The initial code to handle the SSH version exchange is also
@@ -134,7 +140,7 @@ struct ssh_version_receiver {
                             int major_version);
 };
 BinaryPacketProtocol *ssh_verstring_new(
-    Conf *conf, Frontend *frontend, int bare_connection_mode,
+    Conf *conf, LogContext *logctx, int bare_connection_mode,
     const char *protoversion, struct ssh_version_receiver *rcv);
 const char *ssh_verstring_get_remote(BinaryPacketProtocol *);
 const char *ssh_verstring_get_local(BinaryPacketProtocol *);

+ 0 - 6
source/putty/sshcommon.c

@@ -664,12 +664,6 @@ const char *ssh2_pkt_type(Pkt_KCtx pkt_kctx, Pkt_ACtx pkt_actx, int type)
  * PacketProtocolLayer.
  */
 
-void ssh_logevent_and_free(void *frontend, char *message)
-{
-    logevent(frontend, message);
-    sfree(message);
-}
-
 void ssh_ppl_replace(PacketProtocolLayer *old, PacketProtocolLayer *new)
 {
     new->bpp = old->bpp;

+ 3 - 2
source/putty/sshppl.h

@@ -55,7 +55,8 @@ struct PacketProtocolLayer {
     bufchain *user_input;
 
     /* Logging and error-reporting facilities. */
-    void *frontend;               /* for logevent, dialog boxes etc */
+    LogContext *logctx;
+    void *frontend;               /* for dialog boxes etc */
     Ssh *ssh;   /* for session termination + assorted connection-layer ops */
 
     /* Known bugs in the remote implementation. */
@@ -126,7 +127,7 @@ void ssh2_userauth_set_transport_layer(PacketProtocolLayer *userauth,
  * scope, and takes a double pair of parens because it passes a whole
  * argument list to dupprintf. */
 #define ppl_logevent(params) ( \
-        logevent_and_free((ppl)->frontend, dupprintf params))
+        logevent_and_free((ppl)->logctx, dupprintf params))
 
 /* Convenience macro for protocol layers to send formatted strings to
  * the terminal. Also expects 'ppl' to be in scope and takes double

+ 3 - 1
source/putty/sshpubk.c

@@ -612,8 +612,10 @@ struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
     }
 
     /* Read the first header line which contains the key type. */
-    if (!read_header(fp, header))
+    if (!read_header(fp, header)) {
+	error = "no header line found in key file";
 	goto error;
+    }
     if (0 == strcmp(header, "PuTTY-User-Key-File-2")) {
 	old_fmt = 0;
     } else if (0 == strcmp(header, "PuTTY-User-Key-File-1")) {

+ 8 - 21
source/putty/sshshare.c

@@ -703,18 +703,6 @@ static void share_remove_forwarding(struct ssh_sharing_connstate *cs,
     sfree(fwd);
 }
 
-static void logeventf(Frontend *frontend, const char *fmt, ...)
-{
-    va_list ap;
-    char *buf;
-
-    va_start(ap, fmt);
-    buf = dupvprintf(fmt, ap);
-    va_end(ap);
-    logevent(frontend, buf);
-    sfree(buf);
-}
-
 static void log_downstream(struct ssh_sharing_connstate *cs,
                            const char *logfmt, ...)
 {
@@ -724,7 +712,7 @@ static void log_downstream(struct ssh_sharing_connstate *cs,
     va_start(ap, logfmt);
     buf = dupvprintf(logfmt, ap);
     va_end(ap);
-    logeventf(cs->parent->cl->frontend,
+    logeventf(cs->parent->cl->logctx,
               "Connection sharing downstream #%u: %s", cs->id, buf);
     sfree(buf);
 }
@@ -738,7 +726,7 @@ static void log_general(struct ssh_sharing_state *sharestate,
     va_start(ap, logfmt);
     buf = dupvprintf(logfmt, ap);
     va_end(ap);
-    logeventf(sharestate->cl->frontend, "Connection sharing: %s", buf);
+    logeventf(sharestate->cl->logctx, "Connection sharing: %s", buf);
     sfree(buf);
 }
 
@@ -2080,7 +2068,7 @@ void ssh_connshare_provide_connlayer(ssh_sharing_state *sharestate,
  * upstream) we return NULL.
  */
 Socket *ssh_connection_sharing_init(
-    const char *host, int port, Conf *conf, Frontend *frontend,
+    const char *host, int port, Conf *conf, LogContext *logctx,
     Plug *sshplug, ssh_sharing_state **state)
 {
     int result, can_upstream, can_downstream;
@@ -2133,16 +2121,16 @@ Socket *ssh_connection_sharing_init(
             /* For this result, if 'logtext' is not NULL then it is an
              * error message indicating a reason why connection sharing
              * couldn't be set up _at all_ */
-            logeventf(frontend,
+            logeventf(logctx,
                       "Could not set up connection sharing: %s", logtext);
         } else {
             /* Failing that, ds_err and us_err indicate why we
              * couldn't be a downstream and an upstream respectively */
             if (ds_err)
-                logeventf(frontend, "Could not set up connection sharing"
+                logeventf(logctx, "Could not set up connection sharing"
                           " as downstream: %s", ds_err);
             if (us_err)
-                logeventf(frontend, "Could not set up connection sharing"
+                logeventf(logctx, "Could not set up connection sharing"
                           " as upstream: %s", us_err);
         }
 
@@ -2160,8 +2148,7 @@ Socket *ssh_connection_sharing_init(
          */
 
         /* 'logtext' is a local endpoint address */
-        logeventf(frontend,
-                  "Using existing shared connection at %s", logtext);
+        logeventf(logctx, "Using existing shared connection at %s", logtext);
 
         *state = NULL;
         sfree(sharestate);
@@ -2177,7 +2164,7 @@ Socket *ssh_connection_sharing_init(
          */
 
         /* 'logtext' is a local endpoint address */
-        logeventf(frontend, "Sharing this connection at %s", logtext);
+        logeventf(logctx, "Sharing this connection at %s", logtext);
 
         *state = sharestate;
         sharestate->listensock = sock;

+ 4 - 5
source/putty/sshverstring.c

@@ -58,7 +58,7 @@ static int ssh_version_includes_v1(const char *ver);
 static int ssh_version_includes_v2(const char *ver);
 
 BinaryPacketProtocol *ssh_verstring_new(
-    Conf *conf, Frontend *frontend, int bare_connection_mode,
+    Conf *conf, LogContext *logctx, int bare_connection_mode,
     const char *protoversion, struct ssh_version_receiver *rcv)
 {
     struct ssh_verstring_state *s = snew(struct ssh_verstring_state);
@@ -87,7 +87,7 @@ BinaryPacketProtocol *ssh_verstring_new(
     assert(s->prefix_wanted.len <= PREFIX_MAXLEN);
 
     s->conf = conf_copy(conf);
-    s->bpp.frontend = frontend;
+    s->bpp.logctx = logctx;
     s->bpp.frontend = frontend;
     s->our_protoversion = dupstr(protoversion);
     s->receiver = rcv;
@@ -146,11 +146,9 @@ static int ssh_version_includes_v2(const char *ver)
     return ssh_versioncmp(ver, "1.99") >= 0;
 }
 
-#define bpp_logevent(printf_args) \
-    logevent_and_free(s->bpp.frontend, dupprintf printf_args)
-
 static void ssh_verstring_send(struct ssh_verstring_state *s)
 {
+    BinaryPacketProtocol *bpp = &s->bpp; /* for bpp_logevent */
     char *p;
     int sv_pos;
 
@@ -422,6 +420,7 @@ static void ssh_verstring_handle_output(BinaryPacketProtocol *bpp)
  */
 static void ssh_detect_bugs(struct ssh_verstring_state *s)
 {
+    BinaryPacketProtocol *bpp = &s->bpp; /* for bpp_logevent */
     const char *imp = s->softwareversion;
 
     s->remote_bugs = 0;

+ 1 - 27
source/putty/windows/winnet.c

@@ -228,13 +228,6 @@ int sk_startup(int hi, int lo)
 	return FALSE;
     }
 
-#ifdef NET_SETUP_DIAGNOSTICS
-    {
-	char buf[80];
-	sprintf(buf, "Using WinSock %d.%d", hi, lo);
-	logevent(NULL, buf);
-    }
-#endif
     return TRUE;
 }
 
@@ -263,9 +256,6 @@ void sk_init(void)
 #ifndef NO_IPV6
     /* Check if we have getaddrinfo in Winsock */
     if (GetProcAddress(winsock_module, "getaddrinfo") != NULL) {
-#ifdef NET_SETUP_DIAGNOSTICS
-	logevent(NULL, "Native WinSock IPv6 support detected");
-#endif
 	GET_WINDOWS_FUNCTION(winsock_module, getaddrinfo);
 	GET_WINDOWS_FUNCTION(winsock_module, freeaddrinfo);
 #pragma option push -w-cpt
@@ -279,9 +269,6 @@ void sk_init(void)
 	/* Fall back to wship6.dll for Windows 2000 */
 	wship6_module = load_system32_dll("wship6.dll");
 	if (wship6_module) {
-#ifdef NET_SETUP_DIAGNOSTICS
-	    logevent(NULL, "WSH IPv6 support detected");
-#endif
 	    GET_WINDOWS_FUNCTION(wship6_module, getaddrinfo);
 	    GET_WINDOWS_FUNCTION(wship6_module, freeaddrinfo);
 #pragma option push -w-cpt
@@ -290,16 +277,9 @@ void sk_init(void)
             /* See comment above about type check */
             GET_WINDOWS_FUNCTION_NO_TYPECHECK(winsock_module, gai_strerror);
 	} else {
-#ifdef NET_SETUP_DIAGNOSTICS
-	    logevent(NULL, "No IPv6 support detected");
-#endif
 	}
     }
     GET_WINDOWS_FUNCTION(winsock2_module, WSAAddressToStringA);
-#else
-#ifdef NET_SETUP_DIAGNOSTICS
-    logevent(NULL, "PuTTY was built without IPv6 support");
-#endif
 #endif
 
     GET_WINDOWS_FUNCTION(winsock_module, WSAAsyncSelect);
@@ -579,9 +559,6 @@ SockAddr *sk_namelookup(const char *host, char **canonicalname,
 	 */
 	if (p_getaddrinfo) {
 	    struct addrinfo hints;
-#ifdef NET_SETUP_DIAGNOSTICS
-	    logevent(NULL, "Using getaddrinfo() for resolving");
-#endif
 	    memset(&hints, 0, sizeof(hints));
 	    hints.ai_family = hint_family;
 	    hints.ai_flags = AI_CANONNAME;
@@ -598,9 +575,6 @@ SockAddr *sk_namelookup(const char *host, char **canonicalname,
 	} else
 #endif
 	{
-#ifdef NET_SETUP_DIAGNOSTICS
-	    logevent(NULL, "Using gethostbyname() for resolving");
-#endif
 	    /*
 	     * Otherwise use the IPv4-only gethostbyname...
 	     * (NOTE: we don't use gethostbyname as a fallback!)
@@ -820,7 +794,7 @@ static int ipv4_is_local_addr(struct in_addr addr)
 		       &retbytes, NULL, NULL) == 0)
 	    n_local_interfaces = retbytes / sizeof(INTERFACE_INFO);
 	else
-	    logevent(NULL, "Unable to get list of local IP addresses");
+            n_local_interfaces = -1;
     }
     if (n_local_interfaces > 0) {
 	int i;