Browse Source

Plan 9 from Bell Labs 2003-03-05

David du Colombier 21 years ago
parent
commit
7a4bf1fb9b

+ 22 - 22
dist/replica/plan9.db

@@ -340,7 +340,7 @@
 386/bin/rio - 775 sys sys 1046368790 302875
 386/bin/rm - 775 sys sys 1045538047 60036
 386/bin/rtstats - 775 sys sys 1045538048 177343
-386/bin/rx - 775 sys sys 1045538048 78437
+386/bin/rx - 775 sys sys 1046779554 78861
 386/bin/sam - 775 sys sys 1045538049 156896
 386/bin/scat - 775 sys sys 1045538050 282041
 386/bin/scp - 775 sys sys 1046656918 159647
@@ -394,24 +394,24 @@
 386/bin/unmount - 775 sys sys 1039758599 37108
 386/bin/unzip - 775 sys sys 1045538067 90110
 386/bin/upas - 20000000775 sys sys 1016857390 0
-386/bin/upas/aliasmail - 775 sys sys 1045538067 100882
+386/bin/upas/aliasmail - 775 sys sys 1046779554 100889
 386/bin/upas/deliver - 775 sys sys 1045538067 68848
-386/bin/upas/filter - 775 sys sys 1045538068 145562
-386/bin/upas/fs - 775 sys sys 1045538069 326385
+386/bin/upas/filter - 775 sys sys 1046779555 145569
+386/bin/upas/fs - 775 sys sys 1046779556 326392
 386/bin/upas/list - 775 sys sys 1045538069 81422
-386/bin/upas/marshal - 775 sys sys 1045538070 128508
-386/bin/upas/ml - 775 sys sys 1045538070 118096
-386/bin/upas/mlmgr - 775 sys sys 1045538070 100993
-386/bin/upas/mlowner - 775 sys sys 1045538071 92134
-386/bin/upas/nedmail - 775 sys sys 1045538071 148496
-386/bin/upas/pop3 - 775 sys sys 1045538072 251655
-386/bin/upas/qer - 775 sys sys 1045538073 98523
+386/bin/upas/marshal - 775 sys sys 1046779557 128515
+386/bin/upas/ml - 775 sys sys 1046779557 118089
+386/bin/upas/mlmgr - 775 sys sys 1046779558 100986
+386/bin/upas/mlowner - 775 sys sys 1046779558 90400
+386/bin/upas/nedmail - 775 sys sys 1046779559 148503
+386/bin/upas/pop3 - 775 sys sys 1046779561 251662
+386/bin/upas/qer - 775 sys sys 1046779561 98530
 386/bin/upas/ratfs - 775 sys sys 1045538073 112392
-386/bin/upas/runq - 775 sys sys 1045538073 111308
-386/bin/upas/scanmail - 775 sys sys 1045538074 127744
-386/bin/upas/send - 775 sys sys 1045538075 188625
-386/bin/upas/smtp - 775 sys sys 1045538075 264858
-386/bin/upas/smtpd - 775 sys sys 1045538076 307506
+386/bin/upas/runq - 775 sys sys 1046779562 111315
+386/bin/upas/scanmail - 775 sys sys 1046779562 127751
+386/bin/upas/send - 775 sys sys 1046779563 188632
+386/bin/upas/smtp - 775 sys sys 1046779565 264865
+386/bin/upas/smtpd - 775 sys sys 1046779566 307513
 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
@@ -466,7 +466,7 @@
 386/lib - 20000000775 sys sys 1016826328 0
 386/lib/ape - 20000000775 sys sys 944969312 0
 386/lib/ape/lib9.a - 664 sys sys 1038237538 6378
-386/lib/ape/libap.a - 664 sys sys 1046656925 780562
+386/lib/ape/libap.a - 664 sys sys 1046815884 780316
 386/lib/ape/libbsd.a - 664 sys sys 1038237542 171922
 386/lib/ape/libl.a - 664 sys sys 1038237542 8666
 386/lib/ape/libnet.a - 664 sys sys 1038237543 16604
@@ -3231,7 +3231,7 @@ sys/include/ape/select.h - 664 sys sys 944948760 779
 sys/include/ape/setjmp.h - 664 sys sys 944948760 421
 sys/include/ape/signal.h - 664 sys sys 944948760 2619
 sys/include/ape/stddef.h - 664 sys sys 944948759 320
-sys/include/ape/stdio.h - 664 sys sys 1038237536 4869
+sys/include/ape/stdio.h - 664 sys sys 1046815898 4863
 sys/include/ape/stdlib.h - 664 sys sys 1038237536 1680
 sys/include/ape/string.h - 664 sys sys 944948760 1212
 sys/include/ape/sys - 20000000775 sys sys 1014927751 0
@@ -4566,7 +4566,7 @@ sys/man/2/abs - 664 sys sys 944959693 461
 sys/man/2/access - 664 sys sys 1046657167 1102
 sys/man/2/addpt - 664 sys sys 958249501 2964
 sys/man/2/aes - 664 sys sys 1032058672 997
-sys/man/2/allocimage - 664 sys sys 984709630 7300
+sys/man/2/allocimage - 664 sys sys 1046787977 7304
 sys/man/2/arg - 664 sys sys 1030711189 2154
 sys/man/2/arith3 - 664 sys sys 969499887 4397
 sys/man/2/assert - 664 sys sys 960089153 371
@@ -5949,7 +5949,7 @@ sys/src/ape/lib/ap/stdio/fputs.c - 664 sys sys 1014921982 137
 sys/src/ape/lib/ap/stdio/fread.c - 664 sys sys 1038237530 667
 sys/src/ape/lib/ap/stdio/freopen.c - 664 sys sys 1033135391 1517
 sys/src/ape/lib/ap/stdio/fscanf.c - 664 sys sys 1014921982 192
-sys/src/ape/lib/ap/stdio/fseek.c - 664 sys sys 1038237531 422
+sys/src/ape/lib/ap/stdio/fseek.c - 664 sys sys 1046815860 416
 sys/src/ape/lib/ap/stdio/fsetpos.c - 664 sys sys 1014921982 128
 sys/src/ape/lib/ap/stdio/ftell.c - 664 sys sys 1038237532 317
 sys/src/ape/lib/ap/stdio/ftoa.c - 664 sys sys 1014921982 951
@@ -7099,7 +7099,7 @@ sys/src/cmd/fossil/9excl.c - 664 sys sys 1042005502 1887
 sys/src/cmd/fossil/9fid.c - 664 sys sys 1045600016 5521
 sys/src/cmd/fossil/9fsys.c - 664 sys sys 1044906157 26913
 sys/src/cmd/fossil/9lstn.c - 664 sys sys 1042005503 2865
-sys/src/cmd/fossil/9p.c - 664 sys sys 1045600099 21080
+sys/src/cmd/fossil/9p.c - 664 sys sys 1046782756 21345
 sys/src/cmd/fossil/9ping.c - 664 sys sys 1042005503 1563
 sys/src/cmd/fossil/9proc.c - 664 sys sys 1045576808 13707
 sys/src/cmd/fossil/9srv.c - 664 sys sys 1045600018 3291
@@ -10403,7 +10403,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 1043171649 18267
 sys/src/cmd/upas/smtp/smtp.h - 664 sys sys 1015013151 1038
-sys/src/cmd/upas/smtp/smtpd.c - 664 sys sys 1045505955 23075
+sys/src/cmd/upas/smtp/smtpd.c - 664 sys sys 1046783570 24124
 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

+ 22 - 0
dist/replica/plan9.log

@@ -18170,3 +18170,25 @@
 1046667674 0 d sys/src/cmd/ssh/authrsafile.c - 664 sys sys 1016466378 0
 1046669474 0 c sys/src/cmd/rx.c - 664 sys sys 1046668081 3266
 1046705484 0 c sys/man/5/remove - 664 sys sys 1046704639 1078
+1046781073 0 c 386/bin/rx - 775 sys sys 1046779554 78861
+1046781073 1 c 386/bin/upas/aliasmail - 775 sys sys 1046779554 100889
+1046781073 2 c 386/bin/upas/filter - 775 sys sys 1046779555 145569
+1046781073 3 c 386/bin/upas/fs - 775 sys sys 1046779556 326392
+1046781073 4 c 386/bin/upas/marshal - 775 sys sys 1046779557 128515
+1046781073 5 c 386/bin/upas/ml - 775 sys sys 1046779557 118089
+1046781073 6 c 386/bin/upas/mlmgr - 775 sys sys 1046779558 100986
+1046781073 7 c 386/bin/upas/mlowner - 775 sys sys 1046779558 90400
+1046781073 8 c 386/bin/upas/nedmail - 775 sys sys 1046779559 148503
+1046781073 9 c 386/bin/upas/pop3 - 775 sys sys 1046779561 251662
+1046781073 10 c 386/bin/upas/qer - 775 sys sys 1046779561 98530
+1046781073 11 c 386/bin/upas/runq - 775 sys sys 1046779562 111315
+1046781073 12 c 386/bin/upas/scanmail - 775 sys sys 1046779562 127751
+1046781073 13 c 386/bin/upas/send - 775 sys sys 1046779563 188632
+1046781073 14 c 386/bin/upas/smtp - 775 sys sys 1046779565 264865
+1046781073 15 c 386/bin/upas/smtpd - 775 sys sys 1046779566 307513
+1046782873 0 c sys/src/cmd/fossil/9p.c - 664 sys sys 1046782756 21345
+1046784674 0 c sys/src/cmd/upas/smtp/smtpd.c - 664 sys sys 1046783570 24124
+1046788274 0 c sys/man/2/allocimage - 664 sys sys 1046787977 7304
+1046817090 0 c 386/lib/ape/libap.a - 664 sys sys 1046815884 780316
+1046817090 1 c sys/include/ape/stdio.h - 664 sys sys 1046815898 4863
+1046817090 2 c sys/src/ape/lib/ap/stdio/fseek.c - 664 sys sys 1046815860 416

+ 1 - 1
sys/include/ape/stdio.h

@@ -110,7 +110,7 @@ extern int ungetc(int, FILE *);
 extern size_t fread(void *, size_t, size_t, FILE *);
 extern size_t fwrite(const void *, size_t, size_t, FILE *);
 extern int fgetpos(FILE *, fpos_t *);
-extern long long fseek(FILE *, long long, int);
+extern int fseek(FILE *, long long, int);
 extern int fsetpos(FILE *, const fpos_t *);
 extern long long ftell(FILE *);
 extern void rewind(FILE *);

+ 2 - 2
sys/man/2/allocimage

@@ -266,7 +266,7 @@ equals
 .B Cloadimage
 does the same as
 .IR loadimage ,
-bu tfor
+but for
 .I ndata
 bytes of compressed image
 .I data
@@ -288,7 +288,7 @@ and
 return the number of bytes copied.
 .PP
 .I Readimage
-creates a image from data contained an external file (see
+creates an image from data contained in an external file (see
 .IR image (6)
 for the file format);
 .I fd

+ 1 - 1
sys/src/ape/lib/ap/stdio/fseek.c

@@ -2,7 +2,7 @@
  * pANS stdio -- fseek
  */
 #include "iolib.h"
-long long fseek(FILE *f, long long offs, int type){
+int fseek(FILE *f, long long offs, int type){
 	switch(f->state){
 	case ERR:
 	case CLOSED:

+ 9 - 1
sys/src/cmd/fossil/9p.c

@@ -116,7 +116,7 @@ rTwstat(Msg* m)
 {
 	Dir dir;
 	Fid *fid;
-	ulong mode;
+	ulong mode, oldmode;
 	DirEntry de;
 	char *gid, *strs, *uid;
 	int gl, op, retval, tsync;
@@ -242,6 +242,14 @@ rTwstat(Msg* m)
 	}
 
 	if(dir.length != ~0){
+		/*
+		 * Cannot change length on append-only files.
+		 * If we're changing the append bit, it's okay.
+		 */
+		if((de.mode & ModeAppend) && (oldmode & ModeAppend)){
+			vtSetError("wstat -- attempt to change length of append-only file");
+			goto error;
+		}
 		if(de.mode & ModeDir){
 			vtSetError("wstat -- attempt to change length of directory");
 			goto error;

+ 65 - 18
sys/src/cmd/upas/smtp/smtpd.c

@@ -30,6 +30,7 @@ int	sflag;
 int	authenticate;
 int	authenticated;
 int	passwordinclear;
+int	tlsok;
 
 List senders;
 List rcvers;
@@ -125,6 +126,9 @@ main(int argc, char **argv)
 	case 'p':
 		passwordinclear = 1;
 		break;
+	case 't':
+		tlsok = 1;
+		break;
 	default:
 		fprint(2, "usage: smtpd [-dfhrs] [-n net]\n");
 		exits("usage");
@@ -253,7 +257,8 @@ hello(String *himp, int extended)
 
 	reply("250%c%s you are %s\r\n", extended ? '-' : ' ', dom, him);
 	if (extended) {
-		reply("250-STARTTLS\r\n");
+		if(tlsok)
+			reply("250-STARTTLS\r\n");
 		if (passwordinclear)		
 			reply("250 AUTH CRAM-MD5 PLAIN LOGIN\r\n");
 		else
@@ -280,7 +285,9 @@ sender(String *path)
 		reply("503 Start by saying HELO, please.\r\n", s_to_c(path));
 		return;
 	}
-	if(strchr(s_to_c(path), '!') == 0){
+
+	/* don't add the domain onto black holes or we will loop */
+	if(strchr(s_to_c(path), '!') == 0 && strcmp(s_to_c(path), "/dev/null") != 0){
 		s = s_new();
 		s_append(s, him);
 		s_append(s, "!");
@@ -673,6 +680,46 @@ getaddr(Node *p)
 	return nil;
 }
 
+/*
+ *  add waring headers of the form
+ *	X-warning: <reason>
+ *  for any headers that looked like they might be forged.
+ *
+ *  return byte count of new headers
+ */
+static int
+forgedheaderwarnings(void)
+{
+	int nbytes;
+	Field *f;
+
+	nbytes = 0;
+
+	/* warn about envelope sender */
+	if(strcmp(s_to_c(senders.last->p), "/dev/null") != 0 && masquerade(senders.last->p, nil))
+		nbytes += Bprint(pp->std[0]->fp, "X-warning: suspect envelope domain\n");
+
+	/*
+	 *  check Sender: field.  If it's OK, ignore the others because this is an
+	 *  exploded mailing list.
+	 */
+	for(f = firstfield; f; f = f->next){
+		if(f->node->c == SENDER){
+			if(masquerade(getaddr(f->node), him))
+				nbytes += Bprint(pp->std[0]->fp, "X-warning: suspect Sender: domain\n");
+			else
+				return nbytes;
+		}
+	}
+
+	/* check From: */
+	for(f = firstfield; f; f = f->next){
+		if(f->node->c == FROM && masquerade(getaddr(f->node), him))
+			nbytes += Bprint(pp->std[0]->fp, "X-warning: suspect From: domain\n");
+	}
+	return nbytes;
+}
+
 /*
  *  pipe message to mailer with the following transformations:
  *	- change \r\n into \n.
@@ -742,18 +789,11 @@ pipemsg(int *byteswritten)
 	yyparse();
 
 	/*
- 	 *  look for masquerades
+ 	 *  Llook for masquerades.  Let Sender: trump From: to allow mailing list
+	 *  forwarded messages.
 	 */
-	if(fflag){
-		if(masquerade(senders.last->p, nil))
-			nbytes += Bprint(pp->std[0]->fp, "X-warning: suspect envelope domain\n");
-		for(f = firstfield; f; f = f->next){
-			if(f->node->c == FROM && masquerade(getaddr(f->node), him))
-				nbytes += Bprint(pp->std[0]->fp, "X-warning: suspect From: domain\n");
-			if(f->node->c == SENDER && masquerade(getaddr(f->node), him))
-				nbytes += Bprint(pp->std[0]->fp, "X-warning: suspect Sender: domain\n");
-		}
-	}
+	if(fflag)
+		nbytes += forgedheaderwarnings();
 
 	/*
 	 *  add an orginator and/or destination if either is missing
@@ -964,8 +1004,15 @@ s_dec64(String *sin)
 {
 	String *sout;
 	int lin, lout;
-	lin = s_len(sin) - 1;	// strip nl
-	sout = s_newalloc(lin + 1);	// for nul
+	lin = s_len(sin);
+
+	/*
+	 * if the string is coming from smtpd.y, it will have no nl.
+	 * if it is coming from getcrnl below, it will have an nl.
+	 */
+	if (*(s_to_c(sin)+lin-1) == '\n')
+		lin--;
+	sout = s_newalloc(lin+1);
 	lout = dec64((uchar *)s_to_c(sout), lin, s_to_c(sin), lin);
 	if (lout < 0) {
 		s_free(sout);
@@ -1023,6 +1070,8 @@ auth(String *mech, String *resp)
 	if (rejectcheck())
 		goto bomb_out;
 
+	syslog(0, "smtpd", "auth(%s, %s) from %s\n", s_to_c(mech), s_to_c(resp), him);
+
 	if (authenticated) {
 	bad_sequence:
 		rejectcount++;
@@ -1119,7 +1168,7 @@ auth(String *mech, String *resp)
 			reply("501 Cannot decode base64\r\n");
 			goto bomb_out;
 		}
-		// should be of form <user><space><response>
+		/* should be of form <user><space><response> */
 		resp = s_to_c(s_resp1);
 		t = strchr(resp, ' ');
 		if (t == nil) {
@@ -1153,5 +1202,3 @@ bomb_out:
 	if (s_resp2_64)
 		s_free(s_resp2_64);
 }
-
-