#else
r = evdns_base_resolv_conf_parse(base, opts, "/etc/resolv.conf");
#endif
- if (r) {
+ if (r && (EVDNS_ERROR_NO_NAMESERVERS_CONFIGURED != r)) {
evdns_base_free_and_unlock(base, 0);
return NULL;
}
#include <sys/queue.h>
#ifndef _WIN32
#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <signal.h>
#include <netinet/in.h>
#include <arpa/inet.h>
if (dns)
evdns_base_free(dns, 0);
}
+
+static void
+dns_nameservers_no_nameservers_configured_test(void *arg)
+{
+ struct basic_test_data *data = arg;
+ struct event_base *base = data->base;
+ struct evdns_base *dns = NULL;
+ int fd = -1;
+ char *tmpfilename = NULL;
+ const char filecontents[] = "# tmp empty resolv.conf\n";
+ const size_t filecontentssize = sizeof(filecontents);
+ int ok;
+
+ fd = regress_make_tmpfile(filecontents, filecontentssize, &tmpfilename);
+ if (fd < 0)
+ tt_skip();
+
+ dns = evdns_base_new(base, 0);
+ tt_assert(dns);
+
+ ok = evdns_base_resolv_conf_parse(dns, DNS_OPTIONS_ALL, tmpfilename);
+ tt_int_op(ok, ==, EVDNS_ERROR_NO_NAMESERVERS_CONFIGURED);
+
+end:
+ if (fd != -1)
+ close(fd);
+ if (dns)
+ evdns_base_free(dns, 0);
+ if (tmpfilename) {
+ unlink(tmpfilename);
+ free(tmpfilename);
+ }
+}
#endif
/* === Test for bufferevent_socket_connect_hostname */
#ifndef _WIN32
{ "nameservers_no_default", dns_nameservers_no_default_test,
TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
+ { "no_nameservers_configured", dns_nameservers_no_nameservers_configured_test,
+ TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
#endif
{ "getaddrinfo_async", test_getaddrinfo_async,
return (-1);
if (write(fd, data, datalen) != (int)datalen) {
close(fd);
+ unlink(tmpfilename);
return (-1);
}
lseek(fd, 0, SEEK_SET);
- /* remove it from the file system */
- unlink(tmpfilename);
+ *filename_out = strdup(tmpfilename);
return (fd);
#else
/* XXXX actually delete the file later */