[or-cvs] r9157: Resolve bug 363: do not fall back to 127.0.0.1 when no names (in tor/trunk: . doc src/or)

nickm at seul.org nickm at seul.org
Tue Dec 19 19:49:05 UTC 2006


Author: nickm
Date: 2006-12-19 14:49:03 -0500 (Tue, 19 Dec 2006)
New Revision: 9157

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/dns.c
   tor/trunk/src/or/eventdns.c
   tor/trunk/src/or/eventdns.h
Log:
 r11646 at Kushana:  nickm | 2006-12-19 14:40:38 -0500
 Resolve bug 363: do not fall back to 127.0.0.1 when no nameservers are configured.  Instead, have the admin fix resolv.conf or configure a nameserver.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11646] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-12-19 19:48:58 UTC (rev 9156)
+++ tor/trunk/ChangeLog	2006-12-19 19:49:03 UTC (rev 9157)
@@ -67,6 +67,10 @@
     - Remove an artificial (but quite high) restriction on expected
       bandwidth, so that accounting won't break once we all have gigabit
       connections to our homes.
+    - When running as a server, don't fall back to 127.0.0.1 when
+      no nameservers are configured in /etc/resolv.conf; instead, make
+      the user fix resolv.conf or specify nameservers explicitly. (Resolves
+      Bug 363.)
 
   o Controller features:
     - Have GETINFO dir/status/* work on hosts with DirPort disabled.

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2006-12-19 19:48:58 UTC (rev 9156)
+++ tor/trunk/doc/TODO	2006-12-19 19:49:03 UTC (rev 9157)
@@ -104,7 +104,7 @@
       o add a config option to turn it off.
     - Bug 364: notice when all the DNS requests we get back (including a few
       well-known sites) are all going to the same place.
-    - Bug 363: Warn and die if we can't find a nameserver and we're running a
+    o Bug 363: Warn and die if we can't find a nameserver and we're running a
       server; don't fall back to 127.0.0.1.
 ?   - maybe re-check dns when we change IP addresses, rather than
       every 12 hours?

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2006-12-19 19:48:58 UTC (rev 9156)
+++ tor/trunk/src/or/dns.c	2006-12-19 19:49:03 UTC (rev 9157)
@@ -1465,8 +1465,11 @@
       evdns_clear_nameservers_and_suspend();
     }
     log_info(LD_EXIT, "Parsing resolver configuration in '%s'", conf_fname);
-    if (evdns_resolv_conf_parse(DNS_OPTIONS_ALL, conf_fname))
+    if (evdns_resolv_conf_parse(DNS_OPTIONS_ALL, conf_fname)) {
+      log_warn(LD_EXIT, "Unable to parse '%s', or no nameservers in '%s'",
+               conf_fname, conf_fname);
       return -1;
+    }
     if (evdns_count_nameservers() == 0) {
       log_warn(LD_EXIT, "Unable to find any nameservers in '%s'.", conf_fname);
       return -1;

Modified: tor/trunk/src/or/eventdns.c
===================================================================
--- tor/trunk/src/or/eventdns.c	2006-12-19 19:48:58 UTC (rev 9156)
+++ tor/trunk/src/or/eventdns.c	2006-12-19 19:49:03 UTC (rev 9157)
@@ -2499,7 +2499,7 @@
 	char *const first_token = strtok_r(start, delims, &strtok_state);
 	if (!first_token) return;
 
-	if (!strcmp(first_token, "nameserver")) {
+	if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) {
 		const char *const nameserver = NEXT_TOKEN;
 		struct in_addr ina;
 
@@ -2579,7 +2579,7 @@
 	if (fstat(fd, &st)) { err = 2; goto out1; }
 	if (!st.st_size) {
 		evdns_resolv_set_defaults(flags);
-		err = 0;
+		err = (flags & DNS_OPTION_NAMESERVERS) ? 6 : 0;
 		goto out1;
 	}
 	if (st.st_size > 65535) { err = 3; goto out1; }	 // no resolv.conf should be any bigger
@@ -2608,6 +2608,7 @@
 	if (!server_head && (flags & DNS_OPTION_NAMESERVERS)) {
 		// no nameservers were configured.
 		evdns_nameserver_ip_add("127.0.0.1");
+        err = 6;
 	}
 	if (flags & DNS_OPTION_SEARCH && (!global_search_state || global_search_state->num_domains == 0)) {
 		search_set_from_hostname();

Modified: tor/trunk/src/or/eventdns.h
===================================================================
--- tor/trunk/src/or/eventdns.h	2006-12-19 19:48:58 UTC (rev 9156)
+++ tor/trunk/src/or/eventdns.h	2006-12-19 19:49:03 UTC (rev 9157)
@@ -187,6 +187,7 @@
  *	  3 file too large
  *	  4 out of memory
  *	  5 short read from file
+ *        6 no nameservers in file
  *
  * Internals:
  *



More information about the tor-commits mailing list