Skip to content
Permalink
Browse files
Report stderr output of transport proxies
Transport proxies may communicate useful information over stderr.
Thus far stderr has been ignored. We should at the very least let
the user know that we have some stderr output (NOTICE), and log it
at INFO level. For now, we assume transport proxy configuration
won't happen over stderr; but the output is meaningful.

Log transport proxy stderr output (if any) in report_proxy_stderr().

 * FIXES #9957
  • Loading branch information
wfn committed Apr 19, 2014
1 parent 9b3ef62 commit f8152a1fd36e5944ccf604a74bfbbb776e791786
Showing with 43 additions and 0 deletions.
  1. +42 −0 src/or/transports.c
  2. +1 −0 src/or/transports.h
@@ -611,6 +611,11 @@ configure_proxy(managed_proxy_t *mp)
tor_assert(mp->conf_state != PT_PROTO_INFANT);
tor_assert(mp->process_handle);

/* Handle lines from stderr. We have to do this before checking stdout's
* <b>stream_status</b>, because we may jump to <em>done</em>, etc. during
* that check. We want to first log stderr if there's anything to log. */
report_proxy_stderr(mp);

proxy_output =
tor_get_lines_from_handle(tor_process_get_stdout_pipe(mp->process_handle),
&stream_status);
@@ -650,6 +655,43 @@ configure_proxy(managed_proxy_t *mp)
return configuration_finished;
}

/** Report any output from the stderr of managed proxy <b>mp</b>.
* Log output, and return nothing. */
STATIC void
report_proxy_stderr(managed_proxy_t *mp)
{
enum stream_status err_stream_status = 0;
smartlist_t *proxy_err_output = NULL;

proxy_err_output =
tor_get_lines_from_handle(tor_process_get_stderr_pipe(mp->process_handle),
&err_stream_status);

if (proxy_err_output) {
log_notice(LD_GENERAL, "Managed proxy '%s' is giving some output over "
"the standard error stream (stderr). This usually means that "
"it has encountered some error that I won't be able to "
"understand. You should enable INFO-level tor log to see what "
"it is saying - when INFO-level log is enabled, look for "
"lines with 'report_proxy_stderr' (without quotes).",
mp->argv[0]);
log_info(LD_GENERAL, "Managed proxy '%s' reports a possible error over "
"the standard error stream (stderr) - stderr output follows:",
mp->argv[0]);
SMARTLIST_FOREACH_BEGIN(proxy_err_output, const char *, line) {
/* Should we expect any output from stderr to contribute to the proxy
* config process? (We assume not.) */
log_info(LD_GENERAL, "Managed proxy '%s' says (over stderr): %s",
mp->argv[0], escaped(line));
/* (If we want to just output this stream in one go, we may use
* get_string_from_pipe() - but this works, too.) */
} SMARTLIST_FOREACH_END(line);

SMARTLIST_FOREACH(proxy_err_output, char *, cp, tor_free(cp));
smartlist_free(proxy_err_output);
}
}

/** Register server managed proxy <b>mp</b> transports to state */
static void
register_server_proxy(const managed_proxy_t *mp)
@@ -122,6 +122,7 @@ STATIC managed_proxy_t *managed_proxy_create(const smartlist_t *transport_list,
char **proxy_argv, int is_server);

STATIC int configure_proxy(managed_proxy_t *mp);
STATIC void report_proxy_stderr(managed_proxy_t *mp);

#endif

0 comments on commit f8152a1

Please sign in to comment.