From b5f65921f346e6b4335f77e457ac5bcae0ab9d67 Mon Sep 17 00:00:00 2001 From: rsc Date: Sat, 11 Feb 2006 23:38:55 +0000 Subject: various cleanup --- src/cmd/upas/alias/aliasmail.c | 7 +++--- src/cmd/upas/bayes/dfa.c | 36 +++++++++++++++---------------- src/cmd/upas/bayes/mkfile | 8 +++---- src/cmd/upas/bayes/msgtok.c | 3 ++- src/cmd/upas/common/become.c | 28 ------------------------ src/cmd/upas/common/libsys.c | 1 + src/cmd/upas/filterkit/deliver.c | 3 ++- src/cmd/upas/filterkit/list.c | 5 +++-- src/cmd/upas/filterkit/mkfile | 17 +++++---------- src/cmd/upas/filterkit/token.c | 2 +- src/cmd/upas/marshal/marshal.c | 22 +++++++++++-------- src/cmd/upas/misc/mail.rc | 2 +- src/cmd/upas/misc/mkfile | 19 ++++++----------- src/cmd/upas/misc/omail.rc | 14 ------------ src/cmd/upas/misc/qmail | 4 ++-- src/cmd/upas/misc/remotemail | 4 ++-- src/cmd/upas/misc/rewrite | 6 +++--- src/cmd/upas/ml/mkfile | 20 ++++++----------- src/cmd/upas/ml/ml.c | 2 +- src/cmd/upas/ml/mlmgr.c | 2 +- src/cmd/upas/ml/mlowner.c | 2 +- src/cmd/upas/scanmail/common.c | 14 ++++++------ src/cmd/upas/scanmail/mkfile | 16 +++++--------- src/cmd/upas/scanmail/scanmail.c | 12 +++++------ src/cmd/upas/scanmail/testscan.c | 4 ++-- src/cmd/upas/send/message.c | 4 ++-- src/cmd/upas/send/mkfile | 20 +++++------------ src/cmd/upas/send/rewrite.c | 46 ++++++++++++++++++++++++++++++++++------ src/cmd/upas/smtp/greylist.c | 13 +++++------- src/cmd/upas/smtp/mkfile | 18 +++++++--------- src/cmd/upas/smtp/mxdial.c | 18 +++++++++++++--- src/cmd/upas/smtp/smtp.c | 11 +++++----- src/cmd/upas/smtp/smtpd.c | 12 ++++++++++- src/cmd/upas/smtp/spam.c | 22 ++++++++++++------- src/cmd/upas/unesc/mkfile | 18 ++++------------ src/cmd/upas/unesc/unesc.c | 2 +- src/cmd/upas/vf/vf.c | 34 ++++++++++++++--------------- 37 files changed, 223 insertions(+), 248 deletions(-) delete mode 100644 src/cmd/upas/common/become.c delete mode 100755 src/cmd/upas/misc/omail.rc (limited to 'src/cmd') diff --git a/src/cmd/upas/alias/aliasmail.c b/src/cmd/upas/alias/aliasmail.c index f50c348a..626be975 100644 --- a/src/cmd/upas/alias/aliasmail.c +++ b/src/cmd/upas/alias/aliasmail.c @@ -39,10 +39,9 @@ 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(); diff --git a/src/cmd/upas/bayes/dfa.c b/src/cmd/upas/bayes/dfa.c index 46695efd..80142dee 100644 --- a/src/cmd/upas/bayes/dfa.c +++ b/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]); diff --git a/src/cmd/upas/bayes/mkfile b/src/cmd/upas/bayes/mkfile index c0c546e7..1479995b 100644 --- a/src/cmd/upas/bayes/mkfile +++ b/src/cmd/upas/bayes/mkfile @@ -1,18 +1,18 @@ -x && cp x $target diff --git a/src/cmd/upas/bayes/msgtok.c b/src/cmd/upas/bayes/msgtok.c index 7c450546..122e0c64 100644 --- a/src/cmd/upas/bayes/msgtok.c +++ b/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': diff --git a/src/cmd/upas/common/become.c b/src/cmd/upas/common/become.c deleted file mode 100644 index 1b5aa456..00000000 --- a/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; -} - diff --git a/src/cmd/upas/common/libsys.c b/src/cmd/upas/common/libsys.c index a9d4f0f8..cf56c869 100644 --- a/src/cmd/upas/common/libsys.c +++ b/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)); diff --git a/src/cmd/upas/filterkit/deliver.c b/src/cmd/upas/filterkit/deliver.c index 33903708..3b129317 100644 --- a/src/cmd/upas/filterkit/deliver.c +++ b/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 diff --git a/src/cmd/upas/filterkit/list.c b/src/cmd/upas/filterkit/list.c index 6c23dcc1..1913c6de 100644 --- a/src/cmd/upas/filterkit/list.c +++ b/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); } /* diff --git a/src/cmd/upas/filterkit/mkfile b/src/cmd/upas/filterkit/mkfile index c077d564..880ede1e 100644 --- a/src/cmd/upas/filterkit/mkfile +++ b/src/cmd/upas/filterkit/mkfile @@ -1,21 +1,14 @@ - #include #include -#include +#include #include "dat.h" void diff --git a/src/cmd/upas/marshal/marshal.c b/src/cmd/upas/marshal/marshal.c index cfc186c0..e5c75f7f 100644 --- a/src/cmd/upas/marshal/marshal.c +++ b/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(;;){ diff --git a/src/cmd/upas/misc/mail.rc b/src/cmd/upas/misc/mail.rc index 6913d743..b079e2d8 100755 --- a/src/cmd/upas/misc/mail.rc +++ b/src/cmd/upas/misc/mail.rc @@ -1,4 +1,4 @@ -#!/bin/rc +#!/usr/local/plan9/bin/rc switch($#*){ case 0 exec upas/nedmail diff --git a/src/cmd/upas/misc/mkfile b/src/cmd/upas/misc/mkfile index 0bbd8a5a..eeb76965 100644 --- a/src/cmd/upas/misc/mkfile +++ b/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 - -safeinstall:V: - cp mail.rc /rc/bin/mail - -safeinstallall:V: - cp mail.rc /rc/bin/mail +install safeinstall safeinstallall:V: + cp mail.rc $PLAN9/bin/mail clean:Q: - ; + # + nuke:V: - rm /rc/bin/mail + rm $PLAN9/bin/mail UPDATE=\ gone.fishing\ diff --git a/src/cmd/upas/misc/omail.rc b/src/cmd/upas/misc/omail.rc deleted file mode 100755 index ed64f38c..00000000 --- a/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 $* -} diff --git a/src/cmd/upas/misc/qmail b/src/cmd/upas/misc/qmail index 77a3d228..de2f0361 100755 --- a/src/cmd/upas/misc/qmail +++ b/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 diff --git a/src/cmd/upas/misc/remotemail b/src/cmd/upas/misc/remotemail index 312ee587..9059d3f4 100755 --- a/src/cmd/upas/misc/remotemail +++ b/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 $* diff --git a/src/cmd/upas/misc/rewrite b/src/cmd/upas/misc/rewrite index fd724eb1..a4d1719d 100644 --- a/src/cmd/upas/misc/rewrite +++ b/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'" diff --git a/src/cmd/upas/ml/mkfile b/src/cmd/upas/ml/mkfile index 5142e56f..1a384108 100644 --- a/src/cmd/upas/ml/mkfile +++ b/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 { diff --git a/src/cmd/upas/scanmail/mkfile b/src/cmd/upas/scanmail/mkfile index 5f0db855..630150e6 100644 --- a/src/cmd/upas/scanmail/mkfile +++ b/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 *m) 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++; diff --git a/src/cmd/upas/scanmail/testscan.c b/src/cmd/upas/scanmail/testscan.c index e5ea59ad..48cd4bbf 100644 --- a/src/cmd/upas/scanmail/testscan.c +++ b/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; } diff --git a/src/cmd/upas/send/message.c b/src/cmd/upas/send/message.c index eab6160c..8cee34a0 100644 --- a/src/cmd/upas/send/message.c +++ b/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 diff --git a/src/cmd/upas/send/mkfile b/src/cmd/upas/send/mkfile index a49fde17..937b318d 100644 --- a/src/cmd/upas/send/mkfile +++ b/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\ - -BIN=$PLAN9/bin/upas -UPDATE=\ - mkfile\ - $HFILES\ - ${UOFILES:%.$O=%.c}\ - ${SMOBJ:%.$O=%.c}\ - ${TARG:%=%.c}\ +LIB=../common/libcommon.a +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 + diff --git a/src/cmd/upas/send/rewrite.c b/src/cmd/upas/send/rewrite.c index 4f40b293..2feacbf2 100644 --- a/src/cmd/upas/send/rewrite.c +++ b/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,17 +203,45 @@ 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 { diff --git a/src/cmd/upas/smtp/mkfile b/src/cmd/upas/smtp/mkfile index 722f1357..c4c7e053 100644 --- a/src/cmd/upas/smtp/mkfile +++ b/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 + diff --git a/src/cmd/upas/smtp/mxdial.c b/src/cmd/upas/smtp/mxdial.c index aea5f256..13f40ab5 100644 --- a/src/cmd/upas/smtp/mxdial.c +++ b/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,14 +43,20 @@ 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; +} + /* * take an address and return all the mx entries for it, * most preferred first @@ -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) { diff --git a/src/cmd/upas/smtp/smtp.c b/src/cmd/upas/smtp/smtp.c index e88154f7..fb00cd5f 100644 --- a/src/cmd/upas/smtp/smtp.c +++ b/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) { diff --git a/src/cmd/upas/smtp/smtpd.c b/src/cmd/upas/smtp/smtpd.c index 7042c37c..8bd4511d 100644 --- a/src/cmd/upas/smtp/smtpd.c +++ b/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 diff --git a/src/cmd/upas/smtp/spam.c b/src/cmd/upas/smtp/spam.c index 84a8fccc..a4d49485 100644 --- a/src/cmd/upas/smtp/spam.c +++ b/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); diff --git a/src/cmd/upas/unesc/mkfile b/src/cmd/upas/unesc/mkfile index 612a5965..0574e93f 100644 --- a/src/cmd/upas/unesc/mkfile +++ b/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; -- cgit v1.2.3