Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
base repository: wfn/tor
base: master
head repository: wfn/tor
compare: bug_9957_2
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
Commits on Apr 19, 2014
We already have the rest of the utilities needed for handling stderr
handles. Just need the actual higher-level function to get the pipe.

This is needed for #9957.
Commits on Apr 22, 2014
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
Showing with 66 additions and 0 deletions.
  1. +8 −0 changes/bug9957
  2. +13 −0 src/common/util.c
  3. +2 −0 src/common/util.h
  4. +43 −0 src/or/transports.c
@@ -0,0 +1,8 @@

o Minor bugfixes (transport proxies):
- Have Tor report stderr output of transport proxies to log.
Previously we ignored standard error streams of transport proxies.
This would sometimes cause confusion when they would fail
prematurely (e.g. obfsproxy tracebacks get dumped to stderr.) We now
make a notice when there's stderr output, and we log the output
itself at INFO level. Implements ticket 9957.
@@ -3600,13 +3600,26 @@ tor_process_get_stdout_pipe(process_handle_t *process_handle)
{
return process_handle->stdout_pipe;
}

HANDLE
tor_process_get_stderr_pipe(process_handle_t *process_handle)
{
return process_handle->stderr_pipe;
}
#else
/* DOCDOC tor_process_get_stdout_pipe */
FILE *
tor_process_get_stdout_pipe(process_handle_t *process_handle)
{
return process_handle->stdout_handle;
}

/* DOCDOC tor_process_get_stderr_pipe */
FILE *
tor_process_get_stderr_pipe(process_handle_t *process_handle)
{
return process_handle->stderr_handle;
}
#endif

/* DOCDOC process_handle_new */
@@ -488,8 +488,10 @@ char *tor_join_win_cmdline(const char *argv[]);
int tor_process_get_pid(process_handle_t *process_handle);
#ifdef _WIN32
HANDLE tor_process_get_stdout_pipe(process_handle_t *process_handle);
HANDLE tor_process_get_stderr_pipe(process_handle_t *process_handle);
#else
FILE *tor_process_get_stdout_pipe(process_handle_t *process_handle);
FILE *tor_process_get_stderr_pipe(process_handle_t *process_handle);
#endif

#ifdef _WIN32
@@ -105,6 +105,8 @@ create_managed_proxy_environment(const managed_proxy_t *mp);

static INLINE int proxy_configuration_finished(const managed_proxy_t *mp);

static void report_proxy_stderr(managed_proxy_t *mp);

static void handle_finished_proxy(managed_proxy_t *mp);
static void parse_method_error(const char *line, int is_server_method);
#define parse_server_method_error(l) parse_method_error(l, 1)
@@ -611,6 +613,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 +657,42 @@ 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) {
return;
}

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));
} 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)

No commit comments for this range