mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Remove FLAG_STDERR completely.
Originally, it controlled whether ssh.c should send terminal messages (such as login and password prompts) to terminal.c or to stderr. But we've had the from_backend() abstraction for ages now, which even has an existing flag to indicate that the data is stderr rather than stdout data; applications which set FLAG_STDERR are precisely those that link against uxcons or wincons, so from_backend will do the expected thing anyway with data sent to it with that flag set. So there's no reason ssh.c can't just unconditionally pass everything through that, and remove the special case. FLAG_STDERR was also used by winproxy and uxproxy to decide whether to capture standard error from a local proxy command, or whether to let the proxy command send its diagnostics directly to the usual standard error. On reflection, I think it's better to unconditionally capture the proxy's stderr, for three reasons. Firstly, it means proxy diagnostics are prefixed with 'proxy:' so that you can tell them apart from any other stderr spew (which used to be particularly confusing if both the main application and the proxy command were instances of Plink); secondly, proxy diagnostics are now reliably copied to packet log files along with all the other Event Log entries, even by command-line tools; and thirdly, this means the option to suppress proxy command diagnostics after the main session starts will actually _work_ in the command-line tools, which it previously couldn't. A more minor structure change is that copying of Event Log messages to stderr in verbose mode is now done by wincons/uxcons, instead of centrally in logging.c (since logging.c can now no longer check FLAG_STDERR to decide whether to do it). The total amount of code to do this is considerably smaller than the defensive-sounding comment in logevent.c explaining why I did it the other way instead :-)
This commit is contained in:
@ -342,6 +342,10 @@ void console_provide_logctx(LogContext *logctx)
|
||||
|
||||
void logevent(Frontend *frontend, const char *string)
|
||||
{
|
||||
if (flags & FLAG_VERBOSE) {
|
||||
fprintf(stderr, "%s\n", string);
|
||||
fflush(stderr);
|
||||
}
|
||||
log_eventlog(console_logctx, string);
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ int main(int argc, char **argv)
|
||||
default_protocol = PROT_SSH;
|
||||
default_port = 22;
|
||||
|
||||
flags = FLAG_STDERR;
|
||||
flags = 0;
|
||||
cmdline_tooltype |=
|
||||
(TOOLTYPE_HOST_ARG |
|
||||
TOOLTYPE_HOST_ARG_CAN_BE_SESSION |
|
||||
|
@ -66,23 +66,15 @@ Socket platform_new_connection(SockAddr addr, const char *hostname,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (flags & FLAG_STDERR) {
|
||||
/* If we have a sensible stderr, the proxy command can send
|
||||
* its own standard error there, so we won't interfere. */
|
||||
us_from_cmd_err = cmd_err_to_us = NULL;
|
||||
} else {
|
||||
/* If we don't have a sensible stderr, we should catch the
|
||||
* proxy command's standard error to put in our event log. */
|
||||
if (!CreatePipe(&us_from_cmd_err, &cmd_err_to_us, &sa, 0)) {
|
||||
Socket ret = new_error_socket
|
||||
("Unable to create pipes for proxy command", plug);
|
||||
sfree(cmd);
|
||||
CloseHandle(us_from_cmd);
|
||||
CloseHandle(cmd_to_us);
|
||||
CloseHandle(us_to_cmd);
|
||||
CloseHandle(cmd_from_us);
|
||||
return ret;
|
||||
}
|
||||
if (!CreatePipe(&us_from_cmd_err, &cmd_err_to_us, &sa, 0)) {
|
||||
Socket ret = new_error_socket
|
||||
("Unable to create pipes for proxy command", plug);
|
||||
sfree(cmd);
|
||||
CloseHandle(us_from_cmd);
|
||||
CloseHandle(cmd_to_us);
|
||||
CloseHandle(us_to_cmd);
|
||||
CloseHandle(cmd_from_us);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SetHandleInformation(us_to_cmd, HANDLE_FLAG_INHERIT, 0);
|
||||
|
Reference in New Issue
Block a user