mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Framework for announcing which Interactor is talking.
All this Interactor business has been gradually working towards being able to inform the user _which_ network connection is currently presenting them with a password prompt (or whatever), in situations where more than one of them might be, such as an SSH connection being used as a proxy for another SSH connection when neither one has one-touch login configured. At some point, we have to arrange that any attempt to do a user interaction during connection setup - be it a password prompt, a host key confirmation dialog, or just displaying an SSH login banner - makes it clear which host it's come from. That's going to mean calling some kind of announcement function before doing any of those things. But there are several of those functions in the Seat API, and calls to them are scattered far and wide across the SSH backend. (And not even just there - the Rlogin backend also uses seat_get_userpass_input). How can we possibly make sure we don't forget a vital call site on some obscure little-tested code path, and leave the user confused in just that one case which nobody might notice for years? Today I thought of a trick to solve that problem. We can use the C type system to enforce it for us! The plan is: we invent a new struct type which contains nothing but a 'Seat *'. Then, for every Seat method which does a thing that ought to be clearly identified as relating to a particular Interactor, we adjust the API for that function to take the new struct type where it previously took a plain 'Seat *'. Or rather - doing less violence to the existing code - we only need to adjust the API of the dispatch functions inline in putty.h. How does that help? Because the way you _get_ one of these struct-wrapped Seat pointers is by calling interactor_announce() on your Interactor, which will in turn call interactor_get_seat(), and wrap the returned pointer into one of these structs. The effect is that whenever the SSH (or Rlogin) code wants to call one of those particular Seat methods, it _has_ to call interactor_announce() just beforehand, which (once I finish all of this) will make sure the user is aware of who is presenting the prompt or banner or whatever. And you can't forget to call it, because if you don't call it, then you just don't have a struct of the right type to give to the Seat method you wanted to call! (Of course, there's nothing stopping code from _deliberately_ taking a Seat * it already has and wrapping it into the new struct. In fact SshProxy has to do that, in order to forward these requests up the chain of Seats. But the point is that you can't do it _by accident_, just by forgetting to make a vital function call - when you do that, you _know_ you're doing it on purpose.) No functional change: the new interactor_announce() function exists, and the type-system trick ensures it's called in all the right places, but it doesn't actually _do_ anything yet.
This commit is contained in:
parent
89a390bdeb
commit
f00c72cc2a
@ -33,7 +33,8 @@ add_library(crypto STATIC
|
||||
add_subdirectory(crypto)
|
||||
|
||||
add_library(network STATIC
|
||||
be_misc.c nullplug.c errsock.c proxy/proxy.c logging.c x11disp.c)
|
||||
be_misc.c nullplug.c errsock.c logging.c x11disp.c
|
||||
proxy/proxy.c proxy/interactor.c)
|
||||
|
||||
add_library(keygen STATIC
|
||||
import.c)
|
||||
|
1
defs.h
1
defs.h
@ -103,6 +103,7 @@ typedef struct Backend Backend;
|
||||
typedef struct BackendVtable BackendVtable;
|
||||
typedef struct Interactor Interactor;
|
||||
typedef struct InteractorVtable InteractorVtable;
|
||||
typedef struct InteractionReadySeat InteractionReadySeat;
|
||||
|
||||
typedef struct Ldisc_tag Ldisc;
|
||||
typedef struct LogContext LogContext;
|
||||
|
@ -335,7 +335,8 @@ static void rlogin_try_username_prompt(void *ctx)
|
||||
{
|
||||
Rlogin *rlogin = (Rlogin *)ctx;
|
||||
|
||||
int ret = seat_get_userpass_input(rlogin->seat, rlogin->prompt);
|
||||
int ret = seat_get_userpass_input(
|
||||
interactor_announce(&rlogin->interactor), rlogin->prompt);
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
|
18
proxy/interactor.c
Normal file
18
proxy/interactor.c
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Centralised functions for the Interactor trait.
|
||||
*/
|
||||
|
||||
#include "putty.h"
|
||||
|
||||
InteractionReadySeat interactor_announce(Interactor *itr)
|
||||
{
|
||||
Seat *seat = interactor_get_seat(itr);
|
||||
|
||||
/* TODO: print an announcement of this Interactor's identity, when
|
||||
* appropriate */
|
||||
|
||||
InteractionReadySeat iseat;
|
||||
iseat.seat = seat;
|
||||
|
||||
return iseat;
|
||||
}
|
@ -267,6 +267,13 @@ static size_t sshproxy_output(Seat *seat, SeatOutputType type,
|
||||
return bufchain_size(&sp->ssh_to_socket);
|
||||
}
|
||||
|
||||
static inline InteractionReadySeat wrap(Seat *seat)
|
||||
{
|
||||
InteractionReadySeat iseat;
|
||||
iseat.seat = seat;
|
||||
return iseat;
|
||||
}
|
||||
|
||||
static size_t sshproxy_banner(Seat *seat, const void *data, size_t len)
|
||||
{
|
||||
SshProxy *sp = container_of(seat, SshProxy, seat);
|
||||
@ -275,7 +282,7 @@ static size_t sshproxy_banner(Seat *seat, const void *data, size_t len)
|
||||
* If we have access to the outer Seat, pass the SSH login
|
||||
* banner on to it.
|
||||
*/
|
||||
return seat_banner(sp->clientseat, data, len);
|
||||
return seat_banner(wrap(sp->clientseat), data, len);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -311,7 +318,7 @@ static int sshproxy_get_userpass_input(Seat *seat, prompts_t *p)
|
||||
* If we have access to the outer Seat, pass this prompt
|
||||
* request on to it. FIXME: appropriately adjusted
|
||||
*/
|
||||
return seat_get_userpass_input(sp->clientseat, p);
|
||||
return seat_get_userpass_input(wrap(sp->clientseat), p);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -353,7 +360,7 @@ static int sshproxy_confirm_ssh_host_key(
|
||||
* request on to it. FIXME: appropriately adjusted
|
||||
*/
|
||||
return seat_confirm_ssh_host_key(
|
||||
sp->clientseat, host, port, keytype, keystr, keydisp,
|
||||
wrap(sp->clientseat), host, port, keytype, keystr, keydisp,
|
||||
key_fingerprints, mismatch, callback, ctx);
|
||||
}
|
||||
|
||||
@ -377,7 +384,7 @@ static int sshproxy_confirm_weak_crypto_primitive(
|
||||
* request on to it. FIXME: appropriately adjusted
|
||||
*/
|
||||
return seat_confirm_weak_crypto_primitive(
|
||||
sp->clientseat, algtype, algname, callback, ctx);
|
||||
wrap(sp->clientseat), algtype, algname, callback, ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -402,7 +409,7 @@ static int sshproxy_confirm_weak_cached_hostkey(
|
||||
* request on to it. FIXME: appropriately adjusted
|
||||
*/
|
||||
return seat_confirm_weak_cached_hostkey(
|
||||
sp->clientseat, algname, betteralgs, callback, ctx);
|
||||
wrap(sp->clientseat), algname, betteralgs, callback, ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
54
putty.h
54
putty.h
@ -633,6 +633,24 @@ enum {
|
||||
/* In (no)sshproxy.c */
|
||||
extern const bool ssh_proxy_supported;
|
||||
|
||||
/*
|
||||
* This structure type wraps a Seat pointer, in a way that has no
|
||||
* purpose except to be a different type.
|
||||
*
|
||||
* The Seat wrapper functions that present interactive prompts all
|
||||
* expect one of these in place of their ordinary Seat pointer. You
|
||||
* get one by calling interactor_announce (defined below), which will
|
||||
* print a message (if not already done) identifying the Interactor
|
||||
* that originated the prompt.
|
||||
*
|
||||
* This arranges that the C type system itself will check that no call
|
||||
* to any of those Seat methods has omitted the mandatory call to
|
||||
* interactor_announce beforehand.
|
||||
*/
|
||||
struct InteractionReadySeat {
|
||||
Seat *seat;
|
||||
};
|
||||
|
||||
/*
|
||||
* The Interactor trait is implemented by anything that is capable of
|
||||
* presenting interactive prompts or questions to the user during
|
||||
@ -688,6 +706,8 @@ static inline Seat *interactor_get_seat(Interactor *itr)
|
||||
static inline void interactor_set_seat(Interactor *itr, Seat *seat)
|
||||
{ itr->vt->set_seat(itr, seat); }
|
||||
|
||||
InteractionReadySeat interactor_announce(Interactor *itr);
|
||||
|
||||
/* Interactors that are Backends will find this helper function useful
|
||||
* in constructing their description strings */
|
||||
char *default_description(const BackendVtable *backvt,
|
||||
@ -1277,10 +1297,12 @@ static inline bool seat_eof(Seat *seat)
|
||||
{ return seat->vt->eof(seat); }
|
||||
static inline void seat_sent(Seat *seat, size_t bufsize)
|
||||
{ seat->vt->sent(seat, bufsize); }
|
||||
static inline size_t seat_banner(Seat *seat, const void *data, size_t len)
|
||||
{ return seat->vt->banner(seat, data, len); }
|
||||
static inline int seat_get_userpass_input(Seat *seat, prompts_t *p)
|
||||
{ return seat->vt->get_userpass_input(seat, p); }
|
||||
static inline size_t seat_banner(
|
||||
InteractionReadySeat iseat, const void *data, size_t len)
|
||||
{ return iseat.seat->vt->banner(iseat.seat, data, len); }
|
||||
static inline int seat_get_userpass_input(InteractionReadySeat iseat,
|
||||
prompts_t *p)
|
||||
{ return iseat.seat->vt->get_userpass_input(iseat.seat, p); }
|
||||
static inline void seat_notify_session_started(Seat *seat)
|
||||
{ seat->vt->notify_session_started(seat); }
|
||||
static inline void seat_notify_remote_exit(Seat *seat)
|
||||
@ -1294,19 +1316,21 @@ static inline char *seat_get_ttymode(Seat *seat, const char *mode)
|
||||
static inline void seat_set_busy_status(Seat *seat, BusyStatus status)
|
||||
{ seat->vt->set_busy_status(seat, status); }
|
||||
static inline int seat_confirm_ssh_host_key(
|
||||
Seat *seat, const char *h, int p, const char *ktyp, char *kstr,
|
||||
const char *kdsp, char **fps, bool mis,
|
||||
InteractionReadySeat iseat, const char *h, int p, const char *ktyp,
|
||||
char *kstr, const char *kdsp, char **fps, bool mis,
|
||||
void (*cb)(void *ctx, int result), void *ctx)
|
||||
{ return seat->vt->confirm_ssh_host_key(seat, h, p, ktyp, kstr, kdsp, fps,
|
||||
mis, cb, ctx); }
|
||||
{ return iseat.seat->vt->confirm_ssh_host_key(
|
||||
iseat.seat, h, p, ktyp, kstr, kdsp, fps, mis, cb, ctx); }
|
||||
static inline int seat_confirm_weak_crypto_primitive(
|
||||
Seat *seat, const char *atyp, const char *aname,
|
||||
InteractionReadySeat iseat, const char *atyp, const char *aname,
|
||||
void (*cb)(void *ctx, int result), void *ctx)
|
||||
{ return seat->vt->confirm_weak_crypto_primitive(seat, atyp, aname, cb, ctx); }
|
||||
{ return iseat.seat->vt->confirm_weak_crypto_primitive(
|
||||
iseat.seat, atyp, aname, cb, ctx); }
|
||||
static inline int seat_confirm_weak_cached_hostkey(
|
||||
Seat *seat, const char *aname, const char *better,
|
||||
InteractionReadySeat iseat, const char *aname, const char *better,
|
||||
void (*cb)(void *ctx, int result), void *ctx)
|
||||
{ return seat->vt->confirm_weak_cached_hostkey(seat, aname, better, cb, ctx); }
|
||||
{ return iseat.seat->vt->confirm_weak_cached_hostkey(
|
||||
iseat.seat, aname, better, cb, ctx); }
|
||||
static inline bool seat_is_utf8(Seat *seat)
|
||||
{ return seat->vt->is_utf8(seat); }
|
||||
static inline void seat_echoedit_update(Seat *seat, bool ec, bool ed)
|
||||
@ -1347,12 +1371,12 @@ static inline size_t seat_stderr_pl(Seat *seat, ptrlen data)
|
||||
{ return seat_output(seat, SEAT_OUTPUT_STDERR, data.ptr, data.len); }
|
||||
|
||||
/* Alternative API for seat_banner taking a ptrlen */
|
||||
static inline size_t seat_banner_pl(Seat *seat, ptrlen data)
|
||||
{ return seat->vt->banner(seat, data.ptr, data.len); }
|
||||
static inline size_t seat_banner_pl(InteractionReadySeat iseat, ptrlen data)
|
||||
{ return iseat.seat->vt->banner(iseat.seat, data.ptr, data.len); }
|
||||
|
||||
/* In the utils subdir: print a message to the Seat which can't be
|
||||
* spoofed by server-supplied auth-time output such as SSH banners */
|
||||
void seat_antispoof_msg(Seat *seat, const char *msg);
|
||||
void seat_antispoof_msg(InteractionReadySeat iseat, const char *msg);
|
||||
|
||||
/*
|
||||
* Stub methods for seat implementations that want to use the obvious
|
||||
|
4
ssh.h
4
ssh.h
@ -1708,8 +1708,8 @@ void add_to_commasep(strbuf *buf, const char *data);
|
||||
bool get_commasep_word(ptrlen *list, ptrlen *word);
|
||||
|
||||
int verify_ssh_host_key(
|
||||
Seat *seat, Conf *conf, const char *host, int port, ssh_key *key,
|
||||
const char *keytype, char *keystr, const char *keydisp,
|
||||
InteractionReadySeat iseat, Conf *conf, const char *host, int port,
|
||||
ssh_key *key, const char *keytype, char *keystr, const char *keydisp,
|
||||
char **fingerprints, void (*callback)(void *ctx, int result), void *ctx);
|
||||
|
||||
typedef struct ssh_transient_hostkey_cache ssh_transient_hostkey_cache;
|
||||
|
@ -851,8 +851,8 @@ bool ssh2_bpp_check_unimplemented(BinaryPacketProtocol *bpp, PktIn *pktin)
|
||||
*/
|
||||
|
||||
int verify_ssh_host_key(
|
||||
Seat *seat, Conf *conf, const char *host, int port, ssh_key *key,
|
||||
const char *keytype, char *keystr, const char *keydisp,
|
||||
InteractionReadySeat iseat, Conf *conf, const char *host, int port,
|
||||
ssh_key *key, const char *keytype, char *keystr, const char *keydisp,
|
||||
char **fingerprints, void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
/*
|
||||
@ -923,7 +923,7 @@ int verify_ssh_host_key(
|
||||
*/
|
||||
bool mismatch = (storage_status != 1);
|
||||
return seat_confirm_ssh_host_key(
|
||||
seat, host, port, keytype, keystr, keydisp, fingerprints, mismatch,
|
||||
iseat, host, port, keytype, keystr, keydisp, fingerprints, mismatch,
|
||||
callback, ctx);
|
||||
}
|
||||
|
||||
|
@ -380,11 +380,11 @@ static void ssh1_connection_process_queue(PacketProtocolLayer *ppl)
|
||||
s->antispoof_prompt,
|
||||
dupstr("Access granted. Press Return to begin session. "), false);
|
||||
s->antispoof_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->antispoof_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->antispoof_prompt);
|
||||
while (s->antispoof_ret < 0) {
|
||||
crReturnV;
|
||||
s->antispoof_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->antispoof_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->antispoof_prompt);
|
||||
}
|
||||
free_prompts(s->antispoof_prompt);
|
||||
s->antispoof_prompt = NULL;
|
||||
|
@ -993,11 +993,11 @@ static void ssh2_connection_process_queue(PacketProtocolLayer *ppl)
|
||||
s->antispoof_prompt,
|
||||
dupstr("Access granted. Press Return to begin session. "), false);
|
||||
s->antispoof_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->antispoof_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->antispoof_prompt);
|
||||
while (s->antispoof_ret < 0) {
|
||||
crReturnV;
|
||||
s->antispoof_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->antispoof_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->antispoof_prompt);
|
||||
}
|
||||
free_prompts(s->antispoof_prompt);
|
||||
s->antispoof_prompt = NULL;
|
||||
|
@ -854,8 +854,8 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
|
||||
ppl_logevent("%s", fingerprints[fptype_default]);
|
||||
|
||||
s->dlgret = verify_ssh_host_key(
|
||||
s->ppl.seat, s->conf, s->savedhost, s->savedport, s->hkey,
|
||||
ssh_key_cache_id(s->hkey), s->keystr, keydisp,
|
||||
ppl_get_iseat(&s->ppl), s->conf, s->savedhost, s->savedport,
|
||||
s->hkey, ssh_key_cache_id(s->hkey), s->keystr, keydisp,
|
||||
fingerprints, ssh2_transport_dialog_callback, s);
|
||||
|
||||
ssh2_free_all_fingerprints(fingerprints);
|
||||
|
18
ssh/login1.c
18
ssh/login1.c
@ -243,7 +243,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
|
||||
char **fingerprints = rsa_ssh1_fake_all_fingerprints(&s->hostkey);
|
||||
|
||||
s->dlgret = verify_ssh_host_key(
|
||||
s->ppl.seat, s->conf, s->savedhost, s->savedport, NULL,
|
||||
ppl_get_iseat(&s->ppl), s->conf, s->savedhost, s->savedport, NULL,
|
||||
"rsa", keystr, keydisp, fingerprints,
|
||||
ssh1_login_dialog_callback, s);
|
||||
|
||||
@ -325,7 +325,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
|
||||
/* Warn about chosen cipher if necessary. */
|
||||
if (warn) {
|
||||
s->dlgret = seat_confirm_weak_crypto_primitive(
|
||||
s->ppl.seat, "cipher", cipher_string,
|
||||
ppl_get_iseat(&s->ppl), "cipher", cipher_string,
|
||||
ssh1_login_dialog_callback, s);
|
||||
crMaybeWaitUntilV(s->dlgret >= 0);
|
||||
if (s->dlgret == 0) {
|
||||
@ -391,11 +391,12 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
|
||||
s->cur_prompt->from_server = false;
|
||||
s->cur_prompt->name = dupstr("SSH login name");
|
||||
add_prompt(s->cur_prompt, dupstr("login as: "), true);
|
||||
s->userpass_ret = seat_get_userpass_input(s->ppl.seat, s->cur_prompt);
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
while (s->userpass_ret < 0) {
|
||||
crReturnV;
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
}
|
||||
if (!s->userpass_ret) {
|
||||
/*
|
||||
@ -688,11 +689,11 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
|
||||
dupprintf("Passphrase for key \"%s\": ",
|
||||
s->publickey_comment), false);
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
while (s->userpass_ret < 0) {
|
||||
crReturnV;
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
}
|
||||
if (!s->userpass_ret) {
|
||||
/* Failed to get a passphrase. Terminate. */
|
||||
@ -942,11 +943,12 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
|
||||
* or CryptoCard exchange if we're doing TIS or CryptoCard
|
||||
* authentication.
|
||||
*/
|
||||
s->userpass_ret = seat_get_userpass_input(s->ppl.seat, s->cur_prompt);
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
while (s->userpass_ret < 0) {
|
||||
crReturnV;
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
}
|
||||
if (!s->userpass_ret) {
|
||||
/*
|
||||
|
@ -49,6 +49,7 @@ struct PacketProtocolLayer {
|
||||
/* Logging and error-reporting facilities. */
|
||||
LogContext *logctx;
|
||||
Seat *seat; /* for dialog boxes, session output etc */
|
||||
Interactor *interactor; /* for ppl_get_iseat */
|
||||
Ssh *ssh; /* for session termination + assorted connection-layer ops */
|
||||
|
||||
/* Known bugs in the remote implementation. */
|
||||
@ -68,6 +69,9 @@ static inline void ssh_ppl_reconfigure(PacketProtocolLayer *ppl, Conf *conf)
|
||||
static inline size_t ssh_ppl_queued_data_size(PacketProtocolLayer *ppl)
|
||||
{ return ppl->vt->queued_data_size(ppl); }
|
||||
|
||||
static inline InteractionReadySeat ppl_get_iseat(PacketProtocolLayer *ppl)
|
||||
{ return interactor_announce(ppl->interactor); }
|
||||
|
||||
/* ssh_ppl_free is more than just a macro wrapper on the vtable; it
|
||||
* does centralised parts of the freeing too. */
|
||||
void ssh_ppl_free(PacketProtocolLayer *ppl);
|
||||
|
@ -375,6 +375,7 @@ static void server_connect_ppl(server *srv, PacketProtocolLayer *ppl)
|
||||
ppl->logctx = srv->logctx;
|
||||
ppl->ssh = &srv->ssh;
|
||||
ppl->seat = &srv->seat;
|
||||
ppl->interactor = NULL;
|
||||
ppl->remote_bugs = srv->remote_bugs;
|
||||
}
|
||||
|
||||
|
@ -168,6 +168,7 @@ static void ssh_connect_ppl(Ssh *ssh, PacketProtocolLayer *ppl)
|
||||
{
|
||||
ppl->bpp = ssh->bpp;
|
||||
ppl->seat = ssh->seat;
|
||||
ppl->interactor = &ssh->interactor;
|
||||
ppl->ssh = ssh;
|
||||
ppl->logctx = ssh->logctx;
|
||||
ppl->remote_bugs = ssh->remote_bugs;
|
||||
|
@ -1313,7 +1313,7 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
|
||||
/* Use the special warning prompt that lets us provide
|
||||
* a list of better algorithms */
|
||||
s->dlgret = seat_confirm_weak_cached_hostkey(
|
||||
s->ppl.seat, s->hostkey_alg->ssh_id, betteralgs,
|
||||
ppl_get_iseat(&s->ppl), s->hostkey_alg->ssh_id, betteralgs,
|
||||
ssh2_transport_dialog_callback, s);
|
||||
sfree(betteralgs);
|
||||
} else {
|
||||
@ -2148,7 +2148,7 @@ static int ssh2_transport_confirm_weak_crypto_primitive(
|
||||
add234(s->weak_algorithms_consented_to, (void *)alg);
|
||||
|
||||
return seat_confirm_weak_crypto_primitive(
|
||||
s->ppl.seat, type, name, ssh2_transport_dialog_callback, s);
|
||||
ppl_get_iseat(&s->ppl), type, name, ssh2_transport_dialog_callback, s);
|
||||
}
|
||||
|
||||
static size_t ssh2_transport_queued_data_size(PacketProtocolLayer *ppl)
|
||||
|
@ -443,11 +443,11 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
s->cur_prompt->name = dupstr("SSH login name");
|
||||
add_prompt(s->cur_prompt, dupstr("login as: "), true);
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
while (s->userpass_ret < 0) {
|
||||
crReturnV;
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
}
|
||||
if (!s->userpass_ret) {
|
||||
/*
|
||||
@ -521,7 +521,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
(seat_verbose(s->ppl.seat) || seat_interactive(s->ppl.seat))) {
|
||||
if (s->banner_scc) {
|
||||
seat_antispoof_msg(
|
||||
s->ppl.seat,
|
||||
ppl_get_iseat(&s->ppl),
|
||||
"Pre-authentication banner message from server:");
|
||||
seat_set_trust_status(s->ppl.seat, false);
|
||||
}
|
||||
@ -529,7 +529,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_banner_pl(s->ppl.seat, data);
|
||||
seat_banner_pl(ppl_get_iseat(&s->ppl), data);
|
||||
mid_line =
|
||||
(((const char *)data.ptr)[data.len-1] != '\n');
|
||||
bufchain_consume(&s->banner, data.len);
|
||||
@ -537,11 +537,12 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
bufchain_clear(&s->banner);
|
||||
|
||||
if (mid_line)
|
||||
seat_banner_pl(s->ppl.seat, PTRLEN_LITERAL("\r\n"));
|
||||
seat_banner_pl(ppl_get_iseat(&s->ppl),
|
||||
PTRLEN_LITERAL("\r\n"));
|
||||
|
||||
if (s->banner_scc) {
|
||||
seat_set_trust_status(s->ppl.seat, true);
|
||||
seat_antispoof_msg(s->ppl.seat,
|
||||
seat_antispoof_msg(ppl_get_iseat(&s->ppl),
|
||||
"End of banner message from server");
|
||||
}
|
||||
}
|
||||
@ -912,11 +913,11 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
s->publickey_comment),
|
||||
false);
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
while (s->userpass_ret < 0) {
|
||||
crReturnV;
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
}
|
||||
if (!s->userpass_ret) {
|
||||
/* Failed to get a passphrase. Terminate. */
|
||||
@ -1343,8 +1344,8 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
if (!s->ki_printed_header && s->ki_scc &&
|
||||
(s->num_prompts || name.len || inst.len)) {
|
||||
seat_antispoof_msg(
|
||||
s->ppl.seat, "Keyboard-interactive authentication "
|
||||
"prompts from server:");
|
||||
ppl_get_iseat(&s->ppl), "Keyboard-interactive "
|
||||
"authentication prompts from server:");
|
||||
s->ki_printed_header = true;
|
||||
seat_set_trust_status(s->ppl.seat, false);
|
||||
}
|
||||
@ -1391,11 +1392,11 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
* user's response(s).
|
||||
*/
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
while (s->userpass_ret < 0) {
|
||||
crReturnV;
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
}
|
||||
if (!s->userpass_ret) {
|
||||
/*
|
||||
@ -1446,7 +1447,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
if (s->ki_printed_header) {
|
||||
seat_set_trust_status(s->ppl.seat, true);
|
||||
seat_antispoof_msg(
|
||||
s->ppl.seat,
|
||||
ppl_get_iseat(&s->ppl),
|
||||
"End of keyboard-interactive prompts from server");
|
||||
}
|
||||
|
||||
@ -1473,11 +1474,11 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
false);
|
||||
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
while (s->userpass_ret < 0) {
|
||||
crReturnV;
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
}
|
||||
if (!s->userpass_ret) {
|
||||
/*
|
||||
@ -1585,11 +1586,11 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
*/
|
||||
while (!got_new) {
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
while (s->userpass_ret < 0) {
|
||||
crReturnV;
|
||||
s->userpass_ret = seat_get_userpass_input(
|
||||
s->ppl.seat, s->cur_prompt);
|
||||
ppl_get_iseat(&s->ppl), s->cur_prompt);
|
||||
}
|
||||
if (!s->userpass_ret) {
|
||||
/*
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "putty.h"
|
||||
#include "misc.h"
|
||||
|
||||
void seat_antispoof_msg(Seat *seat, const char *msg)
|
||||
void seat_antispoof_msg(InteractionReadySeat iseat, const char *msg)
|
||||
{
|
||||
strbuf *sb = strbuf_new();
|
||||
seat_set_trust_status(seat, true);
|
||||
if (seat_can_set_trust_status(seat)) {
|
||||
seat_set_trust_status(iseat.seat, true);
|
||||
if (seat_can_set_trust_status(iseat.seat)) {
|
||||
/*
|
||||
* If the seat can directly indicate that this message is
|
||||
* generated by the client, then we can just use the message
|
||||
@ -23,6 +23,6 @@ void seat_antispoof_msg(Seat *seat, const char *msg)
|
||||
put_byte(sb, '-');
|
||||
}
|
||||
put_datapl(sb, PTRLEN_LITERAL("\r\n"));
|
||||
seat_banner_pl(seat, ptrlen_from_strbuf(sb));
|
||||
seat_banner_pl(iseat, ptrlen_from_strbuf(sb));
|
||||
strbuf_free(sb);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user