diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-09-13 12:31:41 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-09-13 12:31:41 -0400 |
commit | e0b2cd061bd62fc790d434b2da7ecc51ed100904 (patch) | |
tree | 0bdd72522895a018e4fc9765df0f3067eff940a1 /src/or/dns.c | |
parent | dffc5c3f240e7734e85a427b951c4e493c85906c (diff) | |
parent | 7cf1b9cc33ab2ba13d84e08105699dd1f39dae1d (diff) | |
download | tor-e0b2cd061bd62fc790d434b2da7ecc51ed100904.tar.gz tor-e0b2cd061bd62fc790d434b2da7ecc51ed100904.zip |
Merge remote-tracking branch 'ctoader/gsoc-cap-stage2'
Conflicts:
src/common/sandbox.c
Diffstat (limited to 'src/or/dns.c')
-rw-r--r-- | src/or/dns.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/or/dns.c b/src/or/dns.c index f2b7eecc3f..62ee4f372d 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -24,6 +24,7 @@ #include "relay.h" #include "router.h" #include "ht.h" +#include "../common/sandbox.h" #ifdef HAVE_EVENT2_DNS_H #include <event2/event.h> #include <event2/dns.h> @@ -1443,13 +1444,14 @@ configure_nameservers(int force) const or_options_t *options; const char *conf_fname; struct stat st; - int r; + int r, flags; options = get_options(); conf_fname = options->ServerDNSResolvConfFile; #ifndef _WIN32 if (!conf_fname) conf_fname = "/etc/resolv.conf"; #endif + flags = DNS_OPTIONS_ALL; if (!the_evdns_base) { if (!(the_evdns_base = evdns_base_new(tor_libevent_get_base(), 0))) { @@ -1477,7 +1479,7 @@ configure_nameservers(int force) evdns_set_log_fn(evdns_log_cb); if (conf_fname) { - if (stat(conf_fname, &st)) { + if (stat(sandbox_intern_string(conf_fname), &st)) { log_warn(LD_EXIT, "Unable to stat resolver configuration in '%s': %s", conf_fname, strerror(errno)); goto err; @@ -1491,9 +1493,14 @@ configure_nameservers(int force) evdns_base_search_clear(the_evdns_base); evdns_base_clear_nameservers_and_suspend(the_evdns_base); } + if (flags & DNS_OPTION_HOSTSFILE) { + flags ^= DNS_OPTION_HOSTSFILE; + evdns_base_load_hosts(the_evdns_base, + sandbox_intern_string("/etc/resolv.conf")); + } log_info(LD_EXIT, "Parsing resolver configuration in '%s'", conf_fname); - if ((r = evdns_base_resolv_conf_parse(the_evdns_base, - DNS_OPTIONS_ALL, conf_fname))) { + if ((r = evdns_base_resolv_conf_parse(the_evdns_base, flags, + sandbox_intern_string(conf_fname)))) { log_warn(LD_EXIT, "Unable to parse '%s', or no nameservers in '%s' (%d)", conf_fname, conf_fname, r); goto err; |