Browse Source

Plan 9 from Bell Labs 2002-12-29

David du Colombier 19 years ago
parent
commit
dc11b8bf6a

+ 5 - 1
acme/mail/src/reply.c

@@ -483,10 +483,14 @@ mesgsend(Message *m)
 	e->p[0] = p[0];
 	e->p[1] = p[1];
 	e->prog = "/bin/upas/marshal";
-	e->argv = emalloc((1+1+4*natt+1)*sizeof(char*));
+	e->argv = emalloc((1+1+2+4*natt+1)*sizeof(char*));
 	e->argv[0] = estrdup("marshal");
 	e->argv[1] = estrdup("-8");
 	j = 2;
+	if(m->replyname){
+		e->argv[j++] = estrdup("-R");
+		e->argv[j++] = estrstrdup(mbox.name, m->replyname);
+	}
 	for(i=0; i<natt; i++){
 		if(included[i])
 			e->argv[j++] = estrdup("-A");

+ 14 - 14
dist/replica/plan9.db

@@ -623,7 +623,7 @@ acme/mail/src/html.c - 664 sys sys 1034016085 1333
 acme/mail/src/mail.c - 664 sys sys 1037034918 10909
 acme/mail/src/mesg.c - 664 sys sys 1037034919 26017
 acme/mail/src/mkfile - 664 sys sys 1037034918 364
-acme/mail/src/reply.c - 664 sys sys 1034949362 11216
+acme/mail/src/reply.c - 664 sys sys 1041137203 11326
 acme/mail/src/util.c - 664 sys sys 1022112164 1391
 acme/mail/src/win.c - 664 sys sys 1033936955 5428
 acme/mkfile - 775 sys sys 1035390142 242
@@ -4421,7 +4421,7 @@ sys/man/1/eqn - 664 sys sys 944959675 5655
 sys/man/1/faces - 664 sys sys 1026845791 1871
 sys/man/1/factor - 664 sys sys 957920005 1019
 sys/man/1/file - 664 sys sys 1015024739 1578
-sys/man/1/filter - 664 sys sys 1034094206 4406
+sys/man/1/filter - 664 sys sys 1041108741 4403
 sys/man/1/fmt - 664 sys sys 1034016352 1471
 sys/man/1/fortune - 664 sys sys 944959673 449
 sys/man/1/freq - 664 sys sys 944959673 735
@@ -4446,7 +4446,7 @@ sys/man/1/lp - 664 sys sys 1015024739 3304
 sys/man/1/ls - 664 sys sys 1027260860 2791
 sys/man/1/mail - 664 sys sys 1035832988 2159
 sys/man/1/man - 664 sys sys 954378836 1611
-sys/man/1/marshal - 664 sys sys 1032237028 2881
+sys/man/1/marshal - 664 sys sys 1041109072 3350
 sys/man/1/mc - 664 sys sys 944959673 509
 sys/man/1/mk - 664 sys sys 964455061 13154
 sys/man/1/mkdir - 664 sys sys 944959673 443
@@ -6354,15 +6354,15 @@ sys/src/cmd/acme/buff.c - 664 sys sys 1014926092 5573
 sys/src/cmd/acme/cols.c - 664 sys sys 1032462024 11122
 sys/src/cmd/acme/dat.h - 664 sys sys 1016833876 10884
 sys/src/cmd/acme/disk.c - 664 sys sys 1014926093 2151
-sys/src/cmd/acme/ecmd.c - 644 sys sys 1016833878 23321
-sys/src/cmd/acme/edit.c - 644 sys sys 1015701171 12055
-sys/src/cmd/acme/edit.h - 644 sys sys 969500816 2466
-sys/src/cmd/acme/elog.c - 644 sys sys 1014926093 5922
+sys/src/cmd/acme/ecmd.c - 664 sys sys 1016833878 23321
+sys/src/cmd/acme/edit.c - 664 sys sys 1015701171 12055
+sys/src/cmd/acme/edit.h - 664 sys sys 969500816 2466
+sys/src/cmd/acme/elog.c - 664 sys sys 1041137125 6081
 sys/src/cmd/acme/exec.c - 664 sys sys 1021579991 26915
 sys/src/cmd/acme/file.c - 664 sys sys 1014926094 5718
 sys/src/cmd/acme/fns.h - 664 sys sys 1035591507 2829
 sys/src/cmd/acme/fsys.c - 664 sys sys 1022512648 12727
-sys/src/cmd/acme/look.c - 664 sys sys 1035591509 14840
+sys/src/cmd/acme/look.c - 664 sys sys 1041137125 14840
 sys/src/cmd/acme/mkfile - 664 sys sys 1035591506 566
 sys/src/cmd/acme/regx.c - 664 sys sys 1014926094 16057
 sys/src/cmd/acme/rows.c - 664 sys sys 1016833877 14726
@@ -8753,7 +8753,7 @@ sys/src/cmd/gzip/mkfile - 664 sys sys 984758036 125
 sys/src/cmd/gzip/unzip.c - 664 sys sys 1014924864 13591
 sys/src/cmd/gzip/zip.c - 664 sys sys 1033183074 7054
 sys/src/cmd/gzip/zip.h - 664 sys sys 954778719 1428
-sys/src/cmd/hget.c - 664 sys sys 1037901368 21488
+sys/src/cmd/hget.c - 664 sys sys 1041067379 21856
 sys/src/cmd/history.c - 664 sys sys 1018721429 4868
 sys/src/cmd/hoc - 20000000775 sys sys 954036932 0
 sys/src/cmd/hoc/code.c - 664 sys sys 944961000 10041
@@ -10152,10 +10152,10 @@ sys/src/cmd/upas/fs/mkfile - 664 sys sys 1036687593 349
 sys/src/cmd/upas/fs/plan9.c - 664 sys sys 1016466465 7461
 sys/src/cmd/upas/fs/pop3.c - 664 sys sys 1014926517 11299
 sys/src/cmd/upas/fs/readdir.c - 664 sys sys 944961331 203
-sys/src/cmd/upas/fs/strtotm.c - 664 sys sys 1037468640 1893
+sys/src/cmd/upas/fs/strtotm.c - 664 sys sys 1041137528 1904
 sys/src/cmd/upas/fs/tester.c - 664 sys sys 985037420 1418
 sys/src/cmd/upas/marshal - 20000000775 sys sys 1015009721 0
-sys/src/cmd/upas/marshal/marshal.c - 664 sys sys 1040307704 30160
+sys/src/cmd/upas/marshal/marshal.c - 664 sys sys 1041137524 30766
 sys/src/cmd/upas/marshal/mkfile - 664 sys sys 1031707318 279
 sys/src/cmd/upas/misc - 20000000775 sys sys 944961318 0
 sys/src/cmd/upas/misc/gone.fishing - 664 sys sys 944961318 313
@@ -10180,7 +10180,7 @@ sys/src/cmd/upas/ml/mlmgr.c - 664 sys sys 1015096762 2211
 sys/src/cmd/upas/ml/mlowner.c - 664 sys sys 1015096763 1142
 sys/src/cmd/upas/ned - 20000000775 sys sys 1015013194 0
 sys/src/cmd/upas/ned/mkfile - 664 sys sys 1031707295 261
-sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1034015577 40176
+sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1041137519 40289
 sys/src/cmd/upas/pop3 - 20000000775 sys sys 1015009816 0
 sys/src/cmd/upas/pop3/mkfile - 664 sys sys 1031707311 214
 sys/src/cmd/upas/pop3/pop3.c - 664 sys sys 1021579996 14144
@@ -10411,10 +10411,10 @@ sys/src/cmd/vnc/proto.c - 664 sys sys 1014925999 4369
 sys/src/cmd/vnc/region.c - 664 sys sys 1014925999 6370
 sys/src/cmd/vnc/region.h - 664 sys sys 1014925999 530
 sys/src/cmd/vnc/rre.c - 664 sys sys 1014925999 11036
-sys/src/cmd/vnc/screen.c - 664 sys sys 1039753059 7424
+sys/src/cmd/vnc/screen.c - 664 sys sys 1041115189 7434
 sys/src/cmd/vnc/screen.h - 664 sys sys 1014926000 880
 sys/src/cmd/vnc/vnc.h - 664 sys sys 1034430143 2616
-sys/src/cmd/vnc/vncs.c - 664 sys sys 1039753062 20594
+sys/src/cmd/vnc/vncs.c - 664 sys sys 1041115188 20831
 sys/src/cmd/vnc/vncs.h - 664 sys sys 1034430144 501
 sys/src/cmd/vnc/vncv.c - 664 sys sys 1034430145 5154
 sys/src/cmd/vnc/vncv.h - 664 sys sys 1014926000 643

+ 15 - 0
dist/replica/plan9.log

@@ -16833,3 +16833,18 @@
 1041013815 0 a n/sourcesdump - 20000000775 sys sys 1041013207 0
 1041013815 1 a n/sourcessnap - 20000000775 sys sys 1041013207 0
 1041013815 2 c rc/bin/9fs - 775 sys sys 1041013198 709
+1041060668 0 m sys/src/cmd/acme/ecmd.c - 664 sys sys 1016833878 23321
+1041060668 1 m sys/src/cmd/acme/edit.c - 664 sys sys 1015701171 12055
+1041060668 2 m sys/src/cmd/acme/edit.h - 664 sys sys 969500816 2466
+1041060668 3 m sys/src/cmd/acme/elog.c - 664 sys sys 1014926093 5922
+1041067878 0 c sys/src/cmd/hget.c - 664 sys sys 1041067379 21856
+1041109292 0 c sys/man/1/filter - 664 sys sys 1041108741 4403
+1041109292 1 c sys/man/1/marshal - 664 sys sys 1041109072 3350
+1041116503 0 c sys/src/cmd/vnc/screen.c - 664 sys sys 1041115189 7434
+1041116503 1 c sys/src/cmd/vnc/vncs.c - 664 sys sys 1041115188 20831
+1041137212 0 c acme/mail/src/reply.c - 664 sys sys 1041137203 11326
+1041137212 1 c sys/src/cmd/acme/elog.c - 664 sys sys 1041137125 6081
+1041137212 2 c sys/src/cmd/acme/look.c - 664 sys sys 1041137125 14840
+1041137557 0 c sys/src/cmd/upas/fs/strtotm.c - 664 sys sys 1041137528 1904
+1041137557 1 c sys/src/cmd/upas/marshal/marshal.c - 664 sys sys 1041137524 30766
+1041137557 2 c sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1041137519 40289

+ 3 - 3
sys/man/1/filter

@@ -1,6 +1,6 @@
 .TH FILTER 1
 .SH NAME
-filter, list, deliver, token, vf \-  filterng mail
+filter, list, deliver, token, vf \-  filtering mail
 .SH SYNOPSIS
 .PP
 .B upas/filter
@@ -159,8 +159,8 @@ using the filter kit can be found in
 .BR /sys/src/cmd/upas/filterkit/pipeto.sample .
 .PP
 A sample
-.BR myupassend ,
-.BR /sys/src/cmd/upas/filterkit/myupassend.sample ,
+.BR pipefrom ,
+.BR /sys/src/cmd/upas/filterkit/pipefrom.sample ,
 is provided which adds all addresses of your outgoing
 mail to your pattern file.
 You should copy it into a directory that normally gets

+ 23 - 1
sys/man/1/marshal

@@ -21,6 +21,9 @@ marshal \- formatting and sending mail
 .I copyaddr
 ]
 [
+.B -R
+.I reply-msg
+[
 .B -nrx#
 ]
 [
@@ -30,7 +33,7 @@ marshal \- formatting and sending mail
 .I Marshal
 builds a mail message from standard input and passes it
 for transmission or delivery to
-.B /bin/myupassend
+.BI /mail/box/ username /pipefrom
 if it exists, otherwise to
 .BR /bin/upas/send .
 The message format is both RFC 822 and
@@ -107,6 +110,25 @@ and also adds
 .I copyaddr
 as a recipient.
 .TP
+.BI -R replymsg
+tells marshal what message this one is in reply to.
+.I Replymsg
+is an
+.IR upas/fs (1)
+directory containing the message.
+.I Marshal
+uses any message id in this message in its
+.B In-Reply-To
+field.  It also passes the directory to
+.BI /mail/box/ username /pipefrom
+in the
+.B replymsg
+environment variable.  Thus,
+.B pipefrom
+can alter the message to somehow match
+the reply to the message it is replying to.
+.TP
+.BI -n
 intentionally no standard input
 .TP
 .B -#xr

+ 21 - 10
sys/src/cmd/acme/elog.c

@@ -218,13 +218,25 @@ elogapply(File *f)
 	Buflog b;
 	Rune *buf;
 	uint i, n, up, mod;
+	uint q0, q1;
 	Buffer *log;
+	Text *t;
 
 	elogflush(f);
 	log = f->elogbuf;
+	t = f->curtext;
 
 	buf = fbufalloc();
 	mod = FALSE;
+
+	/*
+	 * The edit commands have already updated the selection in t->q0, t->q1.
+	 * The textinsert and textdelete calls below will update it again, so save the
+	 * current setting and restore it at the end.
+	 */
+	q0 = t->q0;
+	q1 = t->q1;
+
 	while(log->nc > 0){
 		up = log->nc-Buflogsize;
 		bufread(log, up, (Rune*)&b, Buflogsize);
@@ -239,17 +251,15 @@ elogapply(File *f)
 				mod = TRUE;
 				filemark(f);
 			}
-			textdelete(f->curtext, b.q0, b.q0+b.nd, TRUE);
+			textdelete(t, b.q0, b.q0+b.nd, TRUE);
 			up -= b.nr;
 			for(i=0; i<b.nr; i+=n){
 				n = b.nr - i;
 				if(n > RBUFSIZE)
 					n = RBUFSIZE;
 				bufread(log, up+i, buf, n);
-				textinsert(f->curtext, b.q0+i, buf, n, TRUE);
+				textinsert(t, b.q0+i, buf, n, TRUE);
 			}
-			f->curtext->q0 = b.q0;
-			f->curtext->q1 = b.q0+b.nr;
 			break;
 
 		case Delete:
@@ -257,9 +267,7 @@ elogapply(File *f)
 				mod = TRUE;
 				filemark(f);
 			}
-			textdelete(f->curtext, b.q0, b.q0+b.nd, TRUE);
-			f->curtext->q0 = b.q0;
-			f->curtext->q1 = b.q0;
+			textdelete(t, b.q0, b.q0+b.nd, TRUE);
 			break;
 
 		case Insert:
@@ -273,10 +281,8 @@ elogapply(File *f)
 				if(n > RBUFSIZE)
 					n = RBUFSIZE;
 				bufread(log, up+i, buf, n);
-				textinsert(f->curtext, b.q0+i, buf, n, TRUE);
+				textinsert(t, b.q0+i, buf, n, TRUE);
 			}
-			f->curtext->q0 = b.q0;
-			f->curtext->q1 = b.q0+b.nr;
 			break;
 
 /*		case Filename:
@@ -298,4 +304,9 @@ elogapply(File *f)
 	}
 	fbuffree(buf);
 	elogterm(f);
+
+	t->q0 = q0;
+	t->q1 = q1;
+	if(t->q1 > f->nc)	/* can't happen */
+		t->q1 = f->nc;
 }

+ 1 - 1
sys/src/cmd/acme/look.c

@@ -634,7 +634,7 @@ lookfile(Rune *s, int n)
 			w = c->w[i];
 			t = &w->body;
 			k = t->file->nname;
-			if(k>0 && t->file->name[k-1] == '/')
+			if(k>1 && t->file->name[k-1] == '/')
 				k--;
 			if(runeeq(t->file->name, k, s, n)){
 				w = w->body.file->curtext->w;

+ 21 - 0
sys/src/cmd/hget.c

@@ -3,6 +3,7 @@
 #include <ctype.h>
 #include <bio.h>
 #include <ip.h>
+#include <libsec.h>
 
 typedef struct URL URL;
 struct URL
@@ -27,6 +28,7 @@ struct Range
 enum
 {
 	Http,
+	Https,
 	Ftp,
 	Other
 };
@@ -66,6 +68,7 @@ struct {
 	int	(*f)(URL*, Range*, int, long);
 } method[] = {
 	[Http]	{ "http",	dohttp },
+	[Https]	{ "https",	dohttp },
 	[Ftp]	{ "ftp",	doftp },
 	[Other]	{ "_______",	nil },
 };
@@ -307,6 +310,24 @@ dohttp(URL *u, Range *r, int out, long mtime)
 		if(fd < 0)
 			return Error;
 
+		if(u->method == Https){
+			int tfd;
+			TLSconn conn;
+
+			memset(&conn, 0, sizeof conn);
+			tfd = tlsClient(fd, &conn);
+			if(tfd < 0){
+				fprint(2, "tlsClient: %r\n");
+				close(fd);
+				return Error;
+			}
+			/* BUG: check cert here? */
+			if(conn.cert)
+				free(conn.cert);
+			close(fd);
+			fd = tfd;
+		}
+
 		/* write request, use range if not start of file */
 		if(u->postbody == nil){
 			dfprint(fd,	"GET %s HTTP/1.0\r\n"

+ 1 - 1
sys/src/cmd/upas/fs/strtotm.c

@@ -95,7 +95,7 @@ strtotm(char *p, Tm *tmp)
 			continue;
 		}
 		if(strspn(p, "0123456789") == q-p){
-			j = atoi(p);
+			j = strtol(p, nil, 10);
 			if(1 <= j && j <= 31)
 				tm.mday = j;
 			if(j >= 1900)

+ 34 - 2
sys/src/cmd/upas/marshal/marshal.c

@@ -95,6 +95,7 @@ int	printfrom(Biobuf*);
 int	printto(Biobuf*, Addr*);
 int	printcc(Biobuf*, Addr*);
 int	printsubject(Biobuf*, char*);
+int	printinreplyto(Biobuf*, char*);
 int	sendmail(Addr*, Addr*, int*, char*);
 void	attachment(Attach*, Biobuf*);
 int	cistrncmp(char*, char*, int);
@@ -125,6 +126,7 @@ char *login;
 Alias *aliases;
 int rfc822syntaxerror;
 char lastchar;
+char *replymsg;
 
 enum
 {
@@ -139,7 +141,7 @@ enum
 void
 usage(void)
 {
-	fprint(2, "usage: %s [-Fr#xn] [-s subject] [-c ccrecipient] [-t type] [-aA attachment] [-p[es]] -8 | recipient-list\n",
+	fprint(2, "usage: %s [-Fr#xn] [-s subject] [-c ccrecipient] [-t type] [-aA attachment] [-p[es]] [-R replymsg] -8 | recipient-list\n",
 		argv0);
 	exits("usage");
 }
@@ -215,6 +217,9 @@ main(int argc, char **argv)
 			usage();
 		ccargc++;
 		break;
+	case 'R':
+		replymsg = ARGF();
+		break;
 	case 's':
 		subject = ARGF();
 		break;
@@ -349,6 +354,9 @@ main(int argc, char **argv)
 	if((flags & (1<<Hsubject)) == 0 && subject != nil)
 		if(printsubject(&out, subject) < 0)
 			fatal("writing");
+	if(replymsg != nil)
+		if(printinreplyto(&out, replymsg) < 0)
+			fatal("writing");
 	Bprint(&out, "MIME-Version: 1.0\n");
 
 	if(pgpflag){	// interpose pgp process between us and sendmail to handle body
@@ -743,6 +751,27 @@ printsubject(Biobuf *b, char *subject)
 	return Bprint(b, "Subject: %s\n", subject);
 }
 
+int
+printinreplyto(Biobuf *out, char *dir)
+{
+	String *s = s_copy(dir);
+	char buf[256];
+	int fd;
+	int n;
+
+	s_append(s, "/messageid");
+	fd = open(s_to_c(s), OREAD);
+	s_free(s);
+	if(fd < 0)
+		return 0;
+	n = read(fd, buf, sizeof(buf)-1);
+	close(fd);
+	if(n <= 0)
+		return 0;
+	buf[n] = 0;
+	return Bprint(out, "In-Reply-To: %s\n", buf);
+}
+
 Attach*
 mkattach(char *file, char *type, int inline)
 {
@@ -937,7 +966,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr)
 
 	if(pipe(pfd) < 0)
 		fatal("%r");
-	switch(*pid = fork()){
+	switch(*pid = rfork(RFFDG|RFREND|RFPROC|RFENVG)){
 	case -1:
 		fatal("%r");
 		break;
@@ -970,6 +999,9 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr)
 			}
 		}
 
+		if(replymsg != nil)
+			putenv("replymsg", replymsg);
+
 		cmd = mboxpath("pipefrom", user, s_new(), 0);
 		exec(s_to_c(cmd), av);
 		exec("/bin/myupassend", av);

+ 6 - 0
sys/src/cmd/upas/ned/nedmail.c

@@ -1620,6 +1620,7 @@ rcmd(Cmd *c, Message *m)
 	Message *nm;
 	char *addr;
 	String *path = nil;
+	String *rpath;
 	String *subject = nil;
 	String *from;
 
@@ -1654,6 +1655,10 @@ rcmd(Cmd *c, Message *m)
 		}
 	}
 
+	av[ai++] = "-R";
+	rpath = rooted(s_clone(m->path));
+	av[ai++] = s_to_c(rpath);
+
 	if(strchr(c->av[0], 'f') != nil){
 		fcmd(c, m);
 		av[ai++] = "-F";
@@ -1675,6 +1680,7 @@ rcmd(Cmd *c, Message *m)
 	if(tomailer(av) < 0)
 		m = nil;
 	s_free(path);
+	s_free(rpath);
 	s_free(subject);
 	s_free(from);
 	return m;

+ 2 - 2
sys/src/cmd/vnc/screen.c

@@ -196,8 +196,8 @@ cursordraw(Memimage *dst, Rectangle r)
 		loadmemimage(cursorclear, cursorr, clr, CURSORDIM*CURSORDIM/8);
 	}else
 		unlock(&cursor);
-	memimagedraw(dst, r, memwhite, ZP, cursorclear, ZP, S);
-	memimagedraw(dst, r, curscol, ZP, cursorset, ZP, S);
+	memimagedraw(dst, r, memwhite, ZP, cursorclear, ZP, SoverD);
+	memimagedraw(dst, r, curscol, ZP, cursorset, ZP, SoverD);
 }
 
 /*

+ 9 - 1
sys/src/cmd/vnc/vncs.c

@@ -928,7 +928,7 @@ main(int argc, char * argv[])
 {
 	static char *defargv[] = { "/bin/rc", "-i", nil };
 	char *addr, netmt[NETPATHLEN], adir[NETPATHLEN], ldir[NETPATHLEN], *p, *darg, *karg, *pem;
-	int cfd, s, n, fd, w, h, vncport;
+	int cfd, s, n, fd, ffd, w, h, vncport;
 	TLSconn *conn;
 
 	vncport = 5900;
@@ -1036,6 +1036,14 @@ main(int argc, char * argv[])
 		sysfatal("can't fork: %r");
 		break;
 	case 0:
+		/* On a cpuserver, we need to use bootes factotum
+		 * to talk to the auth server.
+		*/
+		ffd = open("/srv/factotum", ORDWR);
+		if(ffd < 0) 
+			sysfatal("can't open bootes factotum: %r\n");
+		mount(ffd, -1, "/mnt", MBEFORE, "");
+
 		if(!mounter("/dev", MBEFORE, fd, n))
 			exits("errors");
 		close(exportfd);