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

@ -177,7 +177,7 @@ static const LogPolicyVtable sesschan_logpolicy_vt = {
};
static size_t sesschan_seat_output(
Seat *, bool is_stderr, const void *, size_t);
Seat *, SeatOutputType type, const void *, size_t);
static bool sesschan_seat_eof(Seat *);
static void sesschan_notify_remote_exit(Seat *seat);
static void sesschan_connection_fatal(Seat *seat, const char *message);
@ -612,10 +612,15 @@ bool sesschan_change_window_size(
}
static size_t sesschan_seat_output(
Seat *seat, bool is_stderr, const void *data, size_t len)
Seat *seat, SeatOutputType type, const void *data, size_t len)
{
sesschan *sess = container_of(seat, sesschan, seat);
return sshfwd_write_ext(sess->c, is_stderr, data, len);
/* We don't expect anything but stdout and stderr to come here,
* because the pty backend doesn't generate auth banners */
assert(type != SEAT_OUTPUT_AUTH_BANNER);
return sshfwd_write_ext(sess->c, type == SEAT_OUTPUT_STDERR, data, len);
}
static void sesschan_check_close_callback(void *vctx)

View File

@ -530,7 +530,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
bool mid_line = false;
while (bufchain_size(&s->banner) > 0) {
ptrlen data = bufchain_prefix(&s->banner);
seat_stderr_pl(s->ppl.seat, data);
seat_banner_pl(s->ppl.seat, data);
mid_line =
(((const char *)data.ptr)[data.len-1] != '\n');
bufchain_consume(&s->banner, data.len);
@ -538,7 +538,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
bufchain_clear(&s->banner);
if (mid_line)
seat_stderr_pl(s->ppl.seat, PTRLEN_LITERAL("\r\n"));
seat_banner_pl(s->ppl.seat, PTRLEN_LITERAL("\r\n"));
if (s->banner_scc) {
seat_set_trust_status(s->ppl.seat, true);
@ -1919,6 +1919,6 @@ static void ssh2_userauth_antispoof_msg(
put_byte(sb, '-');
}
put_datapl(sb, PTRLEN_LITERAL("\r\n"));
seat_stderr_pl(s->ppl.seat, ptrlen_from_strbuf(sb));
seat_banner_pl(s->ppl.seat, ptrlen_from_strbuf(sb));
strbuf_free(sb);
}