Browse Source

Plan 9 from Bell Labs 2014-02-04

David du Colombier 10 years ago
parent
commit
e824f70d6b
4 changed files with 36 additions and 8 deletions
  1. 4 0
      sys/man/8/timesync
  2. 14 5
      sys/src/9/ip/ipifc.c
  3. 1 1
      sys/src/9/ip/ipv6.c
  4. 17 2
      sys/src/cmd/upas/smtp/smtpd.c

+ 4 - 0
sys/man/8/timesync

@@ -26,6 +26,8 @@ timesync \- synchronize the system clock to a time source
 synchronizes the system clock to a time source, by default a
 file server.
 The options are:
+.TF -L
+.PD
 .TP
 .B -f
 synchronize to a file server.  If
@@ -108,3 +110,5 @@ where the last frequency guess is kept
 log file
 .SH SOURCE
 .B /sys/src/cmd/aux/timesync.c
+.SH BUGS
+Only works with IPv4.

+ 14 - 5
sys/src/9/ip/ipifc.c

@@ -16,6 +16,7 @@ enum {
 	NHASH		= 1<<6,
 	NCACHE		= 256,
 	QMAX		= 192*1024-1,
+	Maxv6repr	= (128/(4*4))*(4+1), /* limit of xxxx:xxxx:⋯ notation */
 };
 
 Medium *media[Maxmedia] = { 0 };
@@ -1607,7 +1608,7 @@ ipifcadd6(Ipifc *ifc, char**argv, int argc)
 {
 	int plen = 64;
 	long origint = NOW / 1000, preflt = ~0L, validlt = ~0L;
-	char addr[40], preflen[6];
+	char addr[Maxv6repr], preflen[6];
 	char *params[3];
 	uchar autoflag = 1, onlink = 1;
 	uchar prefix[IPaddrlen];
@@ -1635,9 +1636,17 @@ ipifcadd6(Ipifc *ifc, char**argv, int argc)
 		return Ebadarg;
 	}
 
-	if (parseip(prefix, argv[1]) != 6 || validlt < preflt || plen < 0 ||
-	    plen > 64 || islinklocal(prefix))
-		return Ebadarg;
+	if (parseip(prefix, argv[1]) != 6)
+		return "bad ipv6 address";
+	if (validlt < preflt)
+		return "valid ipv6 lifetime less than preferred lifetime";
+	if (plen < 0)
+		return "negative ipv6 prefix length";
+	/* i think that this length limit is bogus - geoff */
+//	if (plen > 64)
+//		return "ipv6 prefix length greater than 64;
+	if (islinklocal(prefix))
+		return "ipv6 prefix is link-local";
 
 	lifc = smalloc(sizeof(Iplifc));
 	lifc->onlink = (onlink != 0);
@@ -1648,7 +1657,7 @@ ipifcadd6(Ipifc *ifc, char**argv, int argc)
 
 	/* issue "add" ctl msg for v6 link-local addr and prefix len */
 	if(!ifc->m->pref2addr)
-		return Ebadarg;
+		return "no pref2addr on interface";
 	ifc->m->pref2addr(prefix, ifc->mac);	/* mac → v6 link-local addr */
 	snprint(addr, sizeof addr, "%I", prefix);
 	snprint(preflen, sizeof preflen, "/%d", plen);

+ 1 - 1
sys/src/9/ip/ipv6.c

@@ -259,7 +259,7 @@ ipiput6(Fs *f, Ipifc *ifc, Block *bp)
 	tentative = iptentative(f, v6dst);
 
 	if(tentative && h->proto != ICMPv6) {
-		print("ipv6 tentative addr %I, drop\n", v6dst);
+		print("ipv6 non-icmp tentative addr %I, drop\n", v6dst);
 		freeblist(bp);
 		return;
 	}

+ 17 - 2
sys/src/cmd/upas/smtp/smtpd.c

@@ -51,6 +51,7 @@ int	rejectcheck(void);
 String*	startcmd(void);
 
 static void	logmsg(char *action);
+static int	delaysecs(void);
 
 static int
 catchalarm(void *a, char *msg)
@@ -199,8 +200,8 @@ main(int argc, char **argv)
 		dom = domainname_read();
 	if(dom == 0 || dom[0] == 0)
 		dom = me;
-	sayhi();
 	parseinit();
+	sayhi();
 
 	/* allow 45 minutes to parse the header */
 	atnotify(catchalarm, 1);
@@ -287,7 +288,20 @@ reset(void)
 void
 sayhi(void)
 {
-	reply("220 %s ESMTP\r\n", dom);
+	Dir *dp;
+
+	reply("220-%s ESMTP\r\n", dom);
+	sleep(3000);
+	dp = dirfstat(0);
+	if (dp && dp->length > 0) {
+		syslog(0, "smtpd", "Hung up on impatient spammer %s", nci->rsys);
+		if(Dflag)
+			sleep(delaysecs()*1000);
+		reply("554 5.7.0 Spammer!\r\n");
+		exits("spammer didn't wait for greeting to finish");
+	}
+	free(dp);
+	reply("220 \r\n");
 }
 
 /*
@@ -1734,3 +1748,4 @@ bomb_out:
 	if (s_resp2_64)
 		s_free(s_resp2_64);
 }
+