Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2021-10-30 20:05:36 +0300
committerSimon Tatham <anakin@pobox.com>2021-10-30 20:20:33 +0300
commitf00c72cc2a92ce2c49e6951a05860ddca551e1cd (patch)
tree0820ca4d83e50b8421e56bb41856f0c71d88893e /ssh/transport2.c
parent89a390bdeb5b624e17789518efb843e3a88b5417 (diff)
Framework for announcing which Interactor is talking.
All this Interactor business has been gradually working towards being able to inform the user _which_ network connection is currently presenting them with a password prompt (or whatever), in situations where more than one of them might be, such as an SSH connection being used as a proxy for another SSH connection when neither one has one-touch login configured. At some point, we have to arrange that any attempt to do a user interaction during connection setup - be it a password prompt, a host key confirmation dialog, or just displaying an SSH login banner - makes it clear which host it's come from. That's going to mean calling some kind of announcement function before doing any of those things. But there are several of those functions in the Seat API, and calls to them are scattered far and wide across the SSH backend. (And not even just there - the Rlogin backend also uses seat_get_userpass_input). How can we possibly make sure we don't forget a vital call site on some obscure little-tested code path, and leave the user confused in just that one case which nobody might notice for years? Today I thought of a trick to solve that problem. We can use the C type system to enforce it for us! The plan is: we invent a new struct type which contains nothing but a 'Seat *'. Then, for every Seat method which does a thing that ought to be clearly identified as relating to a particular Interactor, we adjust the API for that function to take the new struct type where it previously took a plain 'Seat *'. Or rather - doing less violence to the existing code - we only need to adjust the API of the dispatch functions inline in putty.h. How does that help? Because the way you _get_ one of these struct-wrapped Seat pointers is by calling interactor_announce() on your Interactor, which will in turn call interactor_get_seat(), and wrap the returned pointer into one of these structs. The effect is that whenever the SSH (or Rlogin) code wants to call one of those particular Seat methods, it _has_ to call interactor_announce() just beforehand, which (once I finish all of this) will make sure the user is aware of who is presenting the prompt or banner or whatever. And you can't forget to call it, because if you don't call it, then you just don't have a struct of the right type to give to the Seat method you wanted to call! (Of course, there's nothing stopping code from _deliberately_ taking a Seat * it already has and wrapping it into the new struct. In fact SshProxy has to do that, in order to forward these requests up the chain of Seats. But the point is that you can't do it _by accident_, just by forgetting to make a vital function call - when you do that, you _know_ you're doing it on purpose.) No functional change: the new interactor_announce() function exists, and the type-system trick ensures it's called in all the right places, but it doesn't actually _do_ anything yet.
Diffstat (limited to 'ssh/transport2.c')
-rw-r--r--ssh/transport2.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ssh/transport2.c b/ssh/transport2.c
index 9c49d55c..f0975431 100644
--- a/ssh/transport2.c
+++ b/ssh/transport2.c
@@ -1313,7 +1313,7 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
/* Use the special warning prompt that lets us provide
* a list of better algorithms */
s->dlgret = seat_confirm_weak_cached_hostkey(
- s->ppl.seat, s->hostkey_alg->ssh_id, betteralgs,
+ ppl_get_iseat(&s->ppl), s->hostkey_alg->ssh_id, betteralgs,
ssh2_transport_dialog_callback, s);
sfree(betteralgs);
} else {
@@ -2148,7 +2148,7 @@ static int ssh2_transport_confirm_weak_crypto_primitive(
add234(s->weak_algorithms_consented_to, (void *)alg);
return seat_confirm_weak_crypto_primitive(
- s->ppl.seat, type, name, ssh2_transport_dialog_callback, s);
+ ppl_get_iseat(&s->ppl), type, name, ssh2_transport_dialog_callback, s);
}
static size_t ssh2_transport_queued_data_size(PacketProtocolLayer *ppl)