changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: ndb/dns: handle empty $DNSSERVER

changeset 7416: f23608703701
parent 7415: 489439903f0d
child 7417: 278bf2c57889
author: cinap_lenrek@felloff.net
date: Sun, 13 Oct 2019 09:02:04 +0200
files: sys/src/cmd/ndb/dblookup.c
description: ndb/dns: handle empty $DNSSERVER

when $DNSSERVER is empty, query ndb for local dns servers
instead of not using any at all.
     1.1--- a/sys/src/cmd/ndb/dblookup.c
     1.2+++ b/sys/src/cmd/ndb/dblookup.c
     1.3@@ -937,11 +937,9 @@ dnsservers(int class)
     1.4 		return nsrp;
     1.5 
     1.6 	p = getenv("DNSSERVER");		/* list of ip addresses */
     1.7-	if(p != nil){
     1.8-		n = tokenize(p, args, nelem(args));
     1.9+	if(p != nil && (n = tokenize(p, args, nelem(args))) > 0){
    1.10 		for(i = 0; i < n; i++)
    1.11 			addlocaldnsserver(dp, class, args[i], i);
    1.12-		free(p);
    1.13 	} else {
    1.14 		t = lookupinfo("@dns");		/* @dns=ip1 @dns=ip2 ... */
    1.15 		if(t == nil)
    1.16@@ -953,6 +951,7 @@ dnsservers(int class)
    1.17 		}
    1.18 		ndbfree(t);
    1.19 	}
    1.20+	free(p);
    1.21 
    1.22 	return rrlookup(dp, Tns, NOneg);
    1.23 }