summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-09-29 13:02:35 -0400
committerNick Mathewson <nickm@torproject.org>2014-09-29 13:02:35 -0400
commite1a25f0c3602e007872277ef9ab437cc97cfd47b (patch)
treef97f4cf8d6aa8885752c755aac087ea1656daf4e
parent87576e826f5f60d13478bb9de642be0e6f5533a1 (diff)
parent09951bea7fe30cd91d8a4dee95278218f0aa199e (diff)
downloadtor-e1a25f0c3602e007872277ef9ab437cc97cfd47b.tar.gz
tor-e1a25f0c3602e007872277ef9ab437cc97cfd47b.zip
Merge branch 'bug13295_v2_025' into maint-0.2.5
-rw-r--r--changes/132955
-rw-r--r--src/common/sandbox.c21
-rw-r--r--src/common/sandbox.h2
-rw-r--r--src/tools/tor-resolve.c2
4 files changed, 30 insertions, 0 deletions
diff --git a/changes/13295 b/changes/13295
new file mode 100644
index 0000000000..433432595f
--- /dev/null
+++ b/changes/13295
@@ -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.
diff --git a/src/common/sandbox.c b/src/common/sandbox.c
index 05b91be7be..dbbaa59d7c 100644
--- a/src/common/sandbox.c
+++ b/src/common/sandbox.c
@@ -1385,6 +1385,18 @@ HT_GENERATE(getaddrinfo_cache, cached_getaddrinfo_item_t, node,
cached_getaddrinfo_items_eq,
0.6, tor_malloc_, tor_realloc_, 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,
@@ -1393,6 +1405,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;
@@ -1834,5 +1850,10 @@ sandbox_is_active(void)
{
return 0;
}
+
+void
+sandbox_disable_getaddrinfo_cache(void)
+{
+}
#endif
diff --git a/src/common/sandbox.h b/src/common/sandbox.h
index 20d5d5080c..35d87772fd 100644
--- a/src/common/sandbox.h
+++ b/src/common/sandbox.h
@@ -208,5 +208,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_ */
diff --git a/src/tools/tor-resolve.c b/src/tools/tor-resolve.c
index 306f6c66ab..480c7e52ca 100644
--- a/src/tools/tor-resolve.c
+++ b/src/tools/tor-resolve.c
@@ -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;