commit b5f65921f346e6b4335f77e457ac5bcae0ab9d67 from: rsc date: Sat Feb 11 23:38:55 2006 UTC various cleanup commit - e4d832222ba5519db94c7512c1fb82bd32491120 commit + b5f65921f346e6b4335f77e457ac5bcae0ab9d67 blob - f50c348ab07a49e6da41b215e2de6f7ba1d44315 blob + 626be975595ac37d53597a75a827c99d7ca62a1e --- src/cmd/upas/alias/aliasmail.c +++ src/cmd/upas/alias/aliasmail.c @@ -39,11 +39,10 @@ main(int argc, char *argv[]) namefiles = ARGF(); break; } ARGEND - if (chdir(unsharp(UPASLIB)) < 0) { - perror("translate(chdir):"); - exit9(1); - } + if (chdir(UPASLIB) < 0) + sysfatal("aliasmail chdir %s: %r", UPASLIB); + /* get environmental info */ names = sysnames_read(); files = getdbfiles(); blob - 46695efd8e5193db3a23d16f4a5142e9a0aa5081 blob + 80142deea50ad98ee6ff45a6dcad7e7444976128 --- src/cmd/upas/bayes/dfa.c +++ src/cmd/upas/bayes/dfa.c @@ -3,7 +3,7 @@ #include #include #include -#include "/sys/src/libregexp/regcomp.h" +#include "../../../libregexp/regcomp.h" #include "dfa.h" void rdump(Reprog*); @@ -140,19 +140,19 @@ followempty(Deter *d, uchar *bits, int bol, int eol) switch(i->type){ case RBRA: case LBRA: - again |= add(i->next - d->p->firstinst, bits, k); + again |= add(i->u2.next - d->p->firstinst, bits, k); break; case OR: - again |= add(i->left - d->p->firstinst, bits, k); - again |= add(i->right - d->p->firstinst, bits, k); + again |= add(i->u2.left - d->p->firstinst, bits, k); + again |= add(i->u1.right - d->p->firstinst, bits, k); break; case BOL: if(bol) - again |= add(i->next - d->p->firstinst, bits, k); + again |= add(i->u2.next - d->p->firstinst, bits, k); break; case EOL: if(eol) - again |= add(i->next - d->p->firstinst, bits, k); + again |= add(i->u2.next - d->p->firstinst, bits, k); break; } } @@ -209,27 +209,27 @@ transition(Deter *d, Reiset *s, Rune r, uint eol) longjmp(d->kaboom, 1); case RUNE: - if(r == i->r) - bits[i->next - inst0] = 1; + if(r == i->u1.r) + bits[i->u2.next - inst0] = 1; break; case ANY: if(r != L'\n') - bits[i->next - inst0] = 1; + bits[i->u2.next - inst0] = 1; break; case ANYNL: - bits[i->next - inst0] = 1; + bits[i->u2.next - inst0] = 1; break; case NCCLASS: if(r == L'\n') break; /* fall through */ case CCLASS: - ep = i->cp->end; - for(rp = i->cp->spans; rp < ep; rp += 2) + ep = i->u1.cp->end; + for(rp = i->u1.cp->spans; rp < ep; rp += 2) if(rp[0] <= r && r <= rp[1]) break; if((rp < ep) ^! (i->type == CCLASS)) - bits[i->next - inst0] = 1; + bits[i->u2.next - inst0] = 1; break; case END: break; @@ -290,9 +290,9 @@ findchars(Deter *d, Reprog *p) set(d, tab, L'\n'+1); break; case RUNE: - set(d, tab, i->r-1); - set(d, tab, i->r); - set(d, tab, i->r+1); + set(d, tab, i->u1.r-1); + set(d, tab, i->u1.r); + set(d, tab, i->u1.r+1); break; case NCCLASS: set(d, tab, L'\n'-1); @@ -300,8 +300,8 @@ findchars(Deter *d, Reprog *p) set(d, tab, L'\n'+1); /* fall through */ case CCLASS: - ep = i->cp->end; - for(rp = i->cp->spans; rp < ep; rp += 2){ + ep = i->u1.cp->end; + for(rp = i->u1.cp->spans; rp < ep; rp += 2){ set(d, tab, rp[0]-1); set(d, tab, rp[0]); set(d, tab, rp[1]); blob - c0c546e73a8405ffe5fe595818764a55458e655c blob + 1479995b1476c926faee580529e9ab5fe2c1bb27 --- src/cmd/upas/bayes/mkfile +++ src/cmd/upas/bayes/mkfile @@ -1,18 +1,18 @@ -x && cp x $target blob - 7c450546983f3c004c43edf9fd7eae6563fa2728 blob + 122e0c64606aa22a1e02bca5c3c83d8abbba46d0 --- src/cmd/upas/bayes/msgtok.c +++ src/cmd/upas/bayes/msgtok.c @@ -13,7 +13,7 @@ void buildre(Dreprog*[3]); int debug; -char *refile = "/mail/lib/classify.re"; +char *refile = "#9/mail/lib/classify.re"; int maxtoklen = 20; int trim(char*); @@ -35,6 +35,7 @@ main(int argc, char **argv) char msg[1024+1]; char buf[1024]; + refile = unsharp(refile); buildre(re); ARGBEGIN{ case 'D': blob - 1b5aa4569be8d2af6d9ff8aff90721ea6052fefe (mode 644) blob + /dev/null --- src/cmd/upas/common/become.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "common.h" -#include -#include - -/* - * become powerless user - */ -int -become(char **cmd, char *who) -{ - int fd; - - USED(cmd); - if(strcmp(who, "none") == 0) { - fd = open("#c/user", OWRITE); - if(fd < 0 || write(fd, "none", strlen("none")) < 0) { - werrstr("can't become none"); - return -1; - } - close(fd); - // jpc if(newns("none", 0)) { - // jpc werrstr("can't set new namespace"); - // jpc return -1; - // jpc } - } - return 0; -} - blob - a9d4f0f811341c6312607af5bf9465778440a267 blob + cf56c8693fb4e850f3dda1ffcbf78a5fea1f8fb1 --- src/cmd/upas/common/libsys.c +++ src/cmd/upas/common/libsys.c @@ -454,6 +454,7 @@ sysnames_read(void) if(namev) return namev; +/* XXX */ /* free(csgetvalue(0, "sys", alt_sysname_read(), "dom", &t)); jpc */ db = ndbopen(unsharp("#9/ndb/local")); free(ndbgetvalue(db, &s, "sys", sysname(),"dom", &t)); blob - 33903708a4f6d40e97464c6cce657ef590de8c46 blob + 3b129317f0743d44b1df140c53ef68ab55f11084 --- src/cmd/upas/filterkit/deliver.c +++ src/cmd/upas/filterkit/deliver.c @@ -1,11 +1,12 @@ #include "dat.h" +#include #include "common.h" void usage(void) { fprint(2, "usage: %s recipient fromaddr-file mbox\n", argv0); - exits("usage"); + threadexitsall("usage"); } void blob - 6c23dcc19c19a6f1a427af2a9e345506e4f93c2d blob + 1913c6ded4dc8ef2c19043a4bb0fbcc4598e317f --- src/cmd/upas/filterkit/list.c +++ src/cmd/upas/filterkit/list.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include "dat.h" @@ -188,8 +188,9 @@ readpatterns(char *path) } /* fuck, shit, bugger, damn */ -void regerror(char*) +void regerror(char *err) { + USED(err); } /* blob - c077d56411bd1392db7b4aee235e33aea2b9cd61 blob + 880ede1e2c8a2ecdb230960240b51827a39dc952 --- src/cmd/upas/filterkit/mkfile +++ src/cmd/upas/filterkit/mkfile @@ -1,21 +1,14 @@ - #include #include -#include +#include #include "dat.h" void blob - cfc186c0a8dabd89c7a5a2f399fb4b470414d93b blob + e5c75f7fd40d52186ee7840d41fab876e5ab33d5 --- src/cmd/upas/marshal/marshal.c +++ src/cmd/upas/marshal/marshal.c @@ -1,6 +1,8 @@ #include "common.h" #include +#define inline _inline + typedef struct Attach Attach; typedef struct Alias Alias; typedef struct Addr Addr; @@ -10,7 +12,7 @@ struct Attach { Attach *next; char *path; char *type; - int tinline; + int inline; Ctype *ctype; }; @@ -684,7 +686,7 @@ attachment(Attach *a, Biobuf *out) if(strcmp(a->type, "text/plain") != 0) Bprint(out, "Content-Type: %s\n", a->type); - if(a->tinline){ + if(a->inline){ Bprint(out, "Content-Disposition: inline\n"); } else { p = strrchr(a->path, '/'); @@ -811,7 +813,7 @@ printinreplyto(Biobuf *out, char *dir) } Attach* -mkattach(char *file, char *type, int tinline) +mkattach(char *file, char *type, int inline) { Ctype *c; Attach *a; @@ -829,7 +831,7 @@ mkattach(char *file, char *type, int tinline) a->path = file; a->next = nil; a->type = type; - a->tinline = tinline; + a->inline = inline; a->ctype = nil; if(type != nil){ for(c = ctype; ; c++) @@ -1067,7 +1069,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr) if(pipe(pfd) < 0) fatal("%r"); - switch(*pid = rfork(RFFDG|RFPROC)){ // jpc - removed |RFENVG|RFREND| + switch(*pid = fork()){ case -1: fatal("%r"); break; @@ -1105,7 +1107,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr) cmd = mboxpath("pipefrom", login, s_new(), 0); exec(s_to_c(cmd), av); - exec(unsharp("#9/bin/myupassend"), av); + exec("myupassend", av); exec(unsharp("#9/bin/upas/send"), av); fatal("execing: %r"); break; @@ -1130,6 +1132,7 @@ pgpfilter(int *pid, int fd, int pgpflag) v = av = emalloc(sizeof(char*)*8); ac = 0; v[ac++] = "pgp"; + v[ac++] = "-fat"; /* operate as a filter, generate text */ if(pgpflag & PGPsign) v[ac++] = "-s"; if(pgpflag & PGPencrypt) @@ -1148,8 +1151,10 @@ pgpfilter(int *pid, int fd, int pgpflag) close(pfd[0]); dup(fd, 1); close(fd); + /* add newline to avoid confusing pgp output with 822 headers */ + write(1, "\n", 1); - exec("/bin/upas/pgp", av); + exec("pgp", av); fatal("execing: %r"); break; default: @@ -1314,7 +1319,6 @@ readaliases(void) Alias *a, **l, *first; Addr *addr, **al; String *file, *line, *token; - // jpc - static int already; Sinstack *sp; first = nil; @@ -1747,7 +1751,7 @@ readmimetypes(void) mimetypes[0].ext = ""; } - b = Bopen(unsharp("#9/sys/lib/mimetype"), OREAD); + b = Bopen(unsharp("#9/lib/mimetype"), OREAD); if(b == nil) return; for(;;){ blob - 6913d743e1a9b52044800494e6d15e8d8518240f blob + b079e2d816242f77cec6f1ee33bcba2bafab05a0 --- src/cmd/upas/misc/mail.rc +++ src/cmd/upas/misc/mail.rc @@ -1,4 +1,4 @@ -#!/bin/rc +#!/usr/local/plan9/bin/rc switch($#*){ case 0 exec upas/nedmail blob - 0bbd8a5ab355647dab620b7060a3834d95b782b9 blob + eeb76965b5fe849dd24680031495db743218f9db --- src/cmd/upas/misc/mkfile +++ src/cmd/upas/misc/mkfile @@ -2,24 +2,19 @@ RCFILES=mail.rc\ all:Q: - ; + # installall:Q: install - ; + # -install:V: - cp mail.rc /rc/bin/mail +install safeinstall safeinstallall:V: + cp mail.rc $PLAN9/bin/mail -safeinstall:V: - cp mail.rc /rc/bin/mail - -safeinstallall:V: - cp mail.rc /rc/bin/mail - clean:Q: - ; + # + nuke:V: - rm /rc/bin/mail + rm $PLAN9/bin/mail UPDATE=\ gone.fishing\ blob - ed64f38c439ca03cbf5773d05b430a46c3d288bf (mode 755) blob + /dev/null --- src/cmd/upas/misc/omail.rc +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/rc -switch($#*){ -case 0 - exec upas/edmail -m -} - -switch($1){ -case -F* -m* -f* -r* -p* -e* -c* -D* - exec upas/edmail -m $* -case '-#'* -a* - exec upas/sendmail $* -case * - exec upas/sendmail $* -} blob - 77a3d228ad1413f28264fb31486354360ab7c1b1 blob + de2f03617e432340db27ad2be6eb66e3d35c800f --- src/cmd/upas/misc/qmail +++ src/cmd/upas/misc/qmail @@ -1,6 +1,6 @@ -#!/bin/rc +#!/usr/local/plan9/bin/rc sender=$1 shift addr=$1 shift -qer /mail/queue mail $sender $addr $* && runq /mail/queue /mail/lib/remotemail +qer $PLAN9/mail/queue mail $sender $addr $* && runq $PLAN9/mail/queue $PLAN9/mail/lib/remotemail blob - 312ee58748d80bde6e815aab91935cdf4417ee03 blob + 9059d3f4aabc1a25b0c2f7cab76d17f7f30b0c00 --- src/cmd/upas/misc/remotemail +++ src/cmd/upas/misc/remotemail @@ -1,7 +1,7 @@ -#!/bin/rc +#!/usr/local/plan9/bin/rc shift sender=$1 shift addr=$1 shift -/bin/upas/smtp -g research.research.bell-labs.com $addr $sender $* +upas/smtp -g yourgateway $addr $sender $* blob - fd724eb1e76497bba88f7f448d4c5b7da379e864 blob + a4d1719d767a15c5f17db37b00cb061e70901024 --- src/cmd/upas/misc/rewrite +++ src/cmd/upas/misc/rewrite @@ -2,8 +2,8 @@ pOsTmAsTeR alias postmaster # local mail -[^!@]+ translate "/bin/upas/aliasmail '&'" -local!(.*) >> /mail/box/\1/mbox +[^!@]+ translate "upas/aliasmail '&'" +local!(.*) >> $PLAN9/mail/box/\1/mbox \l!(.*) alias \1 (helix|helix.bell-labs.com)!(.*) alias \2 @@ -17,4 +17,4 @@ local!(.*) >> /mail/box/\1/mbox ([^@]+)@([^@]+) alias \2!\1 # /mail/lib/remotemail will take care of gating to systems we don't know -([^!]*)!(.*) | "/mail/lib/qmail '\s' 'net!\1'" "'\2'" +([^!]*)!(.*) | "$PLAN9/mail/lib/qmail '\s' 'net!\1'" "'\2'" blob - 5142e56f45d3dd97bee0646cc3992839f0596585 blob + 1a3841087d18b1b34eb2ec9588ab8dff6f711540 --- src/cmd/upas/ml/mkfile +++ src/cmd/upas/ml/mkfile @@ -1,4 +1,4 @@ -c1) if(memcmp(s, spat->string, spat->len) == 0) if(!isalt(message, spat->alt)){ - m->sp = s; - m->ep = s + spat->len; + m->s.sp = s; + m->e.ep = s + spat->len; return 1; } } } return 0; } - m->sp = m->ep = 0; + m->s.sp = m->e.ep = 0; if(regexec(p->pat, message, m, 1) == 0) return 0; if(isalt(message, p->alt)) @@ -608,23 +608,23 @@ xprint(int fd, char *type, Resub *m) char *p, *q; int i; - if(m->sp == 0 || m->ep == 0) + if(m->s.sp == 0 || m->e.ep == 0) return; /* back up approx 30 characters to whitespace */ - for(p = m->sp, i = 0; *p && i < 30; i++, p--) + for(p = m->s.sp, i = 0; *p && i < 30; i++, p--) ; while(*p && *p != ' ') p--; p++; /* grab about 30 more chars beyond the end of the match */ - for(q = m->ep, i = 0; *q && i < 30; i++, q++) + for(q = m->e.ep, i = 0; *q && i < 30; i++, q++) ; while(*q && *q != ' ') q++; - fprint(fd, "%s %.*s~%.*s~%.*s\n", type, (int)(m->sp-p), p, (int)(m->ep-m->sp), m->sp, (int)(q-m->ep), m->ep); + fprint(fd, "%s %.*s~%.*s~%.*s\n", type, (int)(m->s.sp-p), p, (int)(m->e.ep-m->s.sp), m->s.sp, (int)(q-m->e.ep), m->e.ep); } enum { blob - 5f0db8556d50d27e5ac57aebab2a7dae82927b3a blob + 630150e65e29115cab96885d67d548d890bd6551 --- src/cmd/upas/scanmail/mkfile +++ src/cmd/upas/scanmail/mkfile @@ -1,4 +1,4 @@ -ep){ + for(cp = message; matchpat(p, cp, m); cp = m->e.ep){ switch(p->action){ case SaveLine: if(vflag) @@ -340,12 +340,12 @@ matcher(char *action, Pattern *p, char *message, Resub case Dump: if(vflag) xprint(2, action, m); - *(m->ep) = 0; + *m->e.ep = 0; if(!tflag){ s = s_new(); s_append(s, sender); s = unescapespecial(s); - syslog(0, "smtpd", "Dumped %s [%s] to %s", s_to_c(s), m->sp, + syslog(0, "smtpd", "Dumped %s [%s] to %s", s_to_c(s), m->s.sp, s_to_c(s_restart(recips))); s_free(s); } @@ -367,17 +367,17 @@ saveline(char *file, char *sender, Resub *rp) int i, c; Biobuf *bp; - if(rp->sp == 0 || rp->ep == 0) + if(rp->s.sp == 0 || rp->e.ep == 0) return; /* back up approx 20 characters to whitespace */ - for(p = rp->sp, i = 0; *p && i < 20; i++, p--) + for(p = rp->s.sp, i = 0; *p && i < 20; i++, p--) ; while(*p && *p != ' ') p--; p++; /* grab about 20 more chars beyond the end of the match */ - for(q = rp->ep, i = 0; *q && i < 20; i++, q++) + for(q = rp->e.ep, i = 0; *q && i < 20; i++, q++) ; while(*q && *q != ' ') q++; blob - e5ea59ad5788f5bdcf96c0d9d316f5b1d14abe38 blob + 48cd4bbfe4649c5ab0078413ba37b4262d5e4587 --- src/cmd/upas/scanmail/testscan.c +++ src/cmd/upas/scanmail/testscan.c @@ -191,11 +191,11 @@ matchaction(Patterns *pp, char *message) p = pp->strings; ret = 0; if(p) - for(cp = message; matcher(name, p, cp, m); cp = m[0].ep) + for(cp = message; matcher(name, p, cp, m); cp = m[0].e.ep) ret++; for(p = pp->regexps; p; p = p->next) - for(cp = message; matcher(name, p, cp, m); cp = m[0].ep) + for(cp = message; matcher(name, p, cp, m); cp = m[0].e.ep) ret++; return ret; } blob - eab6160ca3a00cd874065781e3492c0905860bac blob + 8cee34a0ef2a3a9a5ea6695b9a5d90c2b4022a5a --- src/cmd/upas/send/message.c +++ src/cmd/upas/send/message.c @@ -143,7 +143,7 @@ getstring(Node *p) return s; } -#if 0 /* jpc */ +#if 0 static char *fieldname[] = { [WORD-WORD] "WORD", @@ -172,7 +172,7 @@ static char *fieldname[] = [MAILER-WORD] "MAILER", [BADTOKEN-WORD] "BADTOKEN", }; -#endif /* jpc */ +#endif /* fix 822 addresses */ static void blob - a49fde1762c2aaf323fcda25732192a4f92e7247 blob + 937b318d662f148adcbf9133e7231d2f1197de31 --- src/cmd/upas/send/mkfile +++ src/cmd/upas/send/mkfile @@ -21,22 +21,13 @@ SMOBJ=main.$O\ gateway.$O\ cat_mail.$O\ -LIB=../common/libcommon.av\ - HFILES=send.h\ ../common/common.h\ ../common/sys.h\ -LIB=../common/libcommon.a\ +LIB=../common/libcommon.a -BIN=$PLAN9/bin/upas -UPDATE=\ - mkfile\ - $HFILES\ - ${UOFILES:%.$O=%.c}\ - ${SMOBJ:%.$O=%.c}\ - ${TARG:%=%.c}\ - +BIN=$BIN/upas <$PLAN9/src/mkmany CFLAGS=$CFLAGS -I../common @@ -46,7 +37,6 @@ $O.send: $SMOBJ $OFILES message.$O: ../smtp/y.tab.h ../smtp/y.tab.h ../smtp/rfc822.tab.$O: ../smtp/rfc822.y -# @{ - cd ../smtp - mk rfc822.tab.$O -# } + cd ../smtp + mk rfc822.tab.$O + blob - 4f40b29338b9003991ee364bc2704feff8d202da blob + 2feacbf21d6c0aa180fb16c59f26a8b37e6da002 --- src/cmd/upas/send/rewrite.c +++ src/cmd/upas/send/rewrite.c @@ -131,7 +131,7 @@ getrules(void) String *type; String *file; - file = abspath("rewrite", unsharp(UPASLIB), (String *)0); + file = abspath("rewrite", UPASLIB, (String *)0); rfp = sysopen(s_to_c(file), "r", 0); if(rfp == 0) { rulep = 0; @@ -168,7 +168,7 @@ findrule(String *addrp, int authorized) continue; memset(rp->subexp, 0, sizeof(rp->subexp)); if(debug) - print("matching %s aginst %s\n", s_to_c(addrp), rp->matchre->base); + fprint(2, "matching %s aginst %s\n", s_to_c(addrp), rp->matchre->base); if(regexec(rp->program, s_to_c(addrp), rp->subexp, NSUBEXP)) if(s_to_c(addrp) == rp->subexp[0].s.sp) if((s_to_c(addrp) + strlen(s_to_c(addrp))) == rp->subexp[0].e.ep) @@ -203,15 +203,43 @@ rewrite(dest *dp, message *mp) dp->repl2 = substitute(rp->repl2, rp->subexp, mp); dp->status = rp->type; if(debug){ - print("\t->"); + fprint(2, "\t->"); if(dp->repl1) - print("%s", s_to_c(dp->repl1)); + fprint(2, "%s", s_to_c(dp->repl1)); if(dp->repl2) - print("%s", s_to_c(dp->repl2)); - print("\n"); + fprint(2, "%s", s_to_c(dp->repl2)); + fprint(2, "\n"); } s_free(lower); return 0; +} + +/* stolen from rc/lex.c */ +static int +idchr(int c) +{ + return c>' ' && !strchr("!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", c); +} + +static char* +getrcvar(char* p, char** rv) +{ + char* p0; + char buf[128]; + char* bufe; + + *rv = 0; + p0=p; + bufe=buf+sizeof buf-1; + while(prsys. @@ -40,11 +40,11 @@ onwhitelist(void) uchar mask[IPaddrlen], addr[IPaddrlen], addrmasked[IPaddrlen]; Biobuf *wl; static int beenhere; - static allzero[IPaddrlen]; if (!beenhere) { beenhere = 1; fmtinstall('I', eipfmt); + whitelist = unsharp(whitelist); } parseip(ip, nci->rsys); @@ -219,8 +219,8 @@ isrcptrecent(char *rcpt) user++; /* check & try to update the grey list entry */ - snprint(file, sizeof file, "/mail/grey/%s/%s/%s", - nci->lsys, nci->rsys, user); + snprint(file, sizeof file, "%s/mail/grey/%s/%s/%s", + get9root(), nci->lsys, nci->rsys, user); memset(gsp, 0, sizeof *gsp); addgreylist(file, gsp); @@ -258,10 +258,7 @@ vfysenderhostok(void) 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); - else - fprint(fd, "# unknown\n%s\n\n", nci->rsys); + fprint(fd, "# %s\n%s\n\n", fqdn, nci->rsys); close(fd); } } else { blob - 722f1357b364678cf8dd2920c1e2a1ec7f52a53b blob + c4c7e05332923c615743ef0c6e7d2da381621991 --- src/cmd/upas/smtp/mkfile +++ src/cmd/upas/smtp/mkfile @@ -1,12 +1,12 @@ <$PLAN9/src/mkhdr -TARG = # smtpd\ +TARG=\ smtp\ + smtpd\ OFILES= -LIB=../common/libcommon.a\ - $PLAN9/lib/libthread.a # why do i have to explicitly put this? +LIB=../common/libcommon.a HFILES=../common/common.h\ ../common/sys.h\ @@ -27,7 +27,7 @@ UPDATE=\ ${TARG:%=%.c}\ <$PLAN9/src/mkmany -CFLAGS=$CFLAGS -I../common -D'SPOOL="/mail"' +CFLAGS=$CFLAGS -I../common -D'SPOOL="'$PLAN9'/mail"' $O.smtpd: smtpd.tab.$O rmtdns.$O spam.$O rfc822.tab.$O greylist.$O $O.smtp: rfc822.tab.$O mxdial.$O @@ -37,7 +37,7 @@ smtpd.$O: smtpd.h smtp.$O to.$O: smtp.h smtpd.tab.c: smtpd.y smtpd.h - yacc -o xxx smtpd.y + 9 yacc -o xxx smtpd.y sed 's/yy/zz/g' < xxx > $target rm xxx @@ -47,8 +47,6 @@ rfc822.tab.c: rfc822.y smtp.h clean:V: rm -f *.[$OS] [$OS].$TARG smtpd.tab.c rfc822.tab.c y.tab.? y.debug $TARG -../common/libcommon.a$O: - @{ - cd ../common - mk - } +../common/libcommon.a + cd ../common; mk + blob - aea5f2566f6e6992bec36461dc60fe655cf7c7d9 blob + 13f40ab540778efe7a33f481a7442fb2493880dd --- src/cmd/upas/smtp/mxdial.c +++ src/cmd/upas/smtp/mxdial.c @@ -1,6 +1,7 @@ #include "common.h" #include #include "smtp.h" /* to publish dial_string_parse */ +#include enum { @@ -42,12 +43,18 @@ mxdial(char *addr, char *ddomain, char *gdomain) /* try our mail gateway */ rerrstr(err, sizeof(err)); - if(fd < 0 && gdomain && strstr(err, "can't translate") != 0) { - fprint(2,"dialing %s\n",gdomain); + if(fd < 0 && gdomain && strstr(err, "can't translate") != 0) fd = dial(netmkaddr(gdomain, 0, "smtp"), 0, 0, 0); - } return fd; +} + +static int +timeout(void*, char *msg) +{ + if(strstr(msg, "alarm")) + return 1; + return 0; } /* @@ -92,7 +99,11 @@ callmx(DS *ds, char *dest, char *domain) mx[i].host, ds->service); if(debug) fprint(2, "mxdial trying %s\n", addr); + atnotify(timeout, 1); + alarm(10*1000); fd = dial(addr, 0, 0, 0); + alarm(0); + atnotify(timeout, 0); if(fd >= 0) return fd; } @@ -316,6 +327,7 @@ expand_meta(DS *ds) } #endif /* jpc */ +/* XXX */ static void expand_meta(DS *ds) { blob - e88154f78a2ae2ec215a72aeb575949cafb1f7da blob + fb00cd5f5f99014d5fb2acb596609c4c0eee9077 --- src/cmd/upas/smtp/smtp.c +++ src/cmd/upas/smtp/smtp.c @@ -171,7 +171,7 @@ threadmain(int argc, char **argv) if(*argv == 0) usage(); addr = *argv++; argc--; - // expand $smtp if necessary + // expand $smtp if necessary XXX addr = expand_addr(addr); farend = addr; @@ -202,12 +202,12 @@ threadmain(int argc, char **argv) exits(0); } - /* 10 minutes to get through the initial handshake */ - atnotify(timeout, 1); - - alarm(10*alarmscale); + /* mxdial uses its own timeout handler */ if((rv = connect(addr)) != 0) exits(rv); + + /* 10 minutes to get through the initial handshake */ + atnotify(timeout, 1); alarm(10*alarmscale); if((rv = hello(hellodomain, 0)) != 0) goto error; @@ -1097,6 +1097,7 @@ dBputc(int x) return Bputc(&bout, x); } +/* XXX */ char* expand_addr(char* a) { blob - 7042c37c3bf3b21105adf9408a1c05bb8b198b4c blob + 8bd4511d28d80934fd206200143df8b7ac59e530 --- src/cmd/upas/smtp/smtpd.c +++ src/cmd/upas/smtp/smtpd.c @@ -157,7 +157,7 @@ main(int argc, char **argv) if(debug){ close(2); - snprint(buf, sizeof(buf), "%s/smtpd", UPASLOG); + snprint(buf, sizeof(buf), "%s/smtpd.db", UPASLOG); if (open(buf, OWRITE) >= 0) { seek(2, 0, 2); fprint(2, "%d smtpd %s\n", getpid(), thedate()); @@ -1221,6 +1221,16 @@ data(void) } reply("%d mail process terminated abnormally\r\n", code); } else { + /* + * if a message appeared on stderr, despite good status, + * log it. this can happen if rewrite.in contains a bad + * r.e., for example. + */ + if(*s_to_c(err)) + syslog(0, "smtpd", + "%s returned good status, but said: %s", + s_to_c(mailer), s_to_c(err)); + if(filterstate == BLOCKED) reply("554 we believe this is spam. we don't accept it.\r\n"); else blob - 84a8fccc32ac95965ed12ebba544556ca5097d96 blob + a4d49485e654e60445a8fda3d904da30923fe5ed --- src/cmd/upas/smtp/spam.c +++ src/cmd/upas/smtp/spam.c @@ -62,7 +62,7 @@ findkey(char *val, Keyword *p) char* actstr(int a) { - char buf[32]; + static char buf[32]; Keyword *p; for(p=actions; p->name; p++) @@ -84,7 +84,8 @@ getaction(char *s, char *type) return ACCEPT; for(k = actions; k->name != 0; k++){ - snprint(buf, sizeof buf, "/mail/ratify/%s/%s/%s", k->name, type, s); + snprint(buf, sizeof buf, "%s/mail/ratify/%s/%s/%s", + get9root(), k->name, type, s); if(access(buf,0) >= 0) return k->code; } @@ -99,7 +100,7 @@ istrusted(char *s) if(s == nil || *s == 0) return 0; - snprint(buf, sizeof buf, "/mail/ratify/trusted/%s", s); + snprint(buf, sizeof buf, "%s/mail/ratify/trusted/%s", get9root(), s); return access(buf,0) >= 0; } @@ -167,6 +168,7 @@ getconf(void) sysclose(bp); } +#if 0 /* * match a user name. the only meta-char is '*' which matches all * characters. we only allow it as "*", which matches anything or @@ -186,6 +188,7 @@ usermatch(char *pathuser, char *specuser) } return strcmp(pathuser, specuser); } +#endif static int dommatch(char *pathdom, char *specdom) @@ -493,7 +496,7 @@ dumpfile(char *sender) return "/dev/null"; } -char *validator = "/mail/lib/validateaddress"; +char *validator = "#9/mail/lib/validateaddress"; int recipok(char *user) @@ -504,7 +507,12 @@ recipok(char *user) Biobuf *bp; int pid; Waitmsg *w; - + static int beenhere; + + if(!beenhere){ + beenhere++; + validator = unsharp(validator); + } if(shellchars(user)){ syslog(0, "smtpd", "shellchars in user name"); return 0; @@ -522,9 +530,7 @@ recipok(char *user) if(w->pid != pid) continue; if(w->msg[0] != 0){ - /* syslog(0, "smtpd", "validateaddress %s: %s", user, w->msg); - */ return 0; } break; @@ -581,7 +587,7 @@ optoutofspamfilter(char *addr) rv = 0; - f = smprint("/mail/box/%s/nospamfiltering", p); + f = smprint("%s/mail/box/%s/nospamfiltering", get9root(), p); if(f != nil){ rv = access(f, 0)==0; free(f); blob - 612a5965f05976d52a2c8ce6d2b634a8c1091d93 blob + 0574e93fd0c6fb823bd128888d290915e8706fab --- src/cmd/upas/unesc/mkfile +++ src/cmd/upas/unesc/mkfile @@ -1,17 +1,7 @@ - 0) return p; -fprint(2, "x\n"); + if(justreject) + return p; + syslog(0, "mail", "vf wrapped %s %s", p->type?s_to_c(p->type):"?", p->filename?s_to_c(p->filename):"?"); -fprint(2, "x\n"); boundary = mkboundary(); -fprint(2, "x\n"); /* print out non-mime headers */ for(hl = p->hl; hl != nil; hl = hl->next) if(cistrncmp(s_to_c(hl->s), "content-", 8) != 0) Bprint(&out, "%s", s_to_c(hl->s)); -fprint(2, "x\n"); /* add in our own multipart headers and message */ Bprint(&out, "Content-Type: multipart/mixed;\n"); Bprint(&out, "\tboundary=\"%s\"\n", s_to_c(boundary)); @@ -539,11 +547,9 @@ fprint(2, "x\n"); break; } -fprint(2, "z\n"); /* pass the body */ np = passbody(p, 0); -fprint(2, "w\n"); /* add the new boundary and the original terminator */ Bprint(&out, "--%s--\n", s_to_c(boundary)); if(np && np->boundary){ @@ -551,7 +557,6 @@ fprint(2, "w\n"); Bwrite(&out, cp, Blinelen(&in)); } -fprint(2, "a %p\n", np); return np; } @@ -871,8 +876,6 @@ badfile(char *name) return 2; } } - if(justreject) - return 0; return 1; } @@ -887,9 +890,6 @@ badtype(char *type) char *s, *fix; int rv = 1; - if(justreject) - return 0; - fix = s = strchr(type, '/'); if(s != nil) *s++ = 0;