From 5d58931b51ff1223f1b2208956538cfadd702c0b Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 12 Mar 2022 20:17:30 +0000 Subject: [PATCH] Fix trust status when Interactor returns a seat. While testing the unrelated pile of commits just past, I accidentally started a Cygwin saved session I hadn't run in ages which used the old Telnet-based cygtermd as a local proxy command, and found that it presented the Cygwin prompt with a trust sigil. Oops! It turns out that this is because interactor_return_seat does two things that can change the real seat's trust status, and it does them in the wrong order: it defaults the status back to trusted (as if the seat was brand new, because that's how they start out), and it calls tempseat_flush which may have buffered a trust-status reset while the seat was borrowed. The former should not override the latter! --- proxy/interactor.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/proxy/interactor.c b/proxy/interactor.c index 958e5a98..d069d226 100644 --- a/proxy/interactor.c +++ b/proxy/interactor.c @@ -47,8 +47,18 @@ void interactor_return_seat(Interactor *itr) if (!is_tempseat(tempseat)) return; /* no-op */ - tempseat_flush(tempseat); + /* + * We're about to hand this seat back to the parent Interactor to + * do its own thing with. It will typically expect to start in the + * same state as if the seat had never been borrowed, i.e. in the + * starting trust state. + * + * However, this may be overridden by the tempseat_flush call. + */ Seat *realseat = tempseat_get_real(tempseat); + seat_set_trust_status(realseat, true); + + tempseat_flush(tempseat); interactor_set_seat(itr, realseat); tempseat_free(tempseat); @@ -60,14 +70,6 @@ void interactor_return_seat(Interactor *itr) Interactor *itr_top = interactor_toplevel(itr, NULL); if (itr_top->last_to_talk) interactor_announce(itr); - - /* - * We're about to hand this seat back to the parent Interactor to - * do its own thing with. It will typically expect to start in the - * same state as if the seat had never been borrowed, i.e. in the - * starting trust state. - */ - seat_set_trust_status(realseat, true); } InteractionReadySeat interactor_announce(Interactor *itr)