Browse Source

Plan 9 from Bell Labs 2003-04-02

David du Colombier 21 years ago
parent
commit
29e6fd02b1

+ 11 - 11
dist/replica/plan9.db

@@ -295,9 +295,9 @@
 386/bin/mtime - 775 sys sys 1045538032 57878
 386/bin/mv - 775 sys sys 1045538032 64996
 386/bin/ndb - 20000000775 sys sys 985743147 0
-386/bin/ndb/cs - 775 sys sys 1045538033 143190
+386/bin/ndb/cs - 775 sys sys 1049249435 143599
 386/bin/ndb/csquery - 775 sys sys 1039758577 60136
-386/bin/ndb/dns - 775 sys sys 1048745055 211034
+386/bin/ndb/dns - 775 sys sys 1049249442 211255
 386/bin/ndb/dnsdebug - 775 sys sys 1048745056 186027
 386/bin/ndb/dnsquery - 775 sys sys 1039758578 62442
 386/bin/ndb/dnstcp - 775 sys sys 1048745057 184851
@@ -420,7 +420,7 @@
 386/bin/upas/runq - 775 sys sys 1048745088 111315
 386/bin/upas/scanmail - 775 sys sys 1048745089 127491
 386/bin/upas/send - 775 sys sys 1048799701 188975
-386/bin/upas/smtp - 775 sys sys 1048799702 268124
+386/bin/upas/smtp - 775 sys sys 1049249426 268972
 386/bin/upas/smtpd - 775 sys sys 1048799703 311374
 386/bin/upas/testscan - 775 sys sys 1045538077 82381
 386/bin/upas/token - 775 sys sys 1039758605 76178
@@ -9305,22 +9305,22 @@ sys/src/cmd/mv.c - 664 sys sys 1014926695 4276
 sys/src/cmd/ndb - 20000000775 sys sys 988249988 0
 sys/src/cmd/ndb/convDNS2M.c - 664 sys sys 1021579991 6525
 sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1021579992 6684
-sys/src/cmd/ndb/cs.c - 664 sys sys 1032060499 32345
+sys/src/cmd/ndb/cs.c - 664 sys sys 1049249331 32741
 sys/src/cmd/ndb/csgetval.c - 664 sys sys 957402051 1051
 sys/src/cmd/ndb/csquery.c - 664 sys sys 1014926159 1062
-sys/src/cmd/ndb/dblookup.c - 664 sys sys 1048644530 18341
-sys/src/cmd/ndb/dn.c - 664 sys sys 1032060501 25175
-sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1045505455 15249
-sys/src/cmd/ndb/dns.c - 664 sys sys 1032060500 14957
+sys/src/cmd/ndb/dblookup.c - 664 sys sys 1049249333 18409
+sys/src/cmd/ndb/dn.c - 664 sys sys 1049249332 25182
+sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1049249333 15279
+sys/src/cmd/ndb/dns.c - 664 sys sys 1049249331 15051
 sys/src/cmd/ndb/dns.h - 664 sys sys 1032060499 8082
-sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1021579993 8278
+sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1049249332 8333
 sys/src/cmd/ndb/dnserver.c - 664 sys sys 1021579994 3687
 sys/src/cmd/ndb/dnsquery.c - 664 sys sys 1014926160 2108
 sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1024158822 7040
 sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1024158821 5050
 sys/src/cmd/ndb/ipquery.c - 664 sys sys 960335375 760
 sys/src/cmd/ndb/mkdb.c - 664 sys sys 957402054 2886
-sys/src/cmd/ndb/mkfile - 664 sys sys 1032060324 1804
+sys/src/cmd/ndb/mkfile - 664 sys sys 1049249334 1835
 sys/src/cmd/ndb/mkhash.c - 664 sys sys 1014926160 2899
 sys/src/cmd/ndb/mkhosts.c - 664 sys sys 957402054 4294
 sys/src/cmd/ndb/query.c - 664 sys sys 957402054 1133
@@ -10423,7 +10423,7 @@ sys/src/cmd/upas/smtp/mkfile - 664 sys sys 1047490346 734
 sys/src/cmd/upas/smtp/mxdial.c - 664 sys sys 1015013150 4535
 sys/src/cmd/upas/smtp/rfc822.y - 664 sys sys 1018974179 12512
 sys/src/cmd/upas/smtp/rmtdns.c - 664 sys sys 1015013150 1069
-sys/src/cmd/upas/smtp/smtp.c - 664 sys sys 1043171649 18267
+sys/src/cmd/upas/smtp/smtp.c - 664 sys sys 1049249402 18227
 sys/src/cmd/upas/smtp/smtp.h - 664 sys sys 1015013151 1038
 sys/src/cmd/upas/smtp/smtpd.c - 664 sys sys 1046783570 24124
 sys/src/cmd/upas/smtp/smtpd.h - 664 sys sys 1045505962 1063

+ 11 - 0
dist/replica/plan9.log

@@ -19031,3 +19031,14 @@
 1048969914 3 c sys/src/cmd/unix/u9fs/plan9.h - 664 sys sys 1048969296 5572
 1049040058 0 c sys/man/4/factotum - 664 sys sys 1049038407 14737
 1049135487 0 c sys/man/4/nfs - 664 sys sys 1049135219 2740
+1049250615 0 c 386/bin/ndb/cs - 775 sys sys 1049249435 143599
+1049250615 1 c 386/bin/ndb/dns - 775 sys sys 1049249442 211255
+1049250615 2 c 386/bin/upas/smtp - 775 sys sys 1049249426 268972
+1049250615 3 c sys/src/cmd/ndb/cs.c - 664 sys sys 1049249331 32741
+1049250615 4 c sys/src/cmd/ndb/dblookup.c - 664 sys sys 1049249333 18409
+1049250615 5 c sys/src/cmd/ndb/dn.c - 664 sys sys 1049249332 25182
+1049250615 6 c sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1049249333 15279
+1049250615 7 c sys/src/cmd/ndb/dns.c - 664 sys sys 1049249331 15051
+1049250615 8 c sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1049249332 8333
+1049250615 9 c sys/src/cmd/ndb/mkfile - 664 sys sys 1049249334 1835
+1049250615 10 c sys/src/cmd/upas/smtp/smtp.c - 664 sys sys 1049249402 18227

+ 23 - 7
sys/src/cmd/ndb/cs.c

@@ -414,7 +414,8 @@ io(void)
 			error("mount read");
 		job = newjob();
 		if(convM2S(mdata, n, &job->request) != n){
-			syslog(1, logfile, "format error %ux %ux %ux %ux %ux", mdata[0], mdata[1], mdata[2], mdata[3], mdata[4]);
+			syslog(1, logfile, "format error %ux %ux %ux %ux %ux",
+				mdata[0], mdata[1], mdata[2], mdata[3], mdata[4]);
 			freejob(job);
 			continue;
 		}
@@ -730,6 +731,7 @@ rwrite(Job *job, Mfile *mf)
 	int cnt, n;
 	char *err;
 	char *field[4];
+	char curerr[64];
 
 	err = 0;
 	cnt = job->request.count;
@@ -820,8 +822,10 @@ rwrite(Job *job, Mfile *mf)
 	/*
 	 *  do the first net worth of lookup
 	 */
-	if(lookup(mf) == 0)
-		err = "can't translate address";
+	if(lookup(mf) == 0){
+		rerrstr(curerr, sizeof curerr);
+		err = curerr;
+	}
 send:
 	job->reply.count = cnt;
 	sendmsg(job, err);
@@ -1258,7 +1262,7 @@ ipserv(Network *np, char *name, char *buf)
 			{}
 		else if(isalpha(*p) || *p == '-' || *p == '$')
 			alpha = 1;
-		else
+		else 
 			return 0;
 	}
 	if(alpha){
@@ -1334,8 +1338,9 @@ iplookup(Network *np, char *host, char *serv, int nolookup)
 	 *  start with the service since it's the most likely to fail
 	 *  and costs the least
 	 */
+	werrstr("can't translate address");
 	if(serv==0 || ipserv(np, serv, ts) == 0){
-		werrstr("can't translate address");
+		werrstr("can't translate service");
 		return 0;
 	}
 
@@ -1378,6 +1383,7 @@ iplookup(Network *np, char *host, char *serv, int nolookup)
 	 *  resolve domain names.  if that fails try the database.
 	 */
 	t = 0;
+	werrstr("can't translate address");
 	if(strcmp(attr, "dom") == 0)
 		t = dnsiplookup(host, &s);
 	if(t == 0)
@@ -1433,9 +1439,10 @@ iptrans(Ndbtuple *t, Network *np, char *serv, char *rem, int hack)
 	if(strcmp(t->attr, "ip") != 0)
 		return 0;
 
-	if(serv == 0 || ipserv(np, serv, ts) == 0)
+	if(serv == 0 || ipserv(np, serv, ts) == 0){
+		werrstr("can't translate service");
 		return 0;
-
+	}
 	if(rem != nil)
 		snprint(x, sizeof(x), "!%s", rem);
 	else
@@ -1463,6 +1470,7 @@ telcolookup(Network *np, char *host, char *serv, int nolookup)
 
 	USED(np, nolookup, serv);
 
+	werrstr("can't translate address");
 	t = ndbgetval(db, &s, "sys", host, "telco", th);
 	if(t == 0)
 		return mktuple("telco", host);
@@ -1569,6 +1577,14 @@ dnsiplookup(char *host, Ndbs *s)
 		t = dnsquery(mntpt, buf, "ip");
 	s->t = t;
 
+	if(t == nil){
+		rerrstr(buf, sizeof buf);
+		if(strstr(buf, "exist"))
+			werrstr("can't translate address: %s", buf);
+		else if(strstr(buf, "dns failure"))
+			werrstr("temporary problem: %s", buf);
+	}
+
 	lock(&dblock);
 	return t;
 }

+ 3 - 2
sys/src/cmd/ndb/dblookup.c

@@ -137,8 +137,9 @@ out:
 		for(tp = rp; tp; tp = tp->next)
 			tp->owner = dp;
 	} else {
-		if(inmyarea(name) == nil)
-			err = 0;
+		/* don't call it non-existent if it's not ours */
+		if(err == Rname && !inmyarea(name))
+			err = Rserver;
 		dp->nonexistent = err;
 	}
 

+ 1 - 1
sys/src/cmd/ndb/dn.c

@@ -53,7 +53,7 @@ char *rrtname[] =
 };
 
 /* names of response codes */
-char *rname[] =
+char *rname[Rmask+1] =
 {
 [Rok]			"ok",
 [Rformat]		"format error",

+ 1 - 0
sys/src/cmd/ndb/dnresolve.c

@@ -39,6 +39,7 @@ dnresolve(char *name, int class, int type, Request *req, RR **cn, int depth, int
 		for(nrp = drp; nrp != nil; nrp = nrp->next){
 			snprint(nname, sizeof(nname), "%s.%s", name, nrp->ptr->name);
 			rp = dnresolve(nname, class, type, req,cn, depth, recurse, rooted, status);
+			rrfreelist(rrremneg(&rp));
 			if(rp != nil)
 				break;
 		}

+ 11 - 3
sys/src/cmd/ndb/dns.c

@@ -718,10 +718,18 @@ rwrite(Job *job, Mfile *mf, Request *req)
 		rrfreelist(neg);
 	}
 	if(rp == 0){
-		if(status == Rname)
+		
+		switch(status){
+		case Rname:
 			err = "name does not exist";
-		else
-			err = "no translation found";
+			break;
+		case Rserver:
+			err = "dns failure";
+			break;
+		default:
+			err = "resource does not exist";
+			break;
+		}
 	} else {
 		/* format data to be read later */
 		n = 0;

+ 7 - 3
sys/src/cmd/ndb/dnsdebug.c

@@ -305,7 +305,7 @@ squirrelserveraddrs(void)
 		}
 		req.isslave = 1;
 		req.aborttime = now + 60;	/* don't spend more than 60 seconds */
-		*l = dnresolve(rp->host->name, Cin, Ta, &req, 0, 0, Recurse, 1, 0);
+		*l = dnresolve(rp->host->name, Cin, Ta, &req, 0, 0, Recurse, 0, 0);
 		while(*l != nil)
 			l = &(*l)->next;
 	}
@@ -353,6 +353,7 @@ doquery(char *name, char *tstr)
 	RR *rr, *rp;
 	int len, type;
 	char *p, *np;
+	int rooted;
 	char buf[1024];
 
 	if(resolver)
@@ -368,8 +369,11 @@ doquery(char *name, char *tstr)
 
 	/* if name end in '.', remove it */
 	len = strlen(name);
-	if(len > 0 && name[len-1] == '.')
+	if(len > 0 && name[len-1] == '.'){
+		rooted = 1;
 		name[len-1] = 0;
+	} else
+		rooted = 0;
 
 	/* inverse queries may need to be permuted */
 	strncpy(buf, name, sizeof buf);
@@ -405,7 +409,7 @@ doquery(char *name, char *tstr)
 	getactivity(&req);
 	req.isslave = 1;
 	req.aborttime = now + 60;	/* don't spend more than 60 seconds */
-	rr = dnresolve(buf, Cin, type, &req, 0, 0, Recurse, 1, 0);
+	rr = dnresolve(buf, Cin, type, &req, 0, 0, Recurse, rooted, 0);
 	if(rr){
 		print("----------------------------\n");
 		for(rp = rr; rp; rp = rp->next)

+ 4 - 4
sys/src/cmd/ndb/mkfile

@@ -78,14 +78,14 @@ dns.safeinstall: $O.dns
 
 dns.update:V:
 	SRC=`{echo $DNSOBJ|sed 's/\.'$O'/.c/g'}
-	update dns.h $SRC /386/bin/ndb/dns
+	update $UPDATEFLAGS dns.h $SRC
 
 %.update:V:
-	update $stem.c /386/bin/ndb/$stem
+	update $UPDATEFLAGS $stem.c
 
 update:V:
 	mk clean
 	T=`{echo $TARG|sed 's/( |$)/.update /g'}
-	mk $T
-	update mkfile
+	mk 'UPDATEFLAGS='$"UPDATEFLAGS $T
+	update $UPDATEFLAGS mkfile
 

+ 1 - 2
sys/src/cmd/upas/smtp/smtp.c

@@ -255,8 +255,7 @@ connect(char* net)
 		syslog(0, "smtp.fail", "%s (%s)", buf, net);
 		if(strstr(buf, "illegal")
 		|| strstr(buf, "unknown")
-		|| strstr(buf, "can't translate")
-		|| strstr(buf, "name does not exist"))
+		|| strstr(buf, "can't translate"))
 			return Giveup;
 		else
 			return Retry;