1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-03 12:32:47 -05:00

Give BPPs a Frontend, so they can do their own logging.

The sshverstring quasi-frontend is passed a Frontend pointer at setup
time, so that it can generate Event Log entries containing the local
and remote version strings and the results of remote bug detection.

I'm promoting that field of sshverstring to a field of the public BPP
structure, so now all BPPs have the right to talk directly to the
frontend if they want to. This means I can move all the log messages
of the form 'Initialised so-and-so cipher/MAC/compression' down into
the BPPs themselves, where they can live exactly alongside the actual
initialisation of those primitives.

It also means BPPs will be able to log interesting things they detect
at any point in the packet stream, which is about to come in useful
for another purpose.
This commit is contained in:
Simon Tatham
2018-10-07 08:16:44 +01:00
parent 36caf03a5b
commit 2e7ced6480
9 changed files with 79 additions and 64 deletions

View File

@ -17,7 +17,6 @@ struct ssh_verstring_state {
int crState;
Conf *conf;
Frontend *frontend;
ptrlen prefix_wanted;
char *our_protoversion;
struct ssh_version_receiver *receiver;
@ -88,7 +87,7 @@ BinaryPacketProtocol *ssh_verstring_new(
assert(s->prefix_wanted.len <= PREFIX_MAXLEN);
s->conf = conf_copy(conf);
s->frontend = frontend;
s->bpp.frontend = frontend;
s->our_protoversion = dupstr(protoversion);
s->receiver = rcv;
@ -146,8 +145,8 @@ static int ssh_version_includes_v2(const char *ver)
return ssh_versioncmp(ver, "1.99") >= 0;
}
#define vs_logevent(printf_args) \
logevent_and_free(s->frontend, dupprintf printf_args)
#define bpp_logevent(printf_args) \
logevent_and_free(s->bpp.frontend, dupprintf printf_args)
static void ssh_verstring_send(struct ssh_verstring_state *s)
{
@ -198,7 +197,7 @@ static void ssh_verstring_send(struct ssh_verstring_state *s)
bufchain_add(s->bpp.out_raw, "\015", 1);
bufchain_add(s->bpp.out_raw, "\012", 1);
vs_logevent(("We claim version: %s", s->our_vstring));
bpp_logevent(("We claim version: %s", s->our_vstring));
}
#define BPP_WAITFOR(minlen) do \
@ -308,7 +307,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
s->vslen--;
s->vstring[s->vslen] = '\0';
vs_logevent(("Remote version: %s", s->vstring));
bpp_logevent(("Remote version: %s", s->vstring));
/*
* Pick out the protocol version and software version. The former
@ -374,7 +373,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
crStopV;
}
vs_logevent(("Using SSH protocol version %d", s->major_protoversion));
bpp_logevent(("Using SSH protocol version %d", s->major_protoversion));
if (!s->send_early) {
/*
@ -443,7 +442,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* sniffing.
*/
s->remote_bugs |= BUG_CHOKES_ON_SSH1_IGNORE;
vs_logevent(("We believe remote version has SSH-1 ignore bug"));
bpp_logevent(("We believe remote version has SSH-1 ignore bug"));
}
if (conf_get_int(s->conf, CONF_sshbug_plainpw1) == FORCE_ON ||
@ -455,8 +454,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* the password.
*/
s->remote_bugs |= BUG_NEEDS_SSH1_PLAIN_PASSWORD;
vs_logevent(("We believe remote version needs a "
"plain SSH-1 password"));
bpp_logevent(("We believe remote version needs a "
"plain SSH-1 password"));
}
if (conf_get_int(s->conf, CONF_sshbug_rsa1) == FORCE_ON ||
@ -468,8 +467,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* an AUTH_RSA message.
*/
s->remote_bugs |= BUG_CHOKES_ON_RSA;
vs_logevent(("We believe remote version can't handle SSH-1 "
"RSA authentication"));
bpp_logevent(("We believe remote version can't handle SSH-1 "
"RSA authentication"));
}
if (conf_get_int(s->conf, CONF_sshbug_hmac2) == FORCE_ON ||
@ -482,7 +481,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* These versions have the HMAC bug.
*/
s->remote_bugs |= BUG_SSH2_HMAC;
vs_logevent(("We believe remote version has SSH-2 HMAC bug"));
bpp_logevent(("We believe remote version has SSH-2 HMAC bug"));
}
if (conf_get_int(s->conf, CONF_sshbug_derivekey2) == FORCE_ON ||
@ -495,8 +494,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* generate the keys).
*/
s->remote_bugs |= BUG_SSH2_DERIVEKEY;
vs_logevent(("We believe remote version has SSH-2 "
"key-derivation bug"));
bpp_logevent(("We believe remote version has SSH-2 "
"key-derivation bug"));
}
if (conf_get_int(s->conf, CONF_sshbug_rsapad2) == FORCE_ON ||
@ -509,7 +508,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* These versions have the SSH-2 RSA padding bug.
*/
s->remote_bugs |= BUG_SSH2_RSA_PADDING;
vs_logevent(("We believe remote version has SSH-2 RSA padding bug"));
bpp_logevent(("We believe remote version has SSH-2 RSA padding bug"));
}
if (conf_get_int(s->conf, CONF_sshbug_pksessid2) == FORCE_ON ||
@ -520,8 +519,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* public-key authentication.
*/
s->remote_bugs |= BUG_SSH2_PK_SESSIONID;
vs_logevent(("We believe remote version has SSH-2 "
"public-key-session-ID bug"));
bpp_logevent(("We believe remote version has SSH-2 "
"public-key-session-ID bug"));
}
if (conf_get_int(s->conf, CONF_sshbug_rekey2) == FORCE_ON ||
@ -537,7 +536,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* These versions have the SSH-2 rekey bug.
*/
s->remote_bugs |= BUG_SSH2_REKEY;
vs_logevent(("We believe remote version has SSH-2 rekey bug"));
bpp_logevent(("We believe remote version has SSH-2 rekey bug"));
}
if (conf_get_int(s->conf, CONF_sshbug_maxpkt2) == FORCE_ON ||
@ -548,8 +547,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* This version ignores our makpkt and needs to be throttled.
*/
s->remote_bugs |= BUG_SSH2_MAXPKT;
vs_logevent(("We believe remote version ignores SSH-2 "
"maximum packet size"));
bpp_logevent(("We believe remote version ignores SSH-2 "
"maximum packet size"));
}
if (conf_get_int(s->conf, CONF_sshbug_ignore2) == FORCE_ON) {
@ -558,7 +557,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* none detected automatically.
*/
s->remote_bugs |= BUG_CHOKES_ON_SSH2_IGNORE;
vs_logevent(("We believe remote version has SSH-2 ignore bug"));
bpp_logevent(("We believe remote version has SSH-2 ignore bug"));
}
if (conf_get_int(s->conf, CONF_sshbug_oldgex2) == FORCE_ON ||
@ -570,7 +569,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* we use the newer version.
*/
s->remote_bugs |= BUG_SSH2_OLDGEX;
vs_logevent(("We believe remote version has outdated SSH-2 GEX"));
bpp_logevent(("We believe remote version has outdated SSH-2 GEX"));
}
if (conf_get_int(s->conf, CONF_sshbug_winadj) == FORCE_ON) {
@ -579,7 +578,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* reason or another. Currently, none detected automatically.
*/
s->remote_bugs |= BUG_CHOKES_ON_WINADJ;
vs_logevent(("We believe remote version has winadj bug"));
bpp_logevent(("We believe remote version has winadj bug"));
}
if (conf_get_int(s->conf, CONF_sshbug_chanreq) == FORCE_ON ||
@ -596,8 +595,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* https://secure.ucc.asn.au/hg/dropbear/rev/cd02449b709c
*/
s->remote_bugs |= BUG_SENDS_LATE_REQUEST_REPLY;
vs_logevent(("We believe remote version has SSH-2 "
"channel request bug"));
bpp_logevent(("We believe remote version has SSH-2 "
"channel request bug"));
}
}