Repository: trafficserver
Updated Branches:
  refs/heads/master b597f9cfa -> cc6233173


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


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

Branch: refs/heads/master
Commit: 576c2de9d2e17f6930e718ec34f8fb3baba692d1
Parents: b597f9c
Author: Zizhong Zhang <zizh...@linkedin.com>
Authored: Sun Jul 26 21:46:52 2015 -0700
Committer: Brian Geffon <bri...@apache.org>
Committed: Mon Aug 10 19:40:18 2015 -0700

----------------------------------------------------------------------
 lib/ts/ink_res_init.cc | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/576c2de9/lib/ts/ink_res_init.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_res_init.cc b/lib/ts/ink_res_init.cc
index 958f2dd..00dc938 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,8 +521,17 @@ ink_res_init(ink_res_state statp,         ///< State 
object to update.
     (void)fclose(fp);
   }
 
-  if (nserv > 0)
-    statp->nscount = nserv;
+  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 (statp->defdname[0] == 0 && gethostname(buf, sizeof(statp->defdname) - 1) 
== 0 && (cp = strchr(buf, '.')) != NULL)
     ink_strlcpy(statp->defdname, cp + 1, sizeof(statp->defdname));

Reply via email to