1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Split seat_banner from seat_output.

Previously, SSH authentication banners were displayed by calling the
ordinary seat_output function, and passing it a special value in the
SeatOutputType enumeration indicating an auth banner.

The awkwardness of this was already showing a little in SshProxy's
implementation of seat_output, where it had to check for that special
value and do totally different things for SEAT_OUTPUT_AUTH_BANNER and
everything else. Further work in that area is going to make it more
and more awkward if I keep the two output systems unified.

So let's split them up. Now, Seat has separate output() and banner()
methods, which each implementation can override differently if it
wants to.

All the 'end user' Seat implementations use the centralised
implementation function nullseat_banner_to_stderr(), which turns
banner text straight back into SEAT_OUTPUT_STDERR and passes it on to
seat_output. So I didn't have to tediously implement a boring version
of this function in GTK, Windows GUI, consoles, file transfer etc.
This commit is contained in:
Simon Tatham
2021-10-30 17:06:00 +01:00
parent 971c70e603
commit 74a0be9c56
12 changed files with 53 additions and 27 deletions

View File

@ -8,6 +8,9 @@ size_t nullseat_output(
Seat *seat, SeatOutputType type, const void *data, size_t len) {return 0;}
bool nullseat_eof(Seat *seat) { return true; }
void nullseat_sent(Seat *seat, size_t bufsize) {}
size_t nullseat_banner(Seat *seat, const void *data, size_t len) {return 0;}
size_t nullseat_banner_to_stderr(Seat *seat, const void *data, size_t len)
{ return seat_output(seat, SEAT_OUTPUT_STDERR, data, len); }
int nullseat_get_userpass_input(Seat *seat, prompts_t *p) { return 0; }
void nullseat_notify_session_started(Seat *seat) {}
void nullseat_notify_remote_exit(Seat *seat) {}

View File

@ -224,6 +224,11 @@ static int tempseat_get_userpass_input(Seat *seat, prompts_t *p)
unreachable("get_userpass_input should never be called on TempSeat");
}
static size_t tempseat_banner(Seat *seat, const void *data, size_t len)
{
unreachable("banner should never be called on TempSeat");
}
static int tempseat_confirm_ssh_host_key(
Seat *seat, const char *host, int port, const char *keytype,
char *keystr, const char *keydisp, char **key_fingerprints, bool mismatch,
@ -299,6 +304,7 @@ static const struct SeatVtable tempseat_vt = {
.output = tempseat_output,
.eof = tempseat_eof,
.sent = nullseat_sent,
.banner = tempseat_banner,
.get_userpass_input = tempseat_get_userpass_input,
.notify_session_started = tempseat_notify_session_started,
.notify_remote_exit = tempseat_notify_remote_exit,