ndb/dns: handle empty $DNSSERVER

when $DNSSERVER is empty, query ndb for local dns servers
instead of not using any at all.
This commit is contained in:
cinap_lenrek 2019-10-13 09:02:04 +02:00
parent c0280c607f
commit e168ea045f

View file

@ -937,11 +937,9 @@ dnsservers(int class)
return nsrp; return nsrp;
p = getenv("DNSSERVER"); /* list of ip addresses */ p = getenv("DNSSERVER"); /* list of ip addresses */
if(p != nil){ if(p != nil && (n = tokenize(p, args, nelem(args))) > 0){
n = tokenize(p, args, nelem(args));
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
addlocaldnsserver(dp, class, args[i], i); addlocaldnsserver(dp, class, args[i], i);
free(p);
} else { } else {
t = lookupinfo("@dns"); /* @dns=ip1 @dns=ip2 ... */ t = lookupinfo("@dns"); /* @dns=ip1 @dns=ip2 ... */
if(t == nil) if(t == nil)
@ -953,6 +951,7 @@ dnsservers(int class)
} }
ndbfree(t); ndbfree(t);
} }
free(p);
return rrlookup(dp, Tns, NOneg); return rrlookup(dp, Tns, NOneg);
} }