config: Catch missing Bridge for ClientTransportPlugin

When making sure we have a Bridge line with a ClientTransportPlugin, we
now check in the managed proxy list and so we can catch any missing
ClientTransportPlugin for a Bridge line.

Fixes #40106

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2020-12-08 10:01:23 -05:00 committed by Alexander Færøy
parent c618c4f279
commit ee6ad0e592
4 changed files with 30 additions and 1 deletions

5
changes/ticket40106 Normal file
View File

@ -0,0 +1,5 @@
o Minor bugfixes (config, bridge):
- Really fix the case where torrc has a missing ClientTransportPlugin but
configured with a Bridge line and UseBridges. Previously, we failed to
also look at the managed proxy list and thus it would fail for the
"exec" case. Fixes bug 40106; bugfix on 0.4.5.1-alpha.

View File

@ -2198,7 +2198,8 @@ options_act,(const or_options_t *old_options))
* validation time. */ * validation time. */
SMARTLIST_FOREACH_BEGIN(bridge_list_get(), const bridge_info_t *, bi) { SMARTLIST_FOREACH_BEGIN(bridge_list_get(), const bridge_info_t *, bi) {
const char *bi_transport_name = bridget_get_transport_name(bi); const char *bi_transport_name = bridget_get_transport_name(bi);
if (bi_transport_name && !transport_get_by_name(bi_transport_name)) { if (bi_transport_name && (!transport_get_by_name(bi_transport_name) &&
!managed_proxy_has_transport(bi_transport_name))) {
log_warn(LD_CONFIG, "Bridge line with transport %s is missing a " log_warn(LD_CONFIG, "Bridge line with transport %s is missing a "
"ClientTransportPlugin line", bi_transport_name); "ClientTransportPlugin line", bi_transport_name);
return -1; return -1;

View File

@ -368,6 +368,28 @@ static int unconfigured_proxies_n = 0;
/** Boolean: True iff we might need to restart some proxies. */ /** Boolean: True iff we might need to restart some proxies. */
static int check_if_restarts_needed = 0; static int check_if_restarts_needed = 0;
/** Return true iff we have a managed_proxy_t in the global list is for the
* given transport name. */
bool
managed_proxy_has_transport(const char *transport_name)
{
tor_assert(transport_name);
if (!managed_proxy_list) {
return false;
}
SMARTLIST_FOREACH_BEGIN(managed_proxy_list, const managed_proxy_t *, mp) {
SMARTLIST_FOREACH_BEGIN(mp->transports_to_launch, const char *, name) {
if (!strcasecmp(name, transport_name)) {
return true;
}
} SMARTLIST_FOREACH_END(name);
} SMARTLIST_FOREACH_END(mp);
return false;
}
/** Return true if there are still unconfigured managed proxies, or proxies /** Return true if there are still unconfigured managed proxies, or proxies
* that need restarting. */ * that need restarting. */
int int

View File

@ -41,6 +41,7 @@ void transport_free_(transport_t *transport);
#define transport_free(tr) FREE_AND_NULL(transport_t, transport_free_, (tr)) #define transport_free(tr) FREE_AND_NULL(transport_t, transport_free_, (tr))
MOCK_DECL(transport_t*, transport_get_by_name, (const char *name)); MOCK_DECL(transport_t*, transport_get_by_name, (const char *name));
bool managed_proxy_has_transport(const char *transport_name);
MOCK_DECL(void, pt_kickstart_proxy, MOCK_DECL(void, pt_kickstart_proxy,
(const smartlist_t *transport_list, char **proxy_argv, (const smartlist_t *transport_list, char **proxy_argv,