finalised fix on libevent open string issue

This commit is contained in:
Cristian Toader 2013-08-19 11:41:46 +03:00
parent c09b11b6d8
commit a9910d89f1
2 changed files with 9 additions and 12 deletions

View File

@ -261,15 +261,6 @@ sb_open(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
} }
} }
// todo remove when libevent fix
rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 1,
SCMP_CMP(1, SCMP_CMP_EQ, O_RDONLY|O_LARGEFILE|O_CLOEXEC));
if (rc != 0) {
log_err(LD_BUG,"(Sandbox) failed to add open syscall, received libseccomp "
"error %d", rc);
return rc;
}
// problem: required by getaddrinfo // problem: required by getaddrinfo
rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 1, rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 1,
SCMP_CMP(1, SCMP_CMP_EQ, O_RDONLY|O_CLOEXEC)); SCMP_CMP(1, SCMP_CMP_EQ, O_RDONLY|O_CLOEXEC));

View File

@ -1444,13 +1444,14 @@ configure_nameservers(int force)
const or_options_t *options; const or_options_t *options;
const char *conf_fname; const char *conf_fname;
struct stat st; struct stat st;
int r; int r, flags;
options = get_options(); options = get_options();
conf_fname = options->ServerDNSResolvConfFile; conf_fname = options->ServerDNSResolvConfFile;
#ifndef _WIN32 #ifndef _WIN32
if (!conf_fname) if (!conf_fname)
conf_fname = "/etc/resolv.conf"; conf_fname = "/etc/resolv.conf";
#endif #endif
flags = DNS_OPTIONS_ALL;
if (!the_evdns_base) { if (!the_evdns_base) {
if (!(the_evdns_base = evdns_base_new(tor_libevent_get_base(), 0))) { if (!(the_evdns_base = evdns_base_new(tor_libevent_get_base(), 0))) {
@ -1492,9 +1493,14 @@ configure_nameservers(int force)
evdns_base_search_clear(the_evdns_base); evdns_base_search_clear(the_evdns_base);
evdns_base_clear_nameservers_and_suspend(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); log_info(LD_EXIT, "Parsing resolver configuration in '%s'", conf_fname);
if ((r = evdns_base_resolv_conf_parse(the_evdns_base, if ((r = evdns_base_resolv_conf_parse(the_evdns_base, flags,
DNS_OPTIONS_ALL, conf_fname))) { sandbox_intern_string(conf_fname)))) {
log_warn(LD_EXIT, "Unable to parse '%s', or no nameservers in '%s' (%d)", log_warn(LD_EXIT, "Unable to parse '%s', or no nameservers in '%s' (%d)",
conf_fname, conf_fname, r); conf_fname, conf_fname, r);
goto err; goto err;