You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by br...@apache.org on 2015/08/11 04:40:55 UTC

[2/2] trafficserver git commit: TS-3792: Pointing proxy.config.dns.resolv_conf at an empty (or nonexistant) file causes crashes. Prevent ATS from crashing.

TS-3792: Pointing proxy.config.dns.resolv_conf at an empty (or nonexistant) file causes crashes. Prevent ATS from crashing.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/cc623317
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/cc623317
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/cc623317

Branch: refs/heads/master
Commit: cc6233173338d6304b89b959d35a6eda01f98e7c
Parents: 576c2de
Author: Zizhong Zhang <zi...@linkedin.com>
Authored: Tue Jul 28 22:21:30 2015 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Mon Aug 10 19:40:19 2015 -0700

----------------------------------------------------------------------
 iocore/dns/DNS.cc      |  7 +++++++
 lib/ts/ink_res_init.cc | 15 +++------------
 2 files changed, 10 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cc623317/iocore/dns/DNS.cc
----------------------------------------------------------------------
diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
index 4601147..1cb5698 100644
--- a/iocore/dns/DNS.cc
+++ b/iocore/dns/DNS.cc
@@ -883,6 +883,13 @@ write_dns(DNSHandler *h)
   int max_nscount = h->m_res->nscount;
   if (max_nscount > MAX_NAMED)
     max_nscount = MAX_NAMED;
+  if (max_nscount <= 0) {
+    Warning("There is no name server found in the resolv.conf");
+    if (h->entries.head) {
+      dns_result(h, h->entries.head, NULL, false);
+    }
+    return;
+  }
 
   if (h->in_write_dns)
     return;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cc623317/lib/ts/ink_res_init.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_res_init.cc b/lib/ts/ink_res_init.cc
index 00dc938..958f2dd 100644
--- a/lib/ts/ink_res_init.cc
+++ b/lib/ts/ink_res_init.cc
@@ -432,7 +432,7 @@ ink_res_init(ink_res_state statp,         ///< State object to update.
 
 #define MATCH(line, name) \
   (!strncmp(line, name, sizeof(name) - 1) && (line[sizeof(name) - 1] == ' ' || line[sizeof(name) - 1] == '\t'))
-retry_load_resolve_conf:
+
   if ((fp = fopen(pResolvConf, "r")) != NULL) {
     /* read the config file */
     while (fgets(buf, sizeof(buf), fp) != NULL) {
@@ -521,17 +521,8 @@ retry_load_resolve_conf:
     (void)fclose(fp);
   }
 
-  if (nserv == 0 && strcmp(pResolvConf, "/etc/resolv.conf") != 0) {
-    syslog(LOG_WARNING, "WARNING: trying default because user specified did not have any resolvers");
-    pResolvConf = "/etc/resolv.conf";
-    goto retry_load_resolve_conf;
-  }
-  if (nserv == 0) {
-    syslog(LOG_ERR, "ERR: aborting the traffic server because it did not have any resolvers");
-    abort();
-  }
-
-  statp->nscount = nserv;
+  if (nserv > 0)
+    statp->nscount = nserv;
 
   if (statp->defdname[0] == 0 && gethostname(buf, sizeof(statp->defdname) - 1) == 0 && (cp = strchr(buf, '.')) != NULL)
     ink_strlcpy(statp->defdname, cp + 1, sizeof(statp->defdname));