Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2006/0410/3

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


upas/smtp: move greylist files into /mail/grey/tmp, /mail/grey/whitelist
	change whitelist format to be more tool-friendly
 [rsc] --rw-rw-r-- M 628694 presotto sys 6514 Apr 10 11:41 sys/src/cmd/upas/smtp/greylist.c
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/upas/smtp/greylist.c:23,39 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/upas/smtp/greylist.c:23,39
	  enum {
	  	Nonspammax = 14*60*60,  /* must call back within this time if real */
	  };
	- static char whitelist[] = "/mail/lib/whitelist";
	+ static char whitelist[] = "/mail/grey/whitelist";
	  
	  /*
	   * matches ip addresses or subnets in whitelist against nci->rsys.
	-  * ignores comments and blank lines in /mail/lib/whitelist.
	+  * ignores comments and blank lines in /mail/grey/whitelist.
	   */
	  static int
	  onwhitelist(void)
	  {
	  	int lnlen;
	- 	char *line, *parse;
	+ 	char *line, *parse, *p;
	  	char input[128];
	  	uchar ip[IPaddrlen], ipmasked[IPaddrlen];
	  	uchar mask4[IPaddrlen], addr4[IPaddrlen];
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/upas/smtp/greylist.c:52,66 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/upas/smtp/greylist.c:52,70
	  	if (wl == nil)
	  		return 1;
	  	while ((line = Brdline(wl, '\n')) != nil) {
	- 		if (line[0] == '#' || line[0] == '\n')
	- 			continue;
	  		lnlen = Blinelen(wl);
	  		line[lnlen-1] = '\0';		/* clobber newline */
	  
	+ 		p = strpbrk(line, " \t");
	+ 		if (p)
	+ 			*p = 0;
	+ 		if (line[0] == '#' || line[0] == 0)
	+ 			continue;
	+ 		
	  		/* default mask is /32 (v4) or /128 (v6) for bare IP */
	  		parse = line;
	  		if (strchr(line, '/') == nil) {
	- 			strncpy(input, line, sizeof input - 5);
	+ 			strecpy(input, input+sizeof input-5, line);
	  			if (strchr(line, '.') != nil)
	  				strcat(input, "/32");
	  			else
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/upas/smtp/greylist.c:219,225 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/upas/smtp/greylist.c:223,229
	  		user++;
	  
	  	/* check & try to update the grey list entry */
	- 	snprint(file, sizeof file, "/mail/grey/%s/%s/%s",
	+ 	snprint(file, sizeof file, "/mail/grey/tmp/%s/%s/%s",
	  		nci->lsys, nci->rsys, user);
	  	memset(gsp, 0, sizeof *gsp);
	  	addgreylist(file, gsp);
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/upas/smtp/greylist.c:259,267 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/upas/smtp/greylist.c:263,271
	  		if (fd >= 0) {
	  			seek(fd, 0, 2);			/* paranoia */
	  			if ((fqdn = csgetvalue(nil, "ip", nci->rsys, "dom", nil)) != nil)
	- 				fprint(fd, "# %s\n%s\n\n", fqdn, nci->rsys);
	+ 				fprint(fd, "%s %s\n", nci->rsys, fqdn);
	  			else
	- 				fprint(fd, "# unknown\n%s\n\n", nci->rsys);
	+ 				fprint(fd, "%s\n", nci->rsys);
	  			close(fd);
	  		}
	  	} else {
 [rsc] --rw-rw-r-- M 628694 rsc sys 2813 Apr 10 11:35 dist/replica/plan9.proto
	/n/sourcesdump/2006/0410/plan9/dist/replica/plan9.proto:14,20 - 
	/n/sourcesdump/2006/0411/plan9/dist/replica/plan9.proto:14,22
	  	faxoutqueue	d777 upas upas
	  	faxqueue	d777 upas upas
	  		*	- upas upas
	- 	grey	d777 upas upas
	+ 	grey	d775 upas upas
	+ 		whitelist a666 upas upas
	+ 		tmp	d777 upas upas
	  	fs	- upas upas
	  	lib	- upas upas
	  		+	- upas upas


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.