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

seat_output: add an output type for SSH banners. (NFC)

The jump host system ought really to be treating SSH authentication
banners as a distinct thing from the standard-error session output, so
that the former can be presented to the user in the same way as the
auth banner for the main session.

This change converts the 'bool is_stderr' parameter of seat_output()
into an enumerated type with three values. For the moment, stderr and
banners are treated the same, but the plan is for that to change.
This commit is contained in:
Simon Tatham
2021-09-16 14:46:49 +01:00
parent a45ae81797
commit ac47e550c6
12 changed files with 70 additions and 43 deletions

View File

@ -5,7 +5,7 @@
#include "putty.h"
size_t nullseat_output(
Seat *seat, bool is_stderr, const void *data, size_t len) { return 0; }
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) {}
int nullseat_get_userpass_input(Seat *seat, prompts_t *p) { return 0; }

View File

@ -17,7 +17,7 @@
typedef struct TempSeat TempSeat;
struct TempSeat {
Seat *realseat;
bufchain outputs[2]; /* stdout, stderr */
bufchain outputs[3]; /* stdout, stderr, auth banner (just in case) */
bool seen_session_started;
bool seen_remote_exit;
bool seen_remote_disconnect;
@ -33,12 +33,19 @@ struct TempSeat {
* real Seat in tempseat_flush().
*/
static size_t tempseat_output(Seat *seat, bool is_stderr, const void *data,
size_t len)
static size_t tempseat_output(Seat *seat, SeatOutputType type,
const void *data, size_t len)
{
TempSeat *ts = container_of(seat, TempSeat, seat);
bufchain_add(&ts->outputs[is_stderr], data, len);
return bufchain_size(&ts->outputs[0]) + bufchain_size(&ts->outputs[1]);
size_t index = (size_t)type;
assert(index < lenof(ts->outputs));
bufchain_add(&ts->outputs[index], data, len);
size_t total_size = 0;
for (size_t i = 0; i < lenof(ts->outputs); i++)
total_size += bufchain_size(&ts->outputs[i]);
return total_size;
}
static void tempseat_notify_session_started(Seat *seat)
@ -295,7 +302,7 @@ Seat *tempseat_new(Seat *realseat)
ts->seat.vt = &tempseat_vt;
ts->realseat = realseat;
for (unsigned i = 0; i < 2; i++)
for (size_t i = 0; i < lenof(ts->outputs); i++)
bufchain_init(&ts->outputs[i]);
return &ts->seat;
@ -327,8 +334,8 @@ void tempseat_flush(Seat *seat)
assert(seat->vt == &tempseat_vt);
TempSeat *ts = container_of(seat, TempSeat, seat);
/* Empty the stdout/stderr bufchains into the real seat */
for (unsigned i = 0; i < 2; i++) {
/* Empty the output bufchains into the real seat */
for (size_t i = 0; i < lenof(ts->outputs); i++) {
while (bufchain_size(&ts->outputs[i])) {
ptrlen pl = bufchain_prefix(&ts->outputs[i]);
seat_output(ts->realseat, i, pl.ptr, pl.len);