mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-27 01:28:45 -05:00

Thanks to Colin Watson for the report: if pterm is both able (appropriately setgid) and willing (given the right options) to stamp utmp, it will use $DISPLAY as the location to write into utmp, and segfault if it's not set. But in a Wayland-only system it might very well not be set. To fix this I've generalised seat_get_x_display() into seat_get_display(), so that it can also return a display id string like "wayland-0" if that's what's appropriate. So now in that situation pterm will stamp utmp with a Wayland display id in place of an X11 one. However, seat_get_x_display() was also used to retrieve an X11 display name specifically so as to populate $DISPLAY in the terminal's shell. So the new seat_get_display() has a parameter to constrain the returned display to be of a particular type, or NULL if that type isn't available. As a final fallback, in case seat_get_display(seat, SDISP_ANY) might _still_ manage to return NULL for any reason, we catch that and turn it into the empty string before stamping utmp, so that we still won't segfault.
70 lines
3.4 KiB
C
70 lines
3.4 KiB
C
/*
|
|
* Stub methods usable by Seat implementations.
|
|
*/
|
|
|
|
#include "putty.h"
|
|
|
|
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); }
|
|
SeatPromptResult nullseat_get_userpass_input(Seat *seat, prompts_t *p)
|
|
{ return SPR_SW_ABORT("this seat can't handle interactive prompts"); }
|
|
void nullseat_notify_session_started(Seat *seat) {}
|
|
void nullseat_notify_remote_exit(Seat *seat) {}
|
|
void nullseat_notify_remote_disconnect(Seat *seat) {}
|
|
void nullseat_connection_fatal(Seat *seat, const char *message) {}
|
|
void nullseat_nonfatal(Seat *seat, const char *message) {}
|
|
void nullseat_update_specials_menu(Seat *seat) {}
|
|
char *nullseat_get_ttymode(Seat *seat, const char *mode) { return NULL; }
|
|
void nullseat_set_busy_status(Seat *seat, BusyStatus status) {}
|
|
SeatPromptResult nullseat_confirm_ssh_host_key(
|
|
Seat *seat, const char *host, int port, const char *keytype,
|
|
char *keystr, SeatDialogText *text, HelpCtx helpctx,
|
|
void (*callback)(void *ctx, SeatPromptResult result), void *ctx)
|
|
{ return SPR_SW_ABORT("this seat can't handle interactive prompts"); }
|
|
SeatPromptResult nullseat_confirm_weak_crypto_primitive(
|
|
Seat *seat, SeatDialogText *text,
|
|
void (*callback)(void *ctx, SeatPromptResult result), void *ctx)
|
|
{ return SPR_SW_ABORT("this seat can't handle interactive prompts"); }
|
|
SeatPromptResult nullseat_confirm_weak_cached_hostkey(
|
|
Seat *seat, SeatDialogText *text,
|
|
void (*callback)(void *ctx, SeatPromptResult result), void *ctx)
|
|
{ return SPR_SW_ABORT("this seat can't handle interactive prompts"); }
|
|
bool nullseat_is_never_utf8(Seat *seat) { return false; }
|
|
bool nullseat_is_always_utf8(Seat *seat) { return true; }
|
|
void nullseat_echoedit_update(Seat *seat, bool echoing, bool editing) {}
|
|
const char *nullseat_get_display(Seat *seat, SeatDisplayType dtype)
|
|
{ return NULL; }
|
|
bool nullseat_get_windowid(Seat *seat, long *id_out) { return false; }
|
|
bool nullseat_get_window_pixel_size(
|
|
Seat *seat, int *width, int *height) { return false; }
|
|
StripCtrlChars *nullseat_stripctrl_new(
|
|
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic) {return NULL;}
|
|
void nullseat_set_trust_status(Seat *seat, bool trusted) {}
|
|
bool nullseat_can_set_trust_status_yes(Seat *seat) { return true; }
|
|
bool nullseat_can_set_trust_status_no(Seat *seat) { return false; }
|
|
bool nullseat_has_mixed_input_stream_yes(Seat *seat) { return true; }
|
|
bool nullseat_has_mixed_input_stream_no(Seat *seat) { return false; }
|
|
bool nullseat_verbose_no(Seat *seat) { return false; }
|
|
bool nullseat_verbose_yes(Seat *seat) { return true; }
|
|
bool nullseat_interactive_no(Seat *seat) { return false; }
|
|
bool nullseat_interactive_yes(Seat *seat) { return true; }
|
|
bool nullseat_get_cursor_position(Seat *seat, int *x, int *y) { return false; }
|
|
|
|
const SeatDialogPromptDescriptions *nullseat_prompt_descriptions(Seat *seat)
|
|
{
|
|
static const SeatDialogPromptDescriptions descs = {
|
|
.hk_accept_action = "",
|
|
.hk_connect_once_action = "",
|
|
.hk_cancel_action = "",
|
|
.hk_cancel_action_Participle = "",
|
|
.weak_accept_action = "",
|
|
.weak_cancel_action = "",
|
|
};
|
|
return &descs;
|
|
}
|