Browse Source

Plan 9 from Bell Labs 2003-04-04

David du Colombier 18 years ago
parent
commit
1ef5a17901

+ 9 - 2
386/bin/aux/vmware

@@ -1,8 +1,15 @@
 #!/bin/rc
 
 if(aux/isvmware -s){
-	echo -n on >'#P/pge'	# default, but set anyway.
-	echo -n off >'#P/i8253timerset'
+	if(test -f '#P/pge'){
+		echo -n on >'#P/pge'	# default, but set anyway.
+		echo -n off >'#P/i8253timerset'
+	}
+	if(test -f /dev/archctl){
+		echo pge on >/dev/archctl
+		echo coherence nop >/dev/archctl
+		echo i8253set off >/dev/archctl
+	}
 	for(i in '#S'/sd??)
 		if(test -f $i/ctl)
 			echo dma on >$i/ctl

+ 17 - 16
dist/replica/plan9.db

@@ -146,7 +146,7 @@
 386/bin/aux/typepasswd - 775 sys sys 1045537960 68154
 386/bin/aux/vga - 775 sys sys 1048745030 300067
 386/bin/aux/vmmousepoll - 775 sys sys 1032480572 41434
-386/bin/aux/vmware - 775 sys sys 1045537961 298
+386/bin/aux/vmware - 775 sys sys 1049428256 453
 386/bin/aux/vmwarefs - 775 sys sys 1045537962 102172
 386/bin/aux/write - 775 sys sys 1038443108 4198
 386/bin/awd - 775 sys sys 1038443108 5033
@@ -295,12 +295,12 @@
 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 1049249435 143599
+386/bin/ndb/cs - 775 sys sys 1049377481 143599
 386/bin/ndb/csquery - 775 sys sys 1039758577 60136
-386/bin/ndb/dns - 775 sys sys 1049249442 211255
-386/bin/ndb/dnsdebug - 775 sys sys 1048745056 186027
+386/bin/ndb/dns - 775 sys sys 1049428257 211411
+386/bin/ndb/dnsdebug - 775 sys sys 1049428257 186400
 386/bin/ndb/dnsquery - 775 sys sys 1039758578 62442
-386/bin/ndb/dnstcp - 775 sys sys 1048745057 184851
+386/bin/ndb/dnstcp - 775 sys sys 1049428258 185185
 386/bin/ndb/ipquery - 775 sys sys 1045538035 91678
 386/bin/ndb/mkdb - 775 sys sys 1039758578 62632
 386/bin/ndb/mkhash - 775 sys sys 1045538035 82294
@@ -420,8 +420,8 @@
 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 1049249426 268972
-386/bin/upas/smtpd - 775 sys sys 1048799703 311374
+386/bin/upas/smtp - 775 sys sys 1049377485 268184
+386/bin/upas/smtpd - 775 sys sys 1049428259 312341
 386/bin/upas/testscan - 775 sys sys 1045538077 82381
 386/bin/upas/token - 775 sys sys 1039758605 76178
 386/bin/upas/vf - 775 sys sys 1045538077 90532
@@ -2963,6 +2963,7 @@ rc/bin/service/tcp17005 - 775 sys sys 965182903 31
 rc/bin/service/tcp17006 - 775 sys sys 965182903 15
 rc/bin/service/tcp17007 - 775 sys sys 1016832239 86
 rc/bin/service/tcp17009 - 775 sys sys 950049242 31
+rc/bin/service/tcp17010 - 775 sys sys 1049413268 14
 rc/bin/service/tcp17013 - 775 sys sys 1016832196 14
 rc/bin/service/tcp19 - 775 sys sys 945617223 30
 rc/bin/service/tcp21 - 775 sys sys 954517722 31
@@ -3285,7 +3286,7 @@ sys/include/html.h - 664 sys sys 1017679304 15157
 sys/include/httpd.h - 664 sys sys 1014929064 5726
 sys/include/ip.h - 664 sys sys 1015700847 2395
 sys/include/keyboard.h - 664 sys sys 1014929064 799
-sys/include/libc.h - 664 sys sys 1037035097 18624
+sys/include/libc.h - 664 sys sys 1049426002 18829
 sys/include/libsec.h - 664 sys sys 1048616895 8914
 sys/include/mach.h - 664 sys sys 1032058231 8101
 sys/include/memdraw.h - 664 sys sys 1039752978 5616
@@ -4891,7 +4892,7 @@ sys/man/8/scuzz - 664 sys sys 984709640 7916
 sys/man/8/secstore - 664 sys sys 1045501623 990
 sys/man/8/securenet - 664 sys sys 954305552 3160
 sys/man/8/send - 664 sys sys 1045501634 2168
-sys/man/8/smtp - 664 sys sys 1045501674 3966
+sys/man/8/smtp - 664 sys sys 1049408388 4111
 sys/man/8/snoopy - 664 sys sys 1034009982 3714
 sys/man/8/stats - 664 sys sys 1045059512 4042
 sys/man/8/stub - 664 sys sys 1044830500 943
@@ -5051,11 +5052,11 @@ sys/src/9/ip/igmp.c - 664 sys sys 1047260564 5190
 sys/src/9/ip/il.c - 664 sys sys 1047260564 26943
 sys/src/9/ip/inferno.c - 664 sys sys 1022588098 517
 sys/src/9/ip/ip.c - 664 sys sys 1047951326 15285
-sys/src/9/ip/ip.h - 664 sys sys 1047260722 16078
-sys/src/9/ip/ipaux.c - 664 sys sys 1022588098 12656
+sys/src/9/ip/ip.h - 664 sys sys 1049423191 16080
+sys/src/9/ip/ipaux.c - 664 sys sys 1049423191 12798
 sys/src/9/ip/ipifc.c - 664 sys sys 1048288617 37843
 sys/src/9/ip/ipmux.c - 664 sys sys 1047260566 15362
-sys/src/9/ip/iproute.c - 664 sys sys 1047951327 14767
+sys/src/9/ip/iproute.c - 664 sys sys 1049423192 14763
 sys/src/9/ip/ipv6.c - 664 sys sys 1047951328 14433
 sys/src/9/ip/ipv6.h - 664 sys sys 1022588099 4304
 sys/src/9/ip/loopbackmedium.c - 664 sys sys 1045063513 1651
@@ -9309,7 +9310,7 @@ 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 1049249333 18409
-sys/src/cmd/ndb/dn.c - 664 sys sys 1049249332 25182
+sys/src/cmd/ndb/dn.c - 664 sys sys 1049408473 25198
 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
@@ -9751,7 +9752,7 @@ sys/src/cmd/rc/trap.c - 664 sys sys 944961083 880
 sys/src/cmd/rc/tree.c - 664 sys sys 944961083 1968
 sys/src/cmd/rc/unix.c - 664 sys sys 1045505529 8702
 sys/src/cmd/rc/var.c - 664 sys sys 944961083 1282
-sys/src/cmd/rdbfs.c - 664 sys sys 1045505538 7974
+sys/src/cmd/rdbfs.c - 664 sys sys 1049426950 7952
 sys/src/cmd/read.c - 664 sys sys 1022047660 1278
 sys/src/cmd/replica - 20000000775 sys sys 1018321113 0
 sys/src/cmd/replica/all.h - 664 sys sys 1018323474 1181
@@ -10425,7 +10426,7 @@ 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 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.c - 664 sys sys 1049408234 24269
 sys/src/cmd/upas/smtp/smtpd.h - 664 sys sys 1045505962 1063
 sys/src/cmd/upas/smtp/smtpd.y - 664 sys sys 1043171647 6911
 sys/src/cmd/upas/smtp/spam.c - 664 sys sys 1045505970 9221
@@ -11024,7 +11025,7 @@ sys/src/libc/9sys/privalloc.c - 664 sys sys 984709402 606
 sys/src/libc/9sys/pushssl.c - 664 sys sys 1014927338 905
 sys/src/libc/9sys/pushtls.c - 664 sys sys 1014927338 2009
 sys/src/libc/9sys/putenv.c - 664 sys sys 985023079 398
-sys/src/libc/9sys/qlock.c - 664 sys sys 1048645387 3793
+sys/src/libc/9sys/qlock.c - 664 sys sys 1049426327 5060
 sys/src/libc/9sys/read.c - 664 sys sys 1014927339 108
 sys/src/libc/9sys/read9pmsg.c - 664 sys sys 1014927339 462
 sys/src/libc/9sys/readv.c - 664 sys sys 1014927339 645

+ 23 - 0
dist/replica/plan9.log

@@ -19043,3 +19043,26 @@
 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
 1049304670 0 c sys/man/8/ndb - 664 sys sys 1049303346 9367
+1049378412 0 c 386/bin/ndb/cs - 775 sys sys 1049377481 143599
+1049378412 1 c 386/bin/ndb/dns - 775 sys sys 1049377482 211380
+1049378412 2 c 386/bin/ndb/dnsdebug - 775 sys sys 1049377483 186367
+1049378412 3 c 386/bin/ndb/dnstcp - 775 sys sys 1049377483 185152
+1049378412 4 c 386/bin/upas/smtp - 775 sys sys 1049377485 268184
+1049409044 0 c 386/bin/ndb/dns - 775 sys sys 1049408472 211288
+1049409044 1 c 386/bin/upas/smtpd - 775 sys sys 1049408250 312231
+1049409044 2 c sys/man/8/smtp - 664 sys sys 1049408388 4111
+1049409044 3 c sys/src/cmd/ndb/dn.c - 664 sys sys 1049408473 25198
+1049409044 4 c sys/src/cmd/upas/smtp/smtpd.c - 664 sys sys 1049408234 24269
+1049412648 0 c 386/bin/aux/vmware - 775 sys sys 1049412146 453
+1049413402 0 a rc/bin/service/tcp17010 - 775 sys sys 1049413268 14
+1049423459 0 c sys/src/9/ip/ip.h - 664 sys sys 1049423191 16080
+1049423459 1 c sys/src/9/ip/ipaux.c - 664 sys sys 1049423191 12798
+1049423459 2 c sys/src/9/ip/iproute.c - 664 sys sys 1049423192 14763
+1049426003 0 c sys/include/libc.h - 664 sys sys 1049426002 18829
+1049426331 0 c sys/src/libc/9sys/qlock.c - 664 sys sys 1049426327 5060
+1049426957 0 c sys/src/cmd/rdbfs.c - 664 sys sys 1049426950 7952
+1049428865 0 c 386/bin/aux/vmware - 775 sys sys 1049428256 453
+1049428865 1 c 386/bin/ndb/dns - 775 sys sys 1049428257 211411
+1049428865 2 c 386/bin/ndb/dnsdebug - 775 sys sys 1049428257 186400
+1049428865 3 c 386/bin/ndb/dnstcp - 775 sys sys 1049428258 185185
+1049428865 4 c 386/bin/upas/smtpd - 775 sys sys 1049428259 312341

+ 1 - 0
rc/bin/service/tcp17010

@@ -0,0 +1 @@
+#!/bin/cpu -R

+ 11 - 0
sys/include/libc.h

@@ -429,6 +429,17 @@ extern	void	wlock(RWLock*);
 extern	void	wunlock(RWLock*);
 extern	int		canwlock(RWLock*);
 
+typedef
+struct Rendez
+{
+	QLock *l;
+	QLp	*head;
+	QLp	*tail;
+} Rendez;
+
+extern	void	rsleep(Rendez*);	/* unlocks r->l, sleeps, locks r->l again */
+extern	int	rwakeup(Rendez*);
+extern	int	rwakeupall(Rendez*);
 extern	void**	privalloc(void);
 extern	void	privfree(void**);
 

+ 7 - 0
sys/man/8/smtp

@@ -34,6 +34,9 @@ smtp, smtpd \-  mail transport
 ][
 .B -k
 .I evilipaddr
+][
+.B -c
+.I certfile
 ]
 .SH DESCRIPTION
 .PP
@@ -143,6 +146,10 @@ service attacks or broken mailers which continually
 connect.  The connections are not logged and the
 remote system is not notified via the protocol.
 .TP
+.B -c
+specifies a certificate to use for TLS.  Without this
+option, the capability to start TLS will not be advertised.
+.TP
 .B -a
 requires that all clients authenticate to be able to send mail.
 .TP

+ 1 - 1
sys/src/9/ip/ip.h

@@ -440,10 +440,10 @@ enum
 
 struct Routewalk
 {
-	int	n;
 	int	o;
 	int	h;
 	char*	p;
+	char*	e;
 	void*	state;
 	void	(*walk)(Route*, Routewalk*);
 };

+ 11 - 7
sys/src/9/ip/ipaux.c

@@ -282,13 +282,16 @@ eipfmt(Fmt *f)
 	switch(f->r) {
 	case 'E':		/* Ethernet address */
 		p = va_arg(f->args, uchar*);
-		return fmtprint(f, efmt, p[0], p[1], p[2], p[3], p[4], p[5]);
+		snprint(buf, sizeof buf, efmt, p[0], p[1], p[2], p[3], p[4], p[5]);
+		return fmtstrcpy(f, buf);
 
 	case 'I':		/* Ip address */
 		p = va_arg(f->args, uchar*);
 common:
-		if(memcmp(p, v4prefix, 12) == 0)
-			return fmtprint(f, ifmt, p[12], p[13], p[14], p[15]);
+		if(memcmp(p, v4prefix, 12) == 0){
+			snprint(buf, sizeof buf, ifmt, p[12], p[13], p[14], p[15]);
+			return fmtstrcpy(f, buf);
+		}
 
 		/* find longest elision */
 		eln = eli = -1;
@@ -326,7 +329,8 @@ common:
 
 	case 'V':		/* v4 ip address */
 		p = va_arg(f->args, uchar*);
-		return fmtprint(f, ifmt, p[0], p[1], p[2], p[3]);
+		snprint(buf, sizeof buf, ifmt, p[0], p[1], p[2], p[3]);
+		return fmtstrcpy(f, buf);
 
 	case 'M':		/* ip mask */
 		p = va_arg(f->args, uchar*);
@@ -346,10 +350,10 @@ common:
 			n = 8*16;
 
 		/* got one, use /xx format */
-		return fmtprint(f, "/%d", n);
-
+		snprint(buf, sizeof buf, "/%d", n);
+		return fmtstrcpy(f, buf);
 	}
-	return fmtprint(f, "(eipfmt)");
+	return fmtstrcpy(f, "(eipfmt)");
 }
 
 #define CLASS(p) ((*(uchar*)(p))>>6)

+ 24 - 29
sys/src/9/ip/iproute.c

@@ -617,12 +617,7 @@ routetype(int type, char *p)
 		*p = 'p';
 }
 
-enum
-{
-	Rlinelen=	137,
-};
-
-char *rformat = "%-40.40I %-40.40M %-40.40I %4.4s %4.4s %3s\n";
+char *rformat = "%-15I %-4M %-15I %4.4s %4.4s %3s\n";
 
 void
 convroute(Route *r, uchar *addr, uchar *mask, uchar *gate, char *t, int *nifc)
@@ -658,21 +653,27 @@ convroute(Route *r, uchar *addr, uchar *mask, uchar *gate, char *t, int *nifc)
 static void
 sprintroute(Route *r, Routewalk *rw)
 {
-	int nifc;
+	int nifc, n;
 	char t[5], *iname, ifbuf[5];
 	uchar addr[IPaddrlen], mask[IPaddrlen], gate[IPaddrlen];
+	char *p;
 
-	if(rw->o >= 0) {
-		convroute(r, addr, mask, gate, t, &nifc);
-		iname = "-";
-		if(nifc != -1) {
-			iname = ifbuf;
-			sprint(ifbuf, "%d", nifc);
-		}
-		sprint(rw->p, rformat, addr, mask, gate, t, r->tag, iname);
-		rw->p += Rlinelen;
+	convroute(r, addr, mask, gate, t, &nifc);
+	iname = "-";
+	if(nifc != -1) {
+		iname = ifbuf;
+		sprint(ifbuf, "%d", nifc);
 	}
-	rw->o++;
+	p = seprint(rw->p, rw->e, rformat, addr, mask, gate, t, r->tag, iname);
+	if(rw->o < 0){
+		n = p - rw->p;
+		if(n > -rw->o){
+			memmove(rw->p, rw->p-rw->o, n+rw->o);
+			rw->p = p + rw->o;
+		}
+		rw->o += n;
+	} else
+		rw->p = p;
 }
 
 /*
@@ -683,7 +684,7 @@ rr(Route *r, Routewalk *rw)
 {
 	int h;
 
-	if(rw->n <= rw->o)
+	if(rw->e <= rw->p)
 		return 0;
 	if(r == nil)
 		return 1;
@@ -709,12 +710,12 @@ void
 ipwalkroutes(Fs *f, Routewalk *rw)
 {
 	rlock(&routelock);
-	if(rw->n > rw->o) {
+	if(rw->e > rw->p) {
 		for(rw->h = 0; rw->h < nelem(f->v4root); rw->h++)
 			if(rr(f->v4root[rw->h], rw) == 0)
 				break;
 	}
-	if(rw->n > rw->o) {
+	if(rw->e > rw->p) {
 		for(rw->h = 0; rw->h < nelem(f->v6root); rw->h++)
 			if(rr(f->v6root[rw->h], rw) == 0)
 				break;
@@ -727,20 +728,14 @@ routeread(Fs *f, char *p, ulong offset, int n)
 {
 	Routewalk rw;
 
-	if(offset % Rlinelen)
-		return 0;
-
 	rw.p = p;
-	rw.n = n/Rlinelen;
-	rw.o = -(offset/Rlinelen);
+	rw.e = p+n;
+	rw.o = -offset;
 	rw.walk = sprintroute;
 
 	ipwalkroutes(f, &rw);
 
-	if(rw.o < 0)
-		rw.o = 0;
-
-	return rw.o*Rlinelen;
+	return rw.p - p;
 }
 
 /*

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

@@ -1448,7 +1448,7 @@ syslog(0, logfile, "looking for things in %s %I %I", dom, net, mask);
 	for(i = 0; i < HTLEN; i++){
 		for(dp = ht[i]; dp; dp = dp->next){
 			for(rp = dp->rr; rp; rp = rp->next){
-				if(rp->type != Ta)
+				if(rp->type != Ta || rp->negative)
 					continue;
 				parseip(ip, rp->ip->name);
 				maskip(ip, mask, nnet);

+ 0 - 1
sys/src/cmd/rdbfs.c

@@ -129,7 +129,6 @@ enum
 	Xtext,
 	Xstatus,
 
-	Rendez = 0x89ABCDEF,
 };
 
 int	textfd;

+ 9 - 5
sys/src/cmd/upas/smtp/smtpd.c

@@ -30,7 +30,7 @@ int	sflag;
 int	authenticate;
 int	authenticated;
 int	passwordinclear;
-int	tlsok;
+char	*tlscert;
 
 List senders;
 List rcvers;
@@ -126,11 +126,15 @@ main(int argc, char **argv)
 	case 'p':
 		passwordinclear = 1;
 		break;
+	case 'c':
+		tlscert = ARGF();
+		break;
 	case 't':
-		tlsok = 1;
+		fprint(2, "%s: the -t option is no longer supported, see -c\n", argv0);
+		tlscert = "/sys/lib/ssl/smtpd-cert.pem";
 		break;
 	default:
-		fprint(2, "usage: smtpd [-dfhrs] [-n net]\n");
+		fprint(2, "usage: smtpd [-dfhrs] [-n net] [-c cert]\n");
 		exits("usage");
 	}ARGEND;
 
@@ -257,7 +261,7 @@ hello(String *himp, int extended)
 
 	reply("250%c%s you are %s\r\n", extended ? '-' : ' ', dom, him);
 	if (extended) {
-		if(tlsok)
+		if(tlscert != nil)
 			reply("250-STARTTLS\r\n");
 		if (passwordinclear)		
 			reply("250 AUTH CRAM-MD5 PLAIN LOGIN\r\n");
@@ -1031,7 +1035,7 @@ starttls(void)
 	TLSconn *conn;
 
 	conn = mallocz(sizeof *conn, 1);
-	cert = readcert("/sys/lib/ssl/smtpd-cert.pem", &certlen);
+	cert = readcert(tlscert, &certlen);
 	if (conn == nil || cert == nil) {
 		if (conn != nil)
 			free(conn);

+ 90 - 0
sys/src/libc/9sys/qlock.c

@@ -13,6 +13,7 @@ enum
 	Queuing,
 	QueuingR,
 	QueuingW,
+	Sleeping,
 };
 
 static ulong	(*_rendezvousp)(ulong, ulong) = rendezvous;
@@ -268,3 +269,92 @@ wunlock(RWLock *q)
 	q->writer = 0;
 	unlock(&q->lock);
 }
+
+void
+rsleep(Rendez *r)
+{
+	QLp *t, *me;
+
+	if(!r->l)
+		abort();
+	lock(&r->l->lock);
+	/* we should hold the qlock */
+	if(!r->l->locked)
+		abort();
+
+	/* add ourselves to the wait list */
+	me = getqlp();
+	me->state = Sleeping;
+	if(r->head == nil)
+		r->head = me;
+	else
+		r->tail->next = me;
+	me->next = nil;
+	r->tail = me;
+
+	/* pass the qlock to the next guy */
+	t = r->l->head;
+	if(t){
+		r->l->head = t->next;
+		if(r->l->head == nil)
+			r->l->tail = nil;
+		unlock(&r->l->lock);
+		while((*_rendezvousp)((ulong)t, 0x12345) == ~0)
+			;
+	}else{
+		r->l->locked = 0;
+		unlock(&r->l->lock);
+	}
+
+	/* wait for a wakeup */
+	while((*_rendezvousp)((ulong)me, 1) == ~0)
+		;
+	me->inuse = 0;
+}
+
+int
+rwakeup(Rendez *r)
+{
+	QLp *t;
+
+	/*
+	 * take off wait and put on front of queue
+	 * put on front so guys that have been waiting will not get starved
+	 */
+	
+	if(!r->l)
+		abort();
+	lock(&r->l->lock);
+	if(!r->l->locked)
+		abort();
+
+	t = r->head;
+	if(t == nil){
+		unlock(&r->l->lock);
+		return 0;
+	}
+
+	r->head = t->next;
+	if(r->head == nil)
+		r->tail = nil;
+
+	t->next = r->l->head;
+	r->l->head = t;
+	if(r->l->tail == nil)
+		r->l->tail = t;
+
+	t->state = Queuing;
+	unlock(&r->l->lock);
+	return 1;
+}
+
+int
+rwakeupall(Rendez *r)
+{
+	int i;
+
+	for(i=0; rwakeup(r); i++)
+		;
+	return i;
+}
+