mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Remove FLAG_INTERACTIVE.
This is simpler than FLAG_VERBOSE: everywhere we need to check it, we have a Seat available, so we can just make it a Seat query method.
This commit is contained in:
parent
d20d3b20fd
commit
dc59fcf8e3
2
misc.c
2
misc.c
@ -366,6 +366,8 @@ bool nullseat_set_trust_status(Seat *seat, bool tr) { return false; }
|
|||||||
bool nullseat_set_trust_status_vacuously(Seat *seat, bool tr) { return true; }
|
bool nullseat_set_trust_status_vacuously(Seat *seat, bool tr) { return true; }
|
||||||
bool nullseat_verbose_no(Seat *seat) { return false; }
|
bool nullseat_verbose_no(Seat *seat) { return false; }
|
||||||
bool nullseat_verbose_yes(Seat *seat) { return true; }
|
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 null_lp_verbose_no(LogPolicy *lp) { return false; }
|
bool null_lp_verbose_no(LogPolicy *lp) { return false; }
|
||||||
bool null_lp_verbose_yes(LogPolicy *lp) { return true; }
|
bool null_lp_verbose_yes(LogPolicy *lp) { return true; }
|
||||||
|
1
pscp.c
1
pscp.c
@ -83,6 +83,7 @@ static const SeatVtable pscp_seat_vt = {
|
|||||||
console_stripctrl_new,
|
console_stripctrl_new,
|
||||||
nullseat_set_trust_status_vacuously,
|
nullseat_set_trust_status_vacuously,
|
||||||
cmdline_seat_verbose,
|
cmdline_seat_verbose,
|
||||||
|
nullseat_interactive_no,
|
||||||
};
|
};
|
||||||
static Seat pscp_seat[1] = {{ &pscp_seat_vt }};
|
static Seat pscp_seat[1] = {{ &pscp_seat_vt }};
|
||||||
|
|
||||||
|
3
psftp.c
3
psftp.c
@ -65,6 +65,7 @@ static const SeatVtable psftp_seat_vt = {
|
|||||||
console_stripctrl_new,
|
console_stripctrl_new,
|
||||||
nullseat_set_trust_status_vacuously,
|
nullseat_set_trust_status_vacuously,
|
||||||
cmdline_seat_verbose,
|
cmdline_seat_verbose,
|
||||||
|
nullseat_interactive_yes,
|
||||||
};
|
};
|
||||||
static Seat psftp_seat[1] = {{ &psftp_seat_vt }};
|
static Seat psftp_seat[1] = {{ &psftp_seat_vt }};
|
||||||
|
|
||||||
@ -2768,7 +2769,7 @@ int psftp_main(int argc, char *argv[])
|
|||||||
bool sanitise_stderr = true;
|
bool sanitise_stderr = true;
|
||||||
char *batchfile = NULL;
|
char *batchfile = NULL;
|
||||||
|
|
||||||
flags = FLAG_INTERACTIVE
|
flags = 0
|
||||||
#ifdef FLAG_SYNCAGENT
|
#ifdef FLAG_SYNCAGENT
|
||||||
| FLAG_SYNCAGENT
|
| FLAG_SYNCAGENT
|
||||||
#endif
|
#endif
|
||||||
|
15
putty.h
15
putty.h
@ -581,11 +581,6 @@ extern const char *const appname;
|
|||||||
/*
|
/*
|
||||||
* Some global flags denoting the type of application.
|
* Some global flags denoting the type of application.
|
||||||
*
|
*
|
||||||
* FLAG_INTERACTIVE is set when a full interactive shell session is
|
|
||||||
* being run, _either_ because no remote command has been provided
|
|
||||||
* _or_ because the application is GUI and can't run non-
|
|
||||||
* interactively.
|
|
||||||
*
|
|
||||||
* These flags describe the type of _application_ - they wouldn't
|
* These flags describe the type of _application_ - they wouldn't
|
||||||
* vary between individual sessions - and so it's OK to have this
|
* vary between individual sessions - and so it's OK to have this
|
||||||
* variable be GLOBAL.
|
* variable be GLOBAL.
|
||||||
@ -594,7 +589,6 @@ extern const char *const appname;
|
|||||||
* headers. It's probably best if those ones start from 0x1000, to
|
* headers. It's probably best if those ones start from 0x1000, to
|
||||||
* avoid collision.
|
* avoid collision.
|
||||||
*/
|
*/
|
||||||
#define FLAG_INTERACTIVE 0x0002
|
|
||||||
GLOBAL int flags;
|
GLOBAL int flags;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -956,6 +950,11 @@ struct SeatVtable {
|
|||||||
* Ask the seat whether it would like verbose messages.
|
* Ask the seat whether it would like verbose messages.
|
||||||
*/
|
*/
|
||||||
bool (*verbose)(Seat *seat);
|
bool (*verbose)(Seat *seat);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ask the seat whether it's an interactive program.
|
||||||
|
*/
|
||||||
|
bool (*interactive)(Seat *seat);
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline size_t seat_output(
|
static inline size_t seat_output(
|
||||||
@ -1003,6 +1002,8 @@ static inline bool seat_set_trust_status(Seat *seat, bool trusted)
|
|||||||
{ return seat->vt->set_trust_status(seat, trusted); }
|
{ return seat->vt->set_trust_status(seat, trusted); }
|
||||||
static inline bool seat_verbose(Seat *seat)
|
static inline bool seat_verbose(Seat *seat)
|
||||||
{ return seat->vt->verbose(seat); }
|
{ return seat->vt->verbose(seat); }
|
||||||
|
static inline bool seat_interactive(Seat *seat)
|
||||||
|
{ return seat->vt->interactive(seat); }
|
||||||
|
|
||||||
/* Unlike the seat's actual method, the public entry point
|
/* Unlike the seat's actual method, the public entry point
|
||||||
* seat_connection_fatal is a wrapper function with a printf-like API,
|
* seat_connection_fatal is a wrapper function with a printf-like API,
|
||||||
@ -1057,6 +1058,8 @@ bool nullseat_set_trust_status(Seat *seat, bool trusted);
|
|||||||
bool nullseat_set_trust_status_vacuously(Seat *seat, bool trusted);
|
bool nullseat_set_trust_status_vacuously(Seat *seat, bool trusted);
|
||||||
bool nullseat_verbose_no(Seat *seat);
|
bool nullseat_verbose_no(Seat *seat);
|
||||||
bool nullseat_verbose_yes(Seat *seat);
|
bool nullseat_verbose_yes(Seat *seat);
|
||||||
|
bool nullseat_interactive_no(Seat *seat);
|
||||||
|
bool nullseat_interactive_yes(Seat *seat);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Seat functions provided by the platform's console-application
|
* Seat functions provided by the platform's console-application
|
||||||
|
@ -198,6 +198,7 @@ static const SeatVtable sesschan_seat_vt = {
|
|||||||
nullseat_stripctrl_new,
|
nullseat_stripctrl_new,
|
||||||
nullseat_set_trust_status,
|
nullseat_set_trust_status,
|
||||||
nullseat_verbose_no,
|
nullseat_verbose_no,
|
||||||
|
nullseat_interactive_no,
|
||||||
};
|
};
|
||||||
|
|
||||||
Channel *sesschan_new(SshChannel *c, LogContext *logctx,
|
Channel *sesschan_new(SshChannel *c, LogContext *logctx,
|
||||||
|
2
ssh.c
2
ssh.c
@ -744,7 +744,7 @@ static const char *connect_to_host(
|
|||||||
ssh->fullhostname = NULL;
|
ssh->fullhostname = NULL;
|
||||||
*realhost = dupstr(host); /* best we can do */
|
*realhost = dupstr(host); /* best we can do */
|
||||||
|
|
||||||
if (seat_verbose(ssh->seat) || (flags & FLAG_INTERACTIVE)) {
|
if (seat_verbose(ssh->seat) || seat_interactive(ssh->seat)) {
|
||||||
/* In an interactive session, or in verbose mode, announce
|
/* In an interactive session, or in verbose mode, announce
|
||||||
* in the console window that we're a sharing downstream,
|
* in the console window that we're a sharing downstream,
|
||||||
* to avoid confusing users as to why this session doesn't
|
* to avoid confusing users as to why this session doesn't
|
||||||
|
@ -426,7 +426,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
|
|||||||
pq_push(s->ppl.out_pq, pkt);
|
pq_push(s->ppl.out_pq, pkt);
|
||||||
|
|
||||||
ppl_logevent("Sent username \"%s\"", s->username);
|
ppl_logevent("Sent username \"%s\"", s->username);
|
||||||
if (seat_verbose(s->ppl.seat) || (flags & FLAG_INTERACTIVE))
|
if (seat_verbose(s->ppl.seat) || seat_interactive(s->ppl.seat))
|
||||||
ppl_printf("Sent username \"%s\"\r\n", s->username);
|
ppl_printf("Sent username \"%s\"\r\n", s->username);
|
||||||
|
|
||||||
crMaybeWaitUntilV((pktin = ssh1_login_pop(s)) != NULL);
|
crMaybeWaitUntilV((pktin = ssh1_login_pop(s)) != NULL);
|
||||||
@ -799,7 +799,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
|
|||||||
crMaybeWaitUntilV((pktin = ssh1_login_pop(s)) != NULL);
|
crMaybeWaitUntilV((pktin = ssh1_login_pop(s)) != NULL);
|
||||||
if (pktin->type == SSH1_SMSG_FAILURE) {
|
if (pktin->type == SSH1_SMSG_FAILURE) {
|
||||||
ppl_logevent("TIS authentication declined");
|
ppl_logevent("TIS authentication declined");
|
||||||
if (flags & FLAG_INTERACTIVE)
|
if (seat_interactive(s->ppl.seat))
|
||||||
ppl_printf("TIS authentication refused.\r\n");
|
ppl_printf("TIS authentication refused.\r\n");
|
||||||
s->tis_auth_refused = true;
|
s->tis_auth_refused = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -433,7 +433,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
|||||||
prompt_get_result(s->cur_prompt->prompts[0]);
|
prompt_get_result(s->cur_prompt->prompts[0]);
|
||||||
free_prompts(s->cur_prompt);
|
free_prompts(s->cur_prompt);
|
||||||
} else {
|
} else {
|
||||||
if (seat_verbose(s->ppl.seat) || (flags & FLAG_INTERACTIVE))
|
if (seat_verbose(s->ppl.seat) || seat_interactive(s->ppl.seat))
|
||||||
ppl_printf("Using username \"%s\".\r\n", s->username);
|
ppl_printf("Using username \"%s\".\r\n", s->username);
|
||||||
}
|
}
|
||||||
s->got_username = true;
|
s->got_username = true;
|
||||||
@ -496,7 +496,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
|||||||
* anti-spoofing header lines.
|
* anti-spoofing header lines.
|
||||||
*/
|
*/
|
||||||
if (bufchain_size(&s->banner) &&
|
if (bufchain_size(&s->banner) &&
|
||||||
(seat_verbose(s->ppl.seat) || (flags & FLAG_INTERACTIVE))) {
|
(seat_verbose(s->ppl.seat) || seat_interactive(s->ppl.seat))) {
|
||||||
if (s->banner_scc) {
|
if (s->banner_scc) {
|
||||||
ssh2_userauth_antispoof_msg(
|
ssh2_userauth_antispoof_msg(
|
||||||
s, "Pre-authentication banner message from server:");
|
s, "Pre-authentication banner message from server:");
|
||||||
|
@ -121,6 +121,7 @@ static const SeatVtable server_seat_vt = {
|
|||||||
nullseat_stripctrl_new,
|
nullseat_stripctrl_new,
|
||||||
nullseat_set_trust_status,
|
nullseat_set_trust_status,
|
||||||
nullseat_verbose_no,
|
nullseat_verbose_no,
|
||||||
|
nullseat_interactive_no,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void server_socket_log(Plug *plug, int type, SockAddr *addr, int port,
|
static void server_socket_log(Plug *plug, int type, SockAddr *addr, int port,
|
||||||
|
@ -400,6 +400,7 @@ static const SeatVtable gtk_seat_vt = {
|
|||||||
gtk_seat_stripctrl_new,
|
gtk_seat_stripctrl_new,
|
||||||
gtk_seat_set_trust_status,
|
gtk_seat_set_trust_status,
|
||||||
nullseat_verbose_yes,
|
nullseat_verbose_yes,
|
||||||
|
nullseat_interactive_yes,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gtk_eventlog(LogPolicy *lp, const char *string)
|
static void gtk_eventlog(LogPolicy *lp, const char *string)
|
||||||
|
@ -380,6 +380,13 @@ static int plink_get_userpass_input(Seat *seat, prompts_t *p, bufchain *input)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool plink_seat_interactive(Seat *seat)
|
||||||
|
{
|
||||||
|
return (!*conf_get_str(conf, CONF_remote_cmd) &&
|
||||||
|
!*conf_get_str(conf, CONF_remote_cmd2) &&
|
||||||
|
!*conf_get_str(conf, CONF_ssh_nc_host));
|
||||||
|
}
|
||||||
|
|
||||||
static const SeatVtable plink_seat_vt = {
|
static const SeatVtable plink_seat_vt = {
|
||||||
plink_output,
|
plink_output,
|
||||||
plink_eof,
|
plink_eof,
|
||||||
@ -400,6 +407,7 @@ static const SeatVtable plink_seat_vt = {
|
|||||||
console_stripctrl_new,
|
console_stripctrl_new,
|
||||||
console_set_trust_status,
|
console_set_trust_status,
|
||||||
cmdline_seat_verbose,
|
cmdline_seat_verbose,
|
||||||
|
plink_seat_interactive,
|
||||||
};
|
};
|
||||||
static Seat plink_seat[1] = {{ &plink_seat_vt }};
|
static Seat plink_seat[1] = {{ &plink_seat_vt }};
|
||||||
|
|
||||||
@ -739,11 +747,6 @@ int main(int argc, char **argv)
|
|||||||
if (use_subsystem)
|
if (use_subsystem)
|
||||||
conf_set_bool(conf, CONF_ssh_subsys, true);
|
conf_set_bool(conf, CONF_ssh_subsys, true);
|
||||||
|
|
||||||
if (!*conf_get_str(conf, CONF_remote_cmd) &&
|
|
||||||
!*conf_get_str(conf, CONF_remote_cmd2) &&
|
|
||||||
!*conf_get_str(conf, CONF_ssh_nc_host))
|
|
||||||
flags |= FLAG_INTERACTIVE;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select protocol. This is farmed out into a table in a
|
* Select protocol. This is farmed out into a table in a
|
||||||
* separate file to enable an ssh-free variant.
|
* separate file to enable an ssh-free variant.
|
||||||
|
@ -80,7 +80,6 @@ const bool share_can_be_upstream = true;
|
|||||||
void setup(bool single)
|
void setup(bool single)
|
||||||
{
|
{
|
||||||
sk_init();
|
sk_init();
|
||||||
flags = FLAG_INTERACTIVE;
|
|
||||||
cmdline_tooltype |= TOOLTYPE_HOST_ARG | TOOLTYPE_PORT_ARG |
|
cmdline_tooltype |= TOOLTYPE_HOST_ARG | TOOLTYPE_PORT_ARG |
|
||||||
TOOLTYPE_NO_VERBOSE_OPTION;
|
TOOLTYPE_NO_VERBOSE_OPTION;
|
||||||
default_protocol = be_default_protocol;
|
default_protocol = be_default_protocol;
|
||||||
|
@ -361,6 +361,7 @@ static const SeatVtable win_seat_vt = {
|
|||||||
win_seat_stripctrl_new,
|
win_seat_stripctrl_new,
|
||||||
win_seat_set_trust_status,
|
win_seat_set_trust_status,
|
||||||
nullseat_verbose_yes,
|
nullseat_verbose_yes,
|
||||||
|
nullseat_interactive_yes,
|
||||||
};
|
};
|
||||||
static Seat win_seat_impl = { &win_seat_vt };
|
static Seat win_seat_impl = { &win_seat_vt };
|
||||||
Seat *const win_seat = &win_seat_impl;
|
Seat *const win_seat = &win_seat_impl;
|
||||||
@ -484,7 +485,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
|
|
||||||
hinst = inst;
|
hinst = inst;
|
||||||
hwnd = NULL;
|
hwnd = NULL;
|
||||||
flags = FLAG_INTERACTIVE;
|
|
||||||
cmdline_tooltype |= TOOLTYPE_HOST_ARG | TOOLTYPE_PORT_ARG |
|
cmdline_tooltype |= TOOLTYPE_HOST_ARG | TOOLTYPE_PORT_ARG |
|
||||||
TOOLTYPE_NO_VERBOSE_OPTION;
|
TOOLTYPE_NO_VERBOSE_OPTION;
|
||||||
|
|
||||||
|
@ -82,6 +82,13 @@ static int plink_get_userpass_input(Seat *seat, prompts_t *p, bufchain *input)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool plink_seat_interactive(Seat *seat)
|
||||||
|
{
|
||||||
|
return (!*conf_get_str(conf, CONF_remote_cmd) &&
|
||||||
|
!*conf_get_str(conf, CONF_remote_cmd2) &&
|
||||||
|
!*conf_get_str(conf, CONF_ssh_nc_host));
|
||||||
|
}
|
||||||
|
|
||||||
static const SeatVtable plink_seat_vt = {
|
static const SeatVtable plink_seat_vt = {
|
||||||
plink_output,
|
plink_output,
|
||||||
plink_eof,
|
plink_eof,
|
||||||
@ -102,6 +109,7 @@ static const SeatVtable plink_seat_vt = {
|
|||||||
console_stripctrl_new,
|
console_stripctrl_new,
|
||||||
console_set_trust_status,
|
console_set_trust_status,
|
||||||
cmdline_seat_verbose,
|
cmdline_seat_verbose,
|
||||||
|
plink_seat_interactive,
|
||||||
};
|
};
|
||||||
static Seat plink_seat[1] = {{ &plink_seat_vt }};
|
static Seat plink_seat[1] = {{ &plink_seat_vt }};
|
||||||
|
|
||||||
@ -375,11 +383,6 @@ int main(int argc, char **argv)
|
|||||||
if (use_subsystem)
|
if (use_subsystem)
|
||||||
conf_set_bool(conf, CONF_ssh_subsys, true);
|
conf_set_bool(conf, CONF_ssh_subsys, true);
|
||||||
|
|
||||||
if (!*conf_get_str(conf, CONF_remote_cmd) &&
|
|
||||||
!*conf_get_str(conf, CONF_remote_cmd2) &&
|
|
||||||
!*conf_get_str(conf, CONF_ssh_nc_host))
|
|
||||||
flags |= FLAG_INTERACTIVE;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select protocol. This is farmed out into a table in a
|
* Select protocol. This is farmed out into a table in a
|
||||||
* separate file to enable an ssh-free variant.
|
* separate file to enable an ssh-free variant.
|
||||||
|
Loading…
Reference in New Issue
Block a user