ml-bounces was applied too soon. we need a -bounces directory to catch bounces if we're not going to reply on /dev/null to do it. for now, just make the -bounces pipeto eat any bounces. perhaps something more intelligent could be done later. Reference: /n/atom/patch/applied2013/mlmgr-bounces Date: Thu Jul 11 21:45:26 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/upas/ml/mlmgr.c Thu Jul 11 21:44:27 2013 +++ /sys/src/cmd/upas/ml/mlmgr.c Thu Jul 11 21:44:28 2013 @@ -1,14 +1,23 @@ #include "common.h" #include "dat.h" -int cflag; -int aflag; -int rflag; +enum { + Bounces, + Owner, + List, + Nboxes, +}; + +char *suffix[Nboxes] = { +[Bounces] "-bounces", +[Owner] "-owner", +[List] "", +}; int -createpipeto(char *alfile, char *user, char *listname, int owner) +createpipeto(char *alfile, char *user, char *listname, char *dom, int which) { - char buf[Pathlen]; + char buf[Pathlen], rflag[64]; int fd; Dir *d; @@ -28,11 +37,23 @@ fprint(fd, "Couldn't wstat %s: %r\n", buf); free(d); + if(dom != nil) + snprint(rflag, sizeof rflag, "-r%s@%s ", listname, dom); + else + rflag[0] = 0; + fprint(fd, "#!/bin/rc\n"); - if(owner) + switch(which){ + case Owner: fprint(fd, "/bin/upas/mlowner %s %s\n", alfile, listname); - else - fprint(fd, "/bin/upas/ml %s %s\n", alfile, user); + break; + case List: + fprint(fd, "/bin/upas/ml %s%s %s\n", rflag, alfile, user); + break; + case Bounces: + fprint(fd, "exit ''\n"); + break; + } close(fd); return 0; @@ -49,25 +70,24 @@ void main(int argc, char **argv) { - char *listname, *addr, alfile[Pathlen], owner[64]; + char *listname, *dom, *addr, alfile[Pathlen], buf[64], flag[127]; + int i; + rfork(RFENVG|RFREND); + memset(flag, 0, sizeof flag); ARGBEGIN{ case 'c': - cflag = 1; - break; case 'r': - rflag = 1; - break; case 'a': - aflag = 1; + flag[ARGC()] = 1; break; default: usage(); }ARGEND; - if(aflag + rflag + cflag > 1){ + if(flag['a'] + flag['r'] + flag['c'] > 1){ fprint(2, "%s: -a, -r, and -c are mutually exclusive\n", argv0); exits("usage"); } @@ -76,26 +96,26 @@ usage(); listname = argv[0]; + if((dom = strchr(listname, '@')) != nil) + *dom++ = 0; mboxpathbuf(alfile, sizeof alfile, listname, "address-list"); - if(cflag){ - snprint(owner, sizeof owner, "%s-owner", listname); - if(creatembox(listname, nil) < 0) - sysfatal("creating %s's mbox: %r", listname); - if(creatembox(owner, nil) < 0) - sysfatal("creating %s's mbox: %r", owner); - if(createpipeto(alfile, listname, listname, 0) < 0) - sysfatal("creating %s's pipeto: %r", owner); - if(createpipeto(alfile, owner, listname, 1) < 0) - sysfatal("creating %s's pipeto: %r", owner); + if(flag['c']){ + for(i = 0; i < Nboxes; i++){ + snprint(buf, sizeof buf, "%s%s", listname, suffix[i]); + if(creatembox(buf, nil) < 0) + sysfatal("creating %s's mbox: %r", buf); + if(createpipeto(alfile, buf, listname, dom, i) < 0) + sysfatal("creating %s's pipeto: %r", buf); + } writeaddr(alfile, "# mlmgr c flag", 0, listname); - } else if(rflag){ + } else if(flag['r']){ if(argc != 2) usage(); addr = argv[1]; writeaddr(alfile, "# mlmgr r flag", 0, listname); writeaddr(alfile, addr, 1, listname); - } else if(aflag){ + } else if(flag['a']){ if(argc != 2) usage(); addr = argv[1]; --- /sys/man/1/mlmgr Thu Jul 11 21:44:29 2013 +++ /sys/man/1/mlmgr Thu Jul 11 21:44:29 2013 @@ -4,8 +4,11 @@ .SH SYNOPSIS .B upas/mlmgr -c .I listname +[ +.RI @ domain +] .PP -.B upas/mlmgr -ar +.B upas/mlmgr -[ar] .I listname .I address .PP @@ -25,10 +28,11 @@ creates and updates unmoderated mailing lists. The .B -c -option creates mail directories for both -.I listname -and +option creates mail directories for +.IR listname , .IB listname -owner\f1,\fP +and +.IB listname -bounces\f1,\fP each containing a .B pipeto file. @@ -42,10 +46,15 @@ fields are removed from the messages and new ones are added directing replies to -.I listname +.I listname +or +.IR listname @ domain and specifying bulk precedence. The envelope address for error replies is set to -.BR /dev/null . +.IR listname -bounces. +Its +.B pipefile +discards error messages. .PP The mailing list membership is the file .BR /mail/box/\fIlistname\fP/address-list . @@ -118,6 +127,9 @@ .TP .B /mail/box/\fI\fP-owner owner's mailbox directory +.TP +.B /mail/box/\fI\fP-bounces +mailbox directory handling bounces .TP .B /mail/box/\fI\fP/address-list log of mailing list deletions and additions