Merge remote-tracking branch 'origin/maint-0.2.5'

This commit is contained in:
Nick Mathewson 2014-09-29 13:02:50 -04:00
commit 2e607ff519
4 changed files with 30 additions and 0 deletions

5
changes/13295 Normal file
View File

@ -0,0 +1,5 @@
o Minor bugfixes:
- Disable sandbox name resolver cache when running tor-resolve:
tor-resolve doesn't use the sandbox code, and turning it on was
breaking attempts to do tor-resolve on a non-default server on
Linux. Fixes bug 13295; bugfix on 0.2.5.3-alpha.

View File

@ -1297,6 +1297,18 @@ HT_GENERATE2(getaddrinfo_cache, cached_getaddrinfo_item_t, node,
cached_getaddrinfo_items_eq,
0.6, tor_reallocarray_, tor_free_)
/** If true, don't try to cache getaddrinfo results. */
static int sandbox_getaddrinfo_cache_disabled = 0;
/** Tell the sandbox layer not to try to cache getaddrinfo results. Used as in
* tor-resolve, when we have no intention of initializing crypto or of
* installing the sandbox.*/
void
sandbox_disable_getaddrinfo_cache(void)
{
sandbox_getaddrinfo_cache_disabled = 1;
}
int
sandbox_getaddrinfo(const char *name, const char *servname,
const struct addrinfo *hints,
@ -1305,6 +1317,10 @@ sandbox_getaddrinfo(const char *name, const char *servname,
int err;
struct cached_getaddrinfo_item_t search, *item;
if (sandbox_getaddrinfo_cache_disabled) {
return getaddrinfo(name, NULL, hints, res);
}
if (servname != NULL) {
log_warn(LD_BUG, "called with non-NULL servname");
return EAI_NONAME;
@ -1718,5 +1734,10 @@ sandbox_is_active(void)
{
return 0;
}
void
sandbox_disable_getaddrinfo_cache(void)
{
}
#endif

View File

@ -176,5 +176,7 @@ int sandbox_init(sandbox_cfg_t* cfg);
/** Return true iff the sandbox is turned on. */
int sandbox_is_active(void);
void sandbox_disable_getaddrinfo_cache(void);
#endif /* SANDBOX_H_ */

View File

@ -8,6 +8,7 @@
#include "../common/util.h"
#include "address.h"
#include "../common/torlog.h"
#include "sandbox.h"
#include <stdio.h>
#include <stdlib.h>
@ -344,6 +345,7 @@ main(int argc, char **argv)
log_severity_list_t *s = tor_malloc_zero(sizeof(log_severity_list_t));
init_logging();
sandbox_disable_getaddrinfo_cache();
arg = &argv[1];
n_args = argc-1;