1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-08 08:58:00 +00:00

Remove FLAG_VERBOSE.

The global 'int flags' has always been an ugly feature of this code
base, and I suddenly thought that perhaps it's time to start throwing
it out, one flag at a time, until it's totally unused.

My first target is FLAG_VERBOSE. This was usually set by cmdline.c
when it saw a -v option on the program's command line, except that GUI
PuTTY itself sets it unconditionally on startup. And then various bits
of the code would check it in order to decide whether to print a given
message.

In the current system of front-end abstraction traits, there's no
_one_ place that I can move it to. But there are two: every place that
checked FLAG_VERBOSE has access to either a Seat or a LogPolicy. So
now each of those traits has a query method for 'do I want verbose
messages?'.

A good effect of this is that subsidiary Seats, like the ones used in
Uppity for the main SSH server module itself and the server end of
shell channels, now get to have their own verbosity setting instead of
inheriting the one global one. In fact I don't expect any code using
those Seats to be generating any messages at all, but if that changes
later, we'll have a way to control it. (Who knows, perhaps logging in
Uppity might become a thing.)

As part of this cleanup, I've added a new flag to cmdline_tooltype,
called TOOLTYPE_NO_VERBOSE_OPTION. The unconditionally-verbose tools
now set that, and it has the effect of making cmdline.c disallow -v
completely. So where 'putty -v' would previously have been silently
ignored ("I was already verbose"), it's now an error, reminding you
that that option doesn't actually do anything.

Finally, the 'default_logpolicy' provided by uxcons.c and wincons.c
(with identical definitions) has had to move into a new file of its
own, because now it has to ask cmdline.c for the verbosity setting as
well as asking console.c for the rest of its methods. So there's a new
file clicons.c which can only be included by programs that link
against both cmdline.c _and_ one of the *cons.c, and I've renamed the
logpolicy to reflect that.
This commit is contained in:
Simon Tatham 2020-01-30 06:40:21 +00:00
parent 06e9f71153
commit d20d3b20fd
24 changed files with 118 additions and 66 deletions

11
Recipe
View File

@ -334,11 +334,12 @@ KEYGEN = sshrsag sshdssg sshecdsag
putty : [G] GUITERM NONSSH WINSSH W_BE_ALL WINMISC winx11 putty.res LIBS
puttytel : [G] GUITERM NONSSH W_BE_NOSSH WINMISC puttytel.res nogss LIBS
plink : [C] winplink wincons NONSSH WINSSH W_BE_ALL logging WINMISC
+ winx11 plink.res winnojmp sessprep noterm winnohlp winselcli LIBS
+ winx11 plink.res winnojmp sessprep noterm winnohlp winselcli
+ clicons LIBS
pscp : [C] pscp winsftp wincons WINSSH BE_SSH SFTP wildcard WINMISC
+ pscp.res winnojmp winnohlp winselcli LIBS
+ pscp.res winnojmp winnohlp winselcli clicons LIBS
psftp : [C] psftp winsftp wincons WINSSH BE_SSH SFTP wildcard WINMISC
+ psftp.res winnojmp winnohlp winselcli LIBS
+ psftp.res winnojmp winnohlp winselcli clicons LIBS
pageant : [G] winpgnt pageant sshrsa sshpubk sshdes ARITH sshmd5 version
+ tree234 MISC sshaes sshsha winsecur winpgntc aqsync sshdss sshsh256
@ -363,7 +364,7 @@ puttytel : [X] GTKTERM uxmisc misc ldisc settings uxsel U_BE_NOSSH
+ nogss utils memory GTKMAIN
plink : [U] uxplink uxcons NONSSH UXSSH U_BE_ALL logging UXMISC uxsignal
+ ux_x11 noterm uxnogtk sessprep cmdline
+ ux_x11 noterm uxnogtk sessprep cmdline clicons
PUTTYGEN_UNIX = KEYGEN sshprime sshdes ARITH sshmd5 version sshprng
+ sshrand uxnoise sshsha MISC sshrsa sshdss uxcons uxstore uxmisc
@ -374,7 +375,9 @@ puttygen : [U] cmdgen PUTTYGEN_UNIX
cgtest : [UT] cgtest PUTTYGEN_UNIX
pscp : [U] pscp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC uxnogtk
+ clicons
psftp : [U] psftp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC uxnogtk
+ clicons
pageant : [X] uxpgnt uxagentc aqsync pageant sshrsa sshpubk sshdes ARITH
+ sshmd5 version tree234 misc sshaes sshsha sshdss sshsh256 sshsh512

14
clicons.c Normal file
View File

@ -0,0 +1,14 @@
/*
* clicons.c: definitions limited to tools that link against both
* console.c and cmdline.c.
*/
#include "putty.h"
static const LogPolicyVtable console_cli_logpolicy_vt = {
console_eventlog,
console_askappend,
console_logging_error,
cmdline_lp_verbose,
};
LogPolicy console_cli_logpolicy[1] = {{ &console_cli_logpolicy_vt }};

View File

@ -157,6 +157,10 @@ static bool cmdline_check_unavailable(int flag, const char *p)
static bool seen_hostname_argument = false;
static bool seen_port_argument = false;
static bool seen_verbose_option = false;
bool cmdline_verbose(void) { return seen_verbose_option; }
bool cmdline_seat_verbose(Seat *seat) { return cmdline_verbose(); }
bool cmdline_lp_verbose(LogPolicy *lp) { return cmdline_verbose(); }
int cmdline_process_param(const char *p, char *value,
int need_save, Conf *conf)
@ -452,7 +456,8 @@ int cmdline_process_param(const char *p, char *value,
}
if (!strcmp(p, "-v")) {
RETURN(1);
flags |= FLAG_VERBOSE;
UNAVAILABLE_IN(TOOLTYPE_NO_VERBOSE_OPTION);
seen_verbose_option = true;
}
if (!strcmp(p, "-l")) {
RETURN(2);

5
misc.c
View File

@ -364,6 +364,11 @@ StripCtrlChars *nullseat_stripctrl_new(
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic) {return NULL;}
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_verbose_no(Seat *seat) { return false; }
bool nullseat_verbose_yes(Seat *seat) { return true; }
bool null_lp_verbose_no(LogPolicy *lp) { return false; }
bool null_lp_verbose_yes(LogPolicy *lp) { return true; }
void sk_free_peer_info(SocketPeerInfo *pi)
{

7
pscp.c
View File

@ -82,6 +82,7 @@ static const SeatVtable pscp_seat_vt = {
nullseat_get_window_pixel_size,
console_stripctrl_new,
nullseat_set_trust_status_vacuously,
cmdline_seat_verbose,
};
static Seat pscp_seat[1] = {{ &pscp_seat_vt }};
@ -450,9 +451,9 @@ static void do_cmd(char *host, char *user, char *cmd)
}
conf_set_bool(conf, CONF_nopty, true);
logctx = log_init(default_logpolicy, conf);
logctx = log_init(console_cli_logpolicy, conf);
platform_psftp_pre_conn_setup();
platform_psftp_pre_conn_setup(console_cli_logpolicy);
err = backend_init(&ssh_backend, pscp_seat, &backend, logctx, conf,
conf_get_str(conf, CONF_host),
@ -2257,7 +2258,7 @@ int psftp_main(int argc, char *argv[])
i++; /* skip next argument */
} else if (ret == 1) {
/* We have our own verbosity in addition to `flags'. */
if (flags & FLAG_VERBOSE)
if (cmdline_verbose())
verbose = true;
} else if (strcmp(argv[i], "-pgpfp") == 0) {
pgp_fingerprints();

View File

@ -64,6 +64,7 @@ static const SeatVtable psftp_seat_vt = {
nullseat_get_window_pixel_size,
console_stripctrl_new,
nullseat_set_trust_status_vacuously,
cmdline_seat_verbose,
};
static Seat psftp_seat[1] = {{ &psftp_seat_vt }};
@ -2709,9 +2710,9 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
"exec sftp-server");
conf_set_bool(conf, CONF_ssh_subsys2, false);
psftp_logctx = log_init(default_logpolicy, conf);
psftp_logctx = log_init(console_cli_logpolicy, conf);
platform_psftp_pre_conn_setup();
platform_psftp_pre_conn_setup(console_cli_logpolicy);
err = backend_init(&ssh_backend, psftp_seat, &backend, psftp_logctx, conf,
conf_get_str(conf, CONF_host),
@ -2798,7 +2799,7 @@ int psftp_main(int argc, char *argv[])
i++; /* skip next argument */
} else if (ret == 1) {
/* We have our own verbosity in addition to `flags'. */
if (flags & FLAG_VERBOSE)
if (cmdline_verbose())
verbose = true;
} else if (strcmp(argv[i], "-h") == 0 ||
strcmp(argv[i], "-?") == 0 ||

View File

@ -49,7 +49,7 @@ char *ssh_sftp_get_cmdline(const char *prompt, bool backend_required);
* Platform-specific function called when we're about to make a
* network connection.
*/
void platform_psftp_pre_conn_setup(void);
void platform_psftp_pre_conn_setup(LogPolicy *lp);
/*
* The main program in psftp.c. Called from main() in the platform-

37
putty.h
View File

@ -581,8 +581,6 @@ extern const char *const appname;
/*
* Some global flags denoting the type of application.
*
* FLAG_VERBOSE is set when the user requests verbose details.
*
* 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-
@ -596,7 +594,6 @@ extern const char *const appname;
* headers. It's probably best if those ones start from 0x1000, to
* avoid collision.
*/
#define FLAG_VERBOSE 0x0001
#define FLAG_INTERACTIVE 0x0002
GLOBAL int flags;
@ -954,6 +951,11 @@ struct SeatVtable {
* prompts by malicious servers.
*/
bool (*set_trust_status)(Seat *seat, bool trusted);
/*
* Ask the seat whether it would like verbose messages.
*/
bool (*verbose)(Seat *seat);
};
static inline size_t seat_output(
@ -999,6 +1001,8 @@ static inline StripCtrlChars *seat_stripctrl_new(
{ return seat->vt->stripctrl_new(seat, bs, sic); }
static inline bool seat_set_trust_status(Seat *seat, bool trusted)
{ return seat->vt->set_trust_status(seat, trusted); }
static inline bool seat_verbose(Seat *seat)
{ return seat->vt->verbose(seat); }
/* Unlike the seat's actual method, the public entry point
* seat_connection_fatal is a wrapper function with a printf-like API,
@ -1051,6 +1055,8 @@ StripCtrlChars *nullseat_stripctrl_new(
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic);
bool nullseat_set_trust_status(Seat *seat, bool trusted);
bool nullseat_set_trust_status_vacuously(Seat *seat, bool trusted);
bool nullseat_verbose_no(Seat *seat);
bool nullseat_verbose_yes(Seat *seat);
/*
* Seat functions provided by the platform's console-application
@ -1076,6 +1082,7 @@ bool console_set_trust_status(Seat *seat, bool trusted);
* Other centralised seat functions.
*/
int filexfer_get_userpass_input(Seat *seat, prompts_t *p, bufchain *input);
bool cmdline_seat_verbose(Seat *seat);
/*
* Data type 'TermWin', which is a vtable encapsulating all the
@ -1681,6 +1688,11 @@ struct LogPolicyVtable {
* file :-)
*/
void (*logging_error)(LogPolicy *lp, const char *event);
/*
* Ask whether extra verbose log messages are required.
*/
bool (*verbose)(LogPolicy *lp);
};
struct LogPolicy {
const LogPolicyVtable *vt;
@ -1694,6 +1706,19 @@ static inline int lp_askappend(
{ return lp->vt->askappend(lp, filename, callback, ctx); }
static inline void lp_logging_error(LogPolicy *lp, const char *event)
{ lp->vt->logging_error(lp, event); }
static inline bool lp_verbose(LogPolicy *lp)
{ return lp->vt->verbose(lp); }
/* Defined in conscli.c, used in several console command-line tools */
extern LogPolicy console_cli_logpolicy[];
int console_askappend(LogPolicy *lp, Filename *filename,
void (*callback)(void *ctx, int result), void *ctx);
void console_logging_error(LogPolicy *lp, const char *string);
void console_eventlog(LogPolicy *lp, const char *string);
bool null_lp_verbose_yes(LogPolicy *lp);
bool null_lp_verbose_no(LogPolicy *lp);
bool cmdline_lp_verbose(LogPolicy *lp);
LogContext *log_init(LogPolicy *lp, Conf *conf);
void log_free(LogContext *logctx);
@ -1725,10 +1750,6 @@ void log_packet(LogContext *logctx, int direction, int type,
const unsigned long *sequence,
unsigned downstream_id, const char *additional_log_text);
/* This is defined by applications that have an obvious logging
* destination like standard error or the GUI. */
extern LogPolicy default_logpolicy[1];
/*
* Exports from testback.c
*/
@ -1950,6 +1971,7 @@ void cmdline_run_saved(Conf *);
void cmdline_cleanup(void);
int cmdline_get_passwd_input(prompts_t *p);
bool cmdline_host_ok(Conf *);
bool cmdline_verbose(void);
#define TOOLTYPE_FILETRANSFER 1
#define TOOLTYPE_NONNETWORK 2
#define TOOLTYPE_HOST_ARG 4
@ -1957,6 +1979,7 @@ bool cmdline_host_ok(Conf *);
#define TOOLTYPE_HOST_ARG_PROTOCOL_PREFIX 16
#define TOOLTYPE_HOST_ARG_FROM_LAUNCHABLE_LOAD 32
#define TOOLTYPE_PORT_ARG 64
#define TOOLTYPE_NO_VERBOSE_OPTION 128
extern int cmdline_tooltype;
void cmdline_error(const char *, ...) PRINTF_LIKE(1, 2);

View File

@ -168,6 +168,7 @@ static const LogPolicyVtable sesschan_logpolicy_vt = {
sesschan_eventlog,
sesschan_askappend,
sesschan_logging_error,
null_lp_verbose_no,
};
static size_t sesschan_seat_output(
@ -196,6 +197,7 @@ static const SeatVtable sesschan_seat_vt = {
sesschan_get_window_pixel_size,
nullseat_stripctrl_new,
nullseat_set_trust_status,
nullseat_verbose_no,
};
Channel *sesschan_new(SshChannel *c, LogContext *logctx,

2
ssh.c
View File

@ -744,7 +744,7 @@ static const char *connect_to_host(
ssh->fullhostname = NULL;
*realhost = dupstr(host); /* best we can do */
if ((flags & FLAG_VERBOSE) || (flags & FLAG_INTERACTIVE)) {
if (seat_verbose(ssh->seat) || (flags & FLAG_INTERACTIVE)) {
/* In an interactive session, or in verbose mode, announce
* in the console window that we're a sharing downstream,
* to avoid confusing users as to why this session doesn't

View File

@ -426,7 +426,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
pq_push(s->ppl.out_pq, pkt);
ppl_logevent("Sent username \"%s\"", s->username);
if ((flags & FLAG_VERBOSE) || (flags & FLAG_INTERACTIVE))
if (seat_verbose(s->ppl.seat) || (flags & FLAG_INTERACTIVE))
ppl_printf("Sent username \"%s\"\r\n", s->username);
crMaybeWaitUntilV((pktin = ssh1_login_pop(s)) != NULL);
@ -586,7 +586,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
if (pktin->type == SSH1_SMSG_SUCCESS) {
ppl_logevent("Pageant's response "
"accepted");
if (flags & FLAG_VERBOSE) {
if (seat_verbose(s->ppl.seat)) {
ptrlen comment = ptrlen_from_strbuf(
s->agent_comment);
ppl_printf("Authenticated using RSA "
@ -630,7 +630,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
* key file.
*/
bool got_passphrase; /* need not be kept over crReturn */
if (flags & FLAG_VERBOSE)
if (seat_verbose(s->ppl.seat))
ppl_printf("Trying public key authentication.\r\n");
ppl_logevent("Trying public key \"%s\"",
filename_to_str(s->keyfile));
@ -644,7 +644,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
char *passphrase = NULL; /* only written after crReturn */
const char *error;
if (!s->privatekey_encrypted) {
if (flags & FLAG_VERBOSE)
if (seat_verbose(s->ppl.seat))
ppl_printf("No passphrase required.\r\n");
passphrase = NULL;
} else {
@ -766,7 +766,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
crMaybeWaitUntilV((pktin = ssh1_login_pop(s))
!= NULL);
if (pktin->type == SSH1_SMSG_FAILURE) {
if (flags & FLAG_VERBOSE)
if (seat_verbose(s->ppl.seat))
ppl_printf("Failed to authenticate with"
" our public key.\r\n");
continue; /* go and try something else */
@ -1054,7 +1054,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
s->cur_prompt = NULL;
crMaybeWaitUntilV((pktin = ssh1_login_pop(s)) != NULL);
if (pktin->type == SSH1_SMSG_FAILURE) {
if (flags & FLAG_VERBOSE)
if (seat_verbose(s->ppl.seat))
ppl_printf("Access denied\r\n");
ppl_logevent("Authentication refused");
} else if (pktin->type != SSH1_SMSG_SUCCESS) {

View File

@ -433,7 +433,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
prompt_get_result(s->cur_prompt->prompts[0]);
free_prompts(s->cur_prompt);
} else {
if ((flags & FLAG_VERBOSE) || (flags & FLAG_INTERACTIVE))
if (seat_verbose(s->ppl.seat) || (flags & FLAG_INTERACTIVE))
ppl_printf("Using username \"%s\".\r\n", s->username);
}
s->got_username = true;
@ -496,7 +496,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
* anti-spoofing header lines.
*/
if (bufchain_size(&s->banner) &&
(flags & (FLAG_VERBOSE | FLAG_INTERACTIVE))) {
(seat_verbose(s->ppl.seat) || (flags & FLAG_INTERACTIVE))) {
if (s->banner_scc) {
ssh2_userauth_antispoof_msg(
s, "Pre-authentication banner message from server:");
@ -727,7 +727,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
} else {
strbuf *agentreq, *sigdata;
if (flags & FLAG_VERBOSE)
if (seat_verbose(s->ppl.seat))
ppl_printf("Authenticating with public key "
"\"%.*s\" from agent\r\n",
PTRLEN_PRINTF(s->comment));
@ -836,7 +836,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
* Actually attempt a serious authentication using
* the key.
*/
if (flags & FLAG_VERBOSE)
if (seat_verbose(s->ppl.seat))
ppl_printf("Authenticating with public key \"%s\"\r\n",
s->publickey_comment);

View File

@ -120,6 +120,7 @@ static const SeatVtable server_seat_vt = {
nullseat_get_window_pixel_size,
nullseat_stripctrl_new,
nullseat_set_trust_status,
nullseat_verbose_no,
};
static void server_socket_log(Plug *plug, int type, SockAddr *addr, int port,

View File

@ -399,6 +399,7 @@ static const SeatVtable gtk_seat_vt = {
gtk_seat_get_window_pixel_size,
gtk_seat_stripctrl_new,
gtk_seat_set_trust_status,
nullseat_verbose_yes,
};
static void gtk_eventlog(LogPolicy *lp, const char *string)
@ -428,6 +429,7 @@ static const LogPolicyVtable gtk_logpolicy_vt = {
gtk_eventlog,
gtk_askappend,
gtk_logging_error,
null_lp_verbose_yes,
};
/*

View File

@ -366,9 +366,8 @@ int console_confirm_weak_cached_hostkey(
* Ask whether to wipe a session log file before writing to it.
* Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
*/
static int console_askappend(LogPolicy *lp, Filename *filename,
void (*callback)(void *ctx, int result),
void *ctx)
int console_askappend(LogPolicy *lp, Filename *filename,
void (*callback)(void *ctx, int result), void *ctx)
{
static const char msgtemplate[] =
"The session log file \"%.*s\" already exists.\n"
@ -468,7 +467,7 @@ void old_keyfile_warning(void)
postmsg(&cf);
}
static void console_logging_error(LogPolicy *lp, const char *string)
void console_logging_error(LogPolicy *lp, const char *string)
{
/* Errors setting up logging are considered important, so they're
* displayed to standard error even when not in verbose mode */
@ -480,11 +479,11 @@ static void console_logging_error(LogPolicy *lp, const char *string)
}
static void console_eventlog(LogPolicy *lp, const char *string)
void console_eventlog(LogPolicy *lp, const char *string)
{
/* Ordinary Event Log entries are displayed in the same way as
* logging errors, but only in verbose mode */
if (flags & FLAG_VERBOSE)
if (lp_verbose(lp))
console_logging_error(lp, string);
}
@ -624,10 +623,3 @@ bool is_interactive(void)
char *platform_get_x_display(void) {
return dupstr(getenv("DISPLAY"));
}
static const LogPolicyVtable default_logpolicy_vt = {
console_eventlog,
console_askappend,
console_logging_error,
};
LogPolicy default_logpolicy[1] = {{ &default_logpolicy_vt }};

View File

@ -399,6 +399,7 @@ static const SeatVtable plink_seat_vt = {
nullseat_get_window_pixel_size,
console_stripctrl_new,
console_set_trust_status,
cmdline_seat_verbose,
};
static Seat plink_seat[1] = {{ &plink_seat_vt }};
@ -840,7 +841,7 @@ int main(int argc, char **argv)
/*
* Start up the connection.
*/
logctx = log_init(default_logpolicy, conf);
logctx = log_init(console_cli_logpolicy, conf);
{
const char *error;
char *realhost;

View File

@ -80,8 +80,9 @@ const bool share_can_be_upstream = true;
void setup(bool single)
{
sk_init();
flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
cmdline_tooltype |= TOOLTYPE_HOST_ARG | TOOLTYPE_PORT_ARG;
flags = FLAG_INTERACTIVE;
cmdline_tooltype |= TOOLTYPE_HOST_ARG | TOOLTYPE_PORT_ARG |
TOOLTYPE_NO_VERBOSE_OPTION;
default_protocol = be_default_protocol;
/* Find the appropriate default port. */
{

View File

@ -163,6 +163,7 @@ static const LogPolicyVtable server_logpolicy_vt = {
server_eventlog,
server_askappend,
server_logging_error,
null_lp_verbose_no,
};
struct AuthPolicy_ssh1_pubkey {

View File

@ -631,7 +631,7 @@ char *ssh_sftp_get_cmdline(const char *prompt, bool no_fds_ok)
void frontend_net_error_pending(void) {}
void platform_psftp_pre_conn_setup(void) {}
void platform_psftp_pre_conn_setup(LogPolicy *lp) {}
const bool buildinfo_gtk_relevant = false;

View File

@ -412,7 +412,7 @@ static void console_eventlog(LogPolicy *lp, const char *string)
{
/* Ordinary Event Log entries are displayed in the same way as
* logging errors, but only in verbose mode */
if (flags & FLAG_VERBOSE)
if (lp_verbose(lp))
console_logging_error(lp, string);
}
@ -549,10 +549,3 @@ int console_get_userpass_input(prompts_t *p)
return 1; /* success */
}
static const LogPolicyVtable default_logpolicy_vt = {
console_eventlog,
console_askappend,
console_logging_error,
};
LogPolicy default_logpolicy[1] = {{ &default_logpolicy_vt }};

View File

@ -995,12 +995,13 @@ static int win_gui_askappend(LogPolicy *lp, Filename *filename,
return 0;
}
static const LogPolicyVtable default_logpolicy_vt = {
static const LogPolicyVtable win_gui_logpolicy_vt = {
win_gui_eventlog,
win_gui_askappend,
win_gui_logging_error,
null_lp_verbose_yes,
};
LogPolicy default_logpolicy[1] = {{ &default_logpolicy_vt }};
LogPolicy win_gui_logpolicy[1] = {{ &win_gui_logpolicy_vt }};
/*
* Warn about the obsolescent key file format.

View File

@ -360,6 +360,7 @@ static const SeatVtable win_seat_vt = {
win_seat_get_window_pixel_size,
win_seat_stripctrl_new,
win_seat_set_trust_status,
nullseat_verbose_yes,
};
static Seat win_seat_impl = { &win_seat_vt };
Seat *const win_seat = &win_seat_impl;
@ -471,6 +472,8 @@ static void close_session(void *ignored_context)
}
}
extern LogPolicy win_gui_logpolicy[1]; /* defined in windlg.c */
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{
MSG msg;
@ -481,8 +484,9 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
hinst = inst;
hwnd = NULL;
flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
cmdline_tooltype |= TOOLTYPE_HOST_ARG | TOOLTYPE_PORT_ARG;
flags = FLAG_INTERACTIVE;
cmdline_tooltype |= TOOLTYPE_HOST_ARG | TOOLTYPE_PORT_ARG |
TOOLTYPE_NO_VERBOSE_OPTION;
sk_init();
@ -760,7 +764,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
wintw->vt = &windows_termwin_vt;
term = term_init(conf, &ucsdata, wintw);
setup_clipboards(term, conf);
logctx = log_init(default_logpolicy, conf);
logctx = log_init(win_gui_logpolicy, conf);
term_provide_logctx(term, logctx);
term_size(term, conf_get_int(conf, CONF_height),
conf_get_int(conf, CONF_width),
@ -868,7 +872,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
}
if (restricted_acl) {
lp_eventlog(default_logpolicy, "Running with restricted process ACL");
lp_eventlog(win_gui_logpolicy, "Running with restricted process ACL");
}
winselgui_set_hwnd(hwnd);
@ -2299,7 +2303,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
break;
case IDM_RESTART:
if (!backend) {
lp_eventlog(default_logpolicy,
lp_eventlog(win_gui_logpolicy,
"----- Session restarted -----");
term_pwron(term, false);
start_backend();

View File

@ -101,6 +101,7 @@ static const SeatVtable plink_seat_vt = {
nullseat_get_window_pixel_size,
console_stripctrl_new,
console_set_trust_status,
cmdline_seat_verbose,
};
static Seat plink_seat[1] = {{ &plink_seat_vt }};
@ -407,7 +408,7 @@ int main(int argc, char **argv)
!conf_get_str_nthstrkey(conf, CONF_portfwd, 0))
conf_set_bool(conf, CONF_ssh_simple, true);
logctx = log_init(default_logpolicy, conf);
logctx = log_init(console_cli_logpolicy, conf);
if (just_test_share_exists) {
if (!vt->test_for_upstream) {
@ -423,7 +424,8 @@ int main(int argc, char **argv)
}
if (restricted_acl) {
lp_eventlog(default_logpolicy, "Running with restricted process ACL");
lp_eventlog(console_cli_logpolicy,
"Running with restricted process ACL");
}
inhandle = GetStdHandle(STD_INPUT_HANDLE);

View File

@ -712,10 +712,10 @@ char *ssh_sftp_get_cmdline(const char *prompt, bool no_fds_ok)
return ctx->line;
}
void platform_psftp_pre_conn_setup(void)
void platform_psftp_pre_conn_setup(LogPolicy *lp)
{
if (restricted_acl) {
lp_eventlog(default_logpolicy, "Running with restricted process ACL");
lp_eventlog(lp, "Running with restricted process ACL");
}
}