various cleanup
This commit is contained in:
parent
e4d832222b
commit
b5f65921f3
37 changed files with 223 additions and 248 deletions
|
|
@ -39,10 +39,9 @@ main(int argc, char *argv[])
|
||||||
namefiles = ARGF();
|
namefiles = ARGF();
|
||||||
break;
|
break;
|
||||||
} ARGEND
|
} ARGEND
|
||||||
if (chdir(unsharp(UPASLIB)) < 0) {
|
|
||||||
perror("translate(chdir):");
|
if (chdir(UPASLIB) < 0)
|
||||||
exit9(1);
|
sysfatal("aliasmail chdir %s: %r", UPASLIB);
|
||||||
}
|
|
||||||
|
|
||||||
/* get environmental info */
|
/* get environmental info */
|
||||||
names = sysnames_read();
|
names = sysnames_read();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <bin.h>
|
#include <bin.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <regexp.h>
|
#include <regexp.h>
|
||||||
#include "/sys/src/libregexp/regcomp.h"
|
#include "../../../libregexp/regcomp.h"
|
||||||
#include "dfa.h"
|
#include "dfa.h"
|
||||||
|
|
||||||
void rdump(Reprog*);
|
void rdump(Reprog*);
|
||||||
|
|
@ -140,19 +140,19 @@ followempty(Deter *d, uchar *bits, int bol, int eol)
|
||||||
switch(i->type){
|
switch(i->type){
|
||||||
case RBRA:
|
case RBRA:
|
||||||
case LBRA:
|
case LBRA:
|
||||||
again |= add(i->next - d->p->firstinst, bits, k);
|
again |= add(i->u2.next - d->p->firstinst, bits, k);
|
||||||
break;
|
break;
|
||||||
case OR:
|
case OR:
|
||||||
again |= add(i->left - d->p->firstinst, bits, k);
|
again |= add(i->u2.left - d->p->firstinst, bits, k);
|
||||||
again |= add(i->right - d->p->firstinst, bits, k);
|
again |= add(i->u1.right - d->p->firstinst, bits, k);
|
||||||
break;
|
break;
|
||||||
case BOL:
|
case BOL:
|
||||||
if(bol)
|
if(bol)
|
||||||
again |= add(i->next - d->p->firstinst, bits, k);
|
again |= add(i->u2.next - d->p->firstinst, bits, k);
|
||||||
break;
|
break;
|
||||||
case EOL:
|
case EOL:
|
||||||
if(eol)
|
if(eol)
|
||||||
again |= add(i->next - d->p->firstinst, bits, k);
|
again |= add(i->u2.next - d->p->firstinst, bits, k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -209,27 +209,27 @@ transition(Deter *d, Reiset *s, Rune r, uint eol)
|
||||||
longjmp(d->kaboom, 1);
|
longjmp(d->kaboom, 1);
|
||||||
|
|
||||||
case RUNE:
|
case RUNE:
|
||||||
if(r == i->r)
|
if(r == i->u1.r)
|
||||||
bits[i->next - inst0] = 1;
|
bits[i->u2.next - inst0] = 1;
|
||||||
break;
|
break;
|
||||||
case ANY:
|
case ANY:
|
||||||
if(r != L'\n')
|
if(r != L'\n')
|
||||||
bits[i->next - inst0] = 1;
|
bits[i->u2.next - inst0] = 1;
|
||||||
break;
|
break;
|
||||||
case ANYNL:
|
case ANYNL:
|
||||||
bits[i->next - inst0] = 1;
|
bits[i->u2.next - inst0] = 1;
|
||||||
break;
|
break;
|
||||||
case NCCLASS:
|
case NCCLASS:
|
||||||
if(r == L'\n')
|
if(r == L'\n')
|
||||||
break;
|
break;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case CCLASS:
|
case CCLASS:
|
||||||
ep = i->cp->end;
|
ep = i->u1.cp->end;
|
||||||
for(rp = i->cp->spans; rp < ep; rp += 2)
|
for(rp = i->u1.cp->spans; rp < ep; rp += 2)
|
||||||
if(rp[0] <= r && r <= rp[1])
|
if(rp[0] <= r && r <= rp[1])
|
||||||
break;
|
break;
|
||||||
if((rp < ep) ^! (i->type == CCLASS))
|
if((rp < ep) ^! (i->type == CCLASS))
|
||||||
bits[i->next - inst0] = 1;
|
bits[i->u2.next - inst0] = 1;
|
||||||
break;
|
break;
|
||||||
case END:
|
case END:
|
||||||
break;
|
break;
|
||||||
|
|
@ -290,9 +290,9 @@ findchars(Deter *d, Reprog *p)
|
||||||
set(d, tab, L'\n'+1);
|
set(d, tab, L'\n'+1);
|
||||||
break;
|
break;
|
||||||
case RUNE:
|
case RUNE:
|
||||||
set(d, tab, i->r-1);
|
set(d, tab, i->u1.r-1);
|
||||||
set(d, tab, i->r);
|
set(d, tab, i->u1.r);
|
||||||
set(d, tab, i->r+1);
|
set(d, tab, i->u1.r+1);
|
||||||
break;
|
break;
|
||||||
case NCCLASS:
|
case NCCLASS:
|
||||||
set(d, tab, L'\n'-1);
|
set(d, tab, L'\n'-1);
|
||||||
|
|
@ -300,8 +300,8 @@ findchars(Deter *d, Reprog *p)
|
||||||
set(d, tab, L'\n'+1);
|
set(d, tab, L'\n'+1);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case CCLASS:
|
case CCLASS:
|
||||||
ep = i->cp->end;
|
ep = i->u1.cp->end;
|
||||||
for(rp = i->cp->spans; rp < ep; rp += 2){
|
for(rp = i->u1.cp->spans; rp < ep; rp += 2){
|
||||||
set(d, tab, rp[0]-1);
|
set(d, tab, rp[0]-1);
|
||||||
set(d, tab, rp[0]);
|
set(d, tab, rp[0]);
|
||||||
set(d, tab, rp[1]);
|
set(d, tab, rp[1]);
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
</$objtype/mkfile
|
<$PLAN9/src/mkhdr
|
||||||
|
|
||||||
TARG=addhash bayes msgtok
|
TARG=addhash bayes msgtok
|
||||||
HFILES=
|
HFILES=
|
||||||
OFILES=
|
OFILES=
|
||||||
LIB=
|
LIB=
|
||||||
|
|
||||||
BIN=/$objtype/bin/upas
|
BIN=$BIN/upas
|
||||||
</sys/src/cmd/mkmany
|
<$PLAN9/src/mkmany
|
||||||
|
|
||||||
# msg tokenizer
|
# msg tokenizer
|
||||||
$O.regen: regcomp.$O dfa.$O
|
$O.regen: regcomp.$O dfa.$O
|
||||||
dfa.$O regcomp.$O regen.$O: dfa.h
|
dfa.$O regcomp.$O regen.$O: dfa.h
|
||||||
|
|
||||||
/mail/lib/classify.re: $O.regen
|
$PLAN9/mail/lib/classify.re: $O.regen
|
||||||
if(~ $cputype $objtype)
|
if(~ $cputype $objtype)
|
||||||
$O.regen >x && cp x $target
|
$O.regen >x && cp x $target
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
void buildre(Dreprog*[3]);
|
void buildre(Dreprog*[3]);
|
||||||
int debug;
|
int debug;
|
||||||
char *refile = "/mail/lib/classify.re";
|
char *refile = "#9/mail/lib/classify.re";
|
||||||
int maxtoklen = 20;
|
int maxtoklen = 20;
|
||||||
int trim(char*);
|
int trim(char*);
|
||||||
|
|
||||||
|
|
@ -35,6 +35,7 @@ main(int argc, char **argv)
|
||||||
char msg[1024+1];
|
char msg[1024+1];
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
|
refile = unsharp(refile);
|
||||||
buildre(re);
|
buildre(re);
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
case 'D':
|
case 'D':
|
||||||
|
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
#include "common.h"
|
|
||||||
#include <auth.h>
|
|
||||||
#include <ndb.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -454,6 +454,7 @@ sysnames_read(void)
|
||||||
if(namev)
|
if(namev)
|
||||||
return namev;
|
return namev;
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
/* free(csgetvalue(0, "sys", alt_sysname_read(), "dom", &t)); jpc */
|
/* free(csgetvalue(0, "sys", alt_sysname_read(), "dom", &t)); jpc */
|
||||||
db = ndbopen(unsharp("#9/ndb/local"));
|
db = ndbopen(unsharp("#9/ndb/local"));
|
||||||
free(ndbgetvalue(db, &s, "sys", sysname(),"dom", &t));
|
free(ndbgetvalue(db, &s, "sys", sysname(),"dom", &t));
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
|
#include <thread.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: %s recipient fromaddr-file mbox\n", argv0);
|
fprint(2, "usage: %s recipient fromaddr-file mbox\n", argv0);
|
||||||
exits("usage");
|
threadexitsall("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <regexp.h>
|
#include <regexp.h>
|
||||||
#include <libsec.h>
|
#include <libsec.h>
|
||||||
#include <String.h>
|
#include <libString.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
|
|
||||||
|
|
@ -188,8 +188,9 @@ readpatterns(char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fuck, shit, bugger, damn */
|
/* fuck, shit, bugger, damn */
|
||||||
void regerror(char*)
|
void regerror(char *err)
|
||||||
{
|
{
|
||||||
|
USED(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,14 @@
|
||||||
</$objtype/mkfile
|
<$PLAN9/src/mkhdr
|
||||||
|
|
||||||
TARG=\
|
TARG=\
|
||||||
token\
|
token\
|
||||||
list\
|
list\
|
||||||
deliver\
|
deliver\
|
||||||
|
|
||||||
LIB=../common/libcommon.a$O\
|
LIB=../common/libcommon.a
|
||||||
|
|
||||||
BIN=/$objtype/bin/upas
|
|
||||||
OFILES=readaddrs.$O
|
OFILES=readaddrs.$O
|
||||||
UPDATE=\
|
|
||||||
mkfile\
|
|
||||||
${TARG:%=%.c}\
|
|
||||||
pipeto.sample\
|
|
||||||
pipefrom.sample\
|
|
||||||
pipeto.sample-hold\
|
|
||||||
|
|
||||||
</sys/src/cmd/mkmany
|
BIN=$BIN/upas
|
||||||
|
<$PLAN9/src/mkmany
|
||||||
|
|
||||||
CFLAGS=$CFLAGS -I../common
|
CFLAGS=$CFLAGS -I../common
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <libsec.h>
|
#include <libsec.h>
|
||||||
#include <String.h>
|
#include <libString.h>
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#define inline _inline
|
||||||
|
|
||||||
typedef struct Attach Attach;
|
typedef struct Attach Attach;
|
||||||
typedef struct Alias Alias;
|
typedef struct Alias Alias;
|
||||||
typedef struct Addr Addr;
|
typedef struct Addr Addr;
|
||||||
|
|
@ -10,7 +12,7 @@ struct Attach {
|
||||||
Attach *next;
|
Attach *next;
|
||||||
char *path;
|
char *path;
|
||||||
char *type;
|
char *type;
|
||||||
int tinline;
|
int inline;
|
||||||
Ctype *ctype;
|
Ctype *ctype;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -684,7 +686,7 @@ attachment(Attach *a, Biobuf *out)
|
||||||
if(strcmp(a->type, "text/plain") != 0)
|
if(strcmp(a->type, "text/plain") != 0)
|
||||||
Bprint(out, "Content-Type: %s\n", a->type);
|
Bprint(out, "Content-Type: %s\n", a->type);
|
||||||
|
|
||||||
if(a->tinline){
|
if(a->inline){
|
||||||
Bprint(out, "Content-Disposition: inline\n");
|
Bprint(out, "Content-Disposition: inline\n");
|
||||||
} else {
|
} else {
|
||||||
p = strrchr(a->path, '/');
|
p = strrchr(a->path, '/');
|
||||||
|
|
@ -811,7 +813,7 @@ printinreplyto(Biobuf *out, char *dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
Attach*
|
Attach*
|
||||||
mkattach(char *file, char *type, int tinline)
|
mkattach(char *file, char *type, int inline)
|
||||||
{
|
{
|
||||||
Ctype *c;
|
Ctype *c;
|
||||||
Attach *a;
|
Attach *a;
|
||||||
|
|
@ -829,7 +831,7 @@ mkattach(char *file, char *type, int tinline)
|
||||||
a->path = file;
|
a->path = file;
|
||||||
a->next = nil;
|
a->next = nil;
|
||||||
a->type = type;
|
a->type = type;
|
||||||
a->tinline = tinline;
|
a->inline = inline;
|
||||||
a->ctype = nil;
|
a->ctype = nil;
|
||||||
if(type != nil){
|
if(type != nil){
|
||||||
for(c = ctype; ; c++)
|
for(c = ctype; ; c++)
|
||||||
|
|
@ -1067,7 +1069,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr)
|
||||||
|
|
||||||
if(pipe(pfd) < 0)
|
if(pipe(pfd) < 0)
|
||||||
fatal("%r");
|
fatal("%r");
|
||||||
switch(*pid = rfork(RFFDG|RFPROC)){ // jpc - removed |RFENVG|RFREND|
|
switch(*pid = fork()){
|
||||||
case -1:
|
case -1:
|
||||||
fatal("%r");
|
fatal("%r");
|
||||||
break;
|
break;
|
||||||
|
|
@ -1105,7 +1107,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr)
|
||||||
|
|
||||||
cmd = mboxpath("pipefrom", login, s_new(), 0);
|
cmd = mboxpath("pipefrom", login, s_new(), 0);
|
||||||
exec(s_to_c(cmd), av);
|
exec(s_to_c(cmd), av);
|
||||||
exec(unsharp("#9/bin/myupassend"), av);
|
exec("myupassend", av);
|
||||||
exec(unsharp("#9/bin/upas/send"), av);
|
exec(unsharp("#9/bin/upas/send"), av);
|
||||||
fatal("execing: %r");
|
fatal("execing: %r");
|
||||||
break;
|
break;
|
||||||
|
|
@ -1130,6 +1132,7 @@ pgpfilter(int *pid, int fd, int pgpflag)
|
||||||
v = av = emalloc(sizeof(char*)*8);
|
v = av = emalloc(sizeof(char*)*8);
|
||||||
ac = 0;
|
ac = 0;
|
||||||
v[ac++] = "pgp";
|
v[ac++] = "pgp";
|
||||||
|
v[ac++] = "-fat"; /* operate as a filter, generate text */
|
||||||
if(pgpflag & PGPsign)
|
if(pgpflag & PGPsign)
|
||||||
v[ac++] = "-s";
|
v[ac++] = "-s";
|
||||||
if(pgpflag & PGPencrypt)
|
if(pgpflag & PGPencrypt)
|
||||||
|
|
@ -1148,8 +1151,10 @@ pgpfilter(int *pid, int fd, int pgpflag)
|
||||||
close(pfd[0]);
|
close(pfd[0]);
|
||||||
dup(fd, 1);
|
dup(fd, 1);
|
||||||
close(fd);
|
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");
|
fatal("execing: %r");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -1314,7 +1319,6 @@ readaliases(void)
|
||||||
Alias *a, **l, *first;
|
Alias *a, **l, *first;
|
||||||
Addr *addr, **al;
|
Addr *addr, **al;
|
||||||
String *file, *line, *token;
|
String *file, *line, *token;
|
||||||
// jpc - static int already;
|
|
||||||
Sinstack *sp;
|
Sinstack *sp;
|
||||||
|
|
||||||
first = nil;
|
first = nil;
|
||||||
|
|
@ -1747,7 +1751,7 @@ readmimetypes(void)
|
||||||
mimetypes[0].ext = "";
|
mimetypes[0].ext = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
b = Bopen(unsharp("#9/sys/lib/mimetype"), OREAD);
|
b = Bopen(unsharp("#9/lib/mimetype"), OREAD);
|
||||||
if(b == nil)
|
if(b == nil)
|
||||||
return;
|
return;
|
||||||
for(;;){
|
for(;;){
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/rc
|
#!/usr/local/plan9/bin/rc
|
||||||
switch($#*){
|
switch($#*){
|
||||||
case 0
|
case 0
|
||||||
exec upas/nedmail
|
exec upas/nedmail
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,19 @@
|
||||||
RCFILES=mail.rc\
|
RCFILES=mail.rc\
|
||||||
|
|
||||||
all:Q:
|
all:Q:
|
||||||
;
|
#
|
||||||
|
|
||||||
installall:Q: install
|
installall:Q: install
|
||||||
;
|
#
|
||||||
|
|
||||||
install:V:
|
install safeinstall safeinstallall:V:
|
||||||
cp mail.rc /rc/bin/mail
|
cp mail.rc $PLAN9/bin/mail
|
||||||
|
|
||||||
safeinstall:V:
|
|
||||||
cp mail.rc /rc/bin/mail
|
|
||||||
|
|
||||||
safeinstallall:V:
|
|
||||||
cp mail.rc /rc/bin/mail
|
|
||||||
|
|
||||||
clean:Q:
|
clean:Q:
|
||||||
;
|
#
|
||||||
|
|
||||||
nuke:V:
|
nuke:V:
|
||||||
rm /rc/bin/mail
|
rm $PLAN9/bin/mail
|
||||||
|
|
||||||
UPDATE=\
|
UPDATE=\
|
||||||
gone.fishing\
|
gone.fishing\
|
||||||
|
|
|
||||||
|
|
@ -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 $*
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/rc
|
#!/usr/local/plan9/bin/rc
|
||||||
sender=$1
|
sender=$1
|
||||||
shift
|
shift
|
||||||
addr=$1
|
addr=$1
|
||||||
shift
|
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
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/rc
|
#!/usr/local/plan9/bin/rc
|
||||||
shift
|
shift
|
||||||
sender=$1
|
sender=$1
|
||||||
shift
|
shift
|
||||||
addr=$1
|
addr=$1
|
||||||
shift
|
shift
|
||||||
/bin/upas/smtp -g research.research.bell-labs.com $addr $sender $*
|
upas/smtp -g yourgateway $addr $sender $*
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
pOsTmAsTeR alias postmaster
|
pOsTmAsTeR alias postmaster
|
||||||
|
|
||||||
# local mail
|
# local mail
|
||||||
[^!@]+ translate "/bin/upas/aliasmail '&'"
|
[^!@]+ translate "upas/aliasmail '&'"
|
||||||
local!(.*) >> /mail/box/\1/mbox
|
local!(.*) >> $PLAN9/mail/box/\1/mbox
|
||||||
\l!(.*) alias \1
|
\l!(.*) alias \1
|
||||||
(helix|helix.bell-labs.com)!(.*) alias \2
|
(helix|helix.bell-labs.com)!(.*) alias \2
|
||||||
|
|
||||||
|
|
@ -17,4 +17,4 @@ local!(.*) >> /mail/box/\1/mbox
|
||||||
([^@]+)@([^@]+) alias \2!\1
|
([^@]+)@([^@]+) alias \2!\1
|
||||||
|
|
||||||
# /mail/lib/remotemail will take care of gating to systems we don't know
|
# /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'"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
</$objtype/mkfile
|
<$PLAN9/src/mkhdr
|
||||||
|
|
||||||
TARG=ml\
|
TARG=ml\
|
||||||
mlowner\
|
mlowner\
|
||||||
|
|
@ -16,25 +16,17 @@ UHFILES= ../common/common.h\
|
||||||
HFILES=$UHFILES\
|
HFILES=$UHFILES\
|
||||||
../smtp/y.tab.h\
|
../smtp/y.tab.h\
|
||||||
|
|
||||||
LIB=../common/libcommon.a$O\
|
LIB=../common/libcommon.a
|
||||||
|
|
||||||
BIN=/$objtype/bin/upas
|
BIN=$BIN/upas
|
||||||
|
<$PLAN9/src/mkmany
|
||||||
UPDATE=\
|
|
||||||
mkfile\
|
|
||||||
$UHFILES\
|
|
||||||
${TARG:%=%.c}\
|
|
||||||
${OFILES:%.$O=%.c}\
|
|
||||||
../smtp/rfc822.y\
|
|
||||||
|
|
||||||
</sys/src/cmd/mkmany
|
|
||||||
CFLAGS=$CFLAGS -I../common
|
CFLAGS=$CFLAGS -I../common
|
||||||
|
|
||||||
$O.ml: ../smtp/rfc822.tab.$O
|
$O.ml: ../smtp/rfc822.tab.$O
|
||||||
$O.mlowner: ../smtp/rfc822.tab.$O
|
$O.mlowner: ../smtp/rfc822.tab.$O
|
||||||
|
|
||||||
../smtp/y.tab.h ../smtp/rfc822.tab.$O:
|
../smtp/y.tab.h ../smtp/rfc822.tab.$O:
|
||||||
@{
|
(
|
||||||
cd ../smtp
|
cd ../smtp
|
||||||
mk rfc822.tab.$O
|
mk rfc822.tab.$O
|
||||||
}
|
)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
rfork(RFENVG|RFREND);
|
rfork(RFENVG);
|
||||||
|
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
usage();
|
usage();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ main(int argc, char **argv)
|
||||||
char *listname, *addr;
|
char *listname, *addr;
|
||||||
String *owner, *alfile;
|
String *owner, *alfile;
|
||||||
|
|
||||||
rfork(RFENVG|RFREND);
|
rfork(RFENVG);
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
case 'c':
|
case 'c':
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ main(int argc, char **argv)
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
rfork(RFENVG|RFREND);
|
rfork(RFENVG);
|
||||||
|
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
usage();
|
usage();
|
||||||
|
|
|
||||||
|
|
@ -585,15 +585,15 @@ matchpat(Pattern *p, char *message, Resub *m)
|
||||||
if(c1 == spat->c1)
|
if(c1 == spat->c1)
|
||||||
if(memcmp(s, spat->string, spat->len) == 0)
|
if(memcmp(s, spat->string, spat->len) == 0)
|
||||||
if(!isalt(message, spat->alt)){
|
if(!isalt(message, spat->alt)){
|
||||||
m->sp = s;
|
m->s.sp = s;
|
||||||
m->ep = s + spat->len;
|
m->e.ep = s + spat->len;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
m->sp = m->ep = 0;
|
m->s.sp = m->e.ep = 0;
|
||||||
if(regexec(p->pat, message, m, 1) == 0)
|
if(regexec(p->pat, message, m, 1) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if(isalt(message, p->alt))
|
if(isalt(message, p->alt))
|
||||||
|
|
@ -608,23 +608,23 @@ xprint(int fd, char *type, Resub *m)
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(m->sp == 0 || m->ep == 0)
|
if(m->s.sp == 0 || m->e.ep == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* back up approx 30 characters to whitespace */
|
/* 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 != ' ')
|
while(*p && *p != ' ')
|
||||||
p--;
|
p--;
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
/* grab about 30 more chars beyond the end of the match */
|
/* 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 != ' ')
|
while(*q && *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 {
|
enum {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
</$objtype/mkfile
|
<$PLAN9/src/mkhdr
|
||||||
|
|
||||||
TARG=scanmail\
|
TARG=scanmail\
|
||||||
testscan
|
testscan
|
||||||
|
|
@ -8,17 +8,11 @@ OFILES= common.$O
|
||||||
HFILES= spam.h\
|
HFILES= spam.h\
|
||||||
../common/sys.h\
|
../common/sys.h\
|
||||||
|
|
||||||
LIB= ../common/libcommon.a$O\
|
LIB= ../common/libcommon.a
|
||||||
|
|
||||||
BIN=/$objtype/bin/upas
|
BIN=$BIN/upas
|
||||||
UPDATE=\
|
<$PLAN9/src/mkmany
|
||||||
mkfile\
|
|
||||||
$HFILES\
|
|
||||||
${OFILES:%.$O=%.c}\
|
|
||||||
${TARG:%=%.c}\
|
|
||||||
|
|
||||||
</sys/src/cmd/mkmany
|
|
||||||
CFLAGS=$CFLAGS -I../common
|
CFLAGS=$CFLAGS -I../common
|
||||||
|
|
||||||
scanmail.$O: scanmail.c
|
scanmail.$O: scanmail.c
|
||||||
$CC $CFLAGS -D'SPOOL="/mail"' scanmail.c
|
$CC $CFLAGS -D'SPOOL="'$PLAN9'/mail"' scanmail.c
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,7 @@ matcher(char *action, Pattern *p, char *message, Resub *m)
|
||||||
char *cp;
|
char *cp;
|
||||||
String *s;
|
String *s;
|
||||||
|
|
||||||
for(cp = message; matchpat(p, cp, m); cp = m->ep){
|
for(cp = message; matchpat(p, cp, m); cp = m->e.ep){
|
||||||
switch(p->action){
|
switch(p->action){
|
||||||
case SaveLine:
|
case SaveLine:
|
||||||
if(vflag)
|
if(vflag)
|
||||||
|
|
@ -340,12 +340,12 @@ matcher(char *action, Pattern *p, char *message, Resub *m)
|
||||||
case Dump:
|
case Dump:
|
||||||
if(vflag)
|
if(vflag)
|
||||||
xprint(2, action, m);
|
xprint(2, action, m);
|
||||||
*(m->ep) = 0;
|
*m->e.ep = 0;
|
||||||
if(!tflag){
|
if(!tflag){
|
||||||
s = s_new();
|
s = s_new();
|
||||||
s_append(s, sender);
|
s_append(s, sender);
|
||||||
s = unescapespecial(s);
|
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_to_c(s_restart(recips)));
|
||||||
s_free(s);
|
s_free(s);
|
||||||
}
|
}
|
||||||
|
|
@ -367,17 +367,17 @@ saveline(char *file, char *sender, Resub *rp)
|
||||||
int i, c;
|
int i, c;
|
||||||
Biobuf *bp;
|
Biobuf *bp;
|
||||||
|
|
||||||
if(rp->sp == 0 || rp->ep == 0)
|
if(rp->s.sp == 0 || rp->e.ep == 0)
|
||||||
return;
|
return;
|
||||||
/* back up approx 20 characters to whitespace */
|
/* 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 != ' ')
|
while(*p && *p != ' ')
|
||||||
p--;
|
p--;
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
/* grab about 20 more chars beyond the end of the match */
|
/* 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 != ' ')
|
while(*q && *q != ' ')
|
||||||
q++;
|
q++;
|
||||||
|
|
|
||||||
|
|
@ -191,11 +191,11 @@ matchaction(Patterns *pp, char *message)
|
||||||
p = pp->strings;
|
p = pp->strings;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if(p)
|
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++;
|
ret++;
|
||||||
|
|
||||||
for(p = pp->regexps; p; p = p->next)
|
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++;
|
ret++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ getstring(Node *p)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* jpc */
|
#if 0
|
||||||
static char *fieldname[] =
|
static char *fieldname[] =
|
||||||
{
|
{
|
||||||
[WORD-WORD] "WORD",
|
[WORD-WORD] "WORD",
|
||||||
|
|
@ -172,7 +172,7 @@ static char *fieldname[] =
|
||||||
[MAILER-WORD] "MAILER",
|
[MAILER-WORD] "MAILER",
|
||||||
[BADTOKEN-WORD] "BADTOKEN",
|
[BADTOKEN-WORD] "BADTOKEN",
|
||||||
};
|
};
|
||||||
#endif /* jpc */
|
#endif
|
||||||
|
|
||||||
/* fix 822 addresses */
|
/* fix 822 addresses */
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -21,22 +21,13 @@ SMOBJ=main.$O\
|
||||||
gateway.$O\
|
gateway.$O\
|
||||||
cat_mail.$O\
|
cat_mail.$O\
|
||||||
|
|
||||||
LIB=../common/libcommon.av\
|
|
||||||
|
|
||||||
HFILES=send.h\
|
HFILES=send.h\
|
||||||
../common/common.h\
|
../common/common.h\
|
||||||
../common/sys.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
|
<$PLAN9/src/mkmany
|
||||||
CFLAGS=$CFLAGS -I../common
|
CFLAGS=$CFLAGS -I../common
|
||||||
|
|
||||||
|
|
@ -46,7 +37,6 @@ $O.send: $SMOBJ $OFILES
|
||||||
message.$O: ../smtp/y.tab.h
|
message.$O: ../smtp/y.tab.h
|
||||||
|
|
||||||
../smtp/y.tab.h ../smtp/rfc822.tab.$O: ../smtp/rfc822.y
|
../smtp/y.tab.h ../smtp/rfc822.tab.$O: ../smtp/rfc822.y
|
||||||
# @{
|
cd ../smtp
|
||||||
cd ../smtp
|
mk rfc822.tab.$O
|
||||||
mk rfc822.tab.$O
|
|
||||||
# }
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ getrules(void)
|
||||||
String *type;
|
String *type;
|
||||||
String *file;
|
String *file;
|
||||||
|
|
||||||
file = abspath("rewrite", unsharp(UPASLIB), (String *)0);
|
file = abspath("rewrite", UPASLIB, (String *)0);
|
||||||
rfp = sysopen(s_to_c(file), "r", 0);
|
rfp = sysopen(s_to_c(file), "r", 0);
|
||||||
if(rfp == 0) {
|
if(rfp == 0) {
|
||||||
rulep = 0;
|
rulep = 0;
|
||||||
|
|
@ -168,7 +168,7 @@ findrule(String *addrp, int authorized)
|
||||||
continue;
|
continue;
|
||||||
memset(rp->subexp, 0, sizeof(rp->subexp));
|
memset(rp->subexp, 0, sizeof(rp->subexp));
|
||||||
if(debug)
|
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(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) == rp->subexp[0].s.sp)
|
||||||
if((s_to_c(addrp) + strlen(s_to_c(addrp))) == rp->subexp[0].e.ep)
|
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->repl2 = substitute(rp->repl2, rp->subexp, mp);
|
||||||
dp->status = rp->type;
|
dp->status = rp->type;
|
||||||
if(debug){
|
if(debug){
|
||||||
print("\t->");
|
fprint(2, "\t->");
|
||||||
if(dp->repl1)
|
if(dp->repl1)
|
||||||
print("%s", s_to_c(dp->repl1));
|
fprint(2, "%s", s_to_c(dp->repl1));
|
||||||
if(dp->repl2)
|
if(dp->repl2)
|
||||||
print("%s", s_to_c(dp->repl2));
|
fprint(2, "%s", s_to_c(dp->repl2));
|
||||||
print("\n");
|
fprint(2, "\n");
|
||||||
}
|
}
|
||||||
s_free(lower);
|
s_free(lower);
|
||||||
return 0;
|
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(p<bufe && idchr(*p))
|
||||||
|
p++;
|
||||||
|
|
||||||
|
memcpy(buf, p0, p-p0);
|
||||||
|
buf[p-p0]=0;
|
||||||
|
*rv = getenv(buf);
|
||||||
|
if (debug)
|
||||||
|
fprint(2, "varsubst: %s → %s\n", buf, *rv);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
static String *
|
static String *
|
||||||
substitute(String *source, Resub *subexp, message *mp)
|
substitute(String *source, Resub *subexp, message *mp)
|
||||||
{
|
{
|
||||||
|
|
@ -264,11 +292,15 @@ substitute(String *source, Resub *subexp, message *mp)
|
||||||
s_putc(stp, *sp);
|
s_putc(stp, *sp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(*sp == '&') {
|
} else if(*sp == '&') {
|
||||||
if(subexp[0].s.sp != 0)
|
if(subexp[0].s.sp != 0)
|
||||||
for (s = subexp[0].s.sp;
|
for (s = subexp[0].s.sp;
|
||||||
s < subexp[0].e.ep; s++)
|
s < subexp[0].e.ep; s++)
|
||||||
s_putc(stp, *s);
|
s_putc(stp, *s);
|
||||||
|
} else if(*sp == '$') {
|
||||||
|
sp = getrcvar(sp+1, &s);
|
||||||
|
s_append(stp, s);
|
||||||
|
free(s);
|
||||||
} else
|
} else
|
||||||
s_putc(stp, *sp);
|
s_putc(stp, *sp);
|
||||||
sp++;
|
sp++;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ typedef struct {
|
||||||
enum {
|
enum {
|
||||||
Nonspammax = 14*60*60, /* must call back within this time if real */
|
Nonspammax = 14*60*60, /* must call back within this time if real */
|
||||||
};
|
};
|
||||||
static char whitelist[] = "/mail/lib/whitelist";
|
static char *whitelist = "#9/mail/lib/whitelist";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* matches ip addresses or subnets in whitelist against nci->rsys.
|
* matches ip addresses or subnets in whitelist against nci->rsys.
|
||||||
|
|
@ -40,11 +40,11 @@ onwhitelist(void)
|
||||||
uchar mask[IPaddrlen], addr[IPaddrlen], addrmasked[IPaddrlen];
|
uchar mask[IPaddrlen], addr[IPaddrlen], addrmasked[IPaddrlen];
|
||||||
Biobuf *wl;
|
Biobuf *wl;
|
||||||
static int beenhere;
|
static int beenhere;
|
||||||
static allzero[IPaddrlen];
|
|
||||||
|
|
||||||
if (!beenhere) {
|
if (!beenhere) {
|
||||||
beenhere = 1;
|
beenhere = 1;
|
||||||
fmtinstall('I', eipfmt);
|
fmtinstall('I', eipfmt);
|
||||||
|
whitelist = unsharp(whitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseip(ip, nci->rsys);
|
parseip(ip, nci->rsys);
|
||||||
|
|
@ -219,8 +219,8 @@ isrcptrecent(char *rcpt)
|
||||||
user++;
|
user++;
|
||||||
|
|
||||||
/* check & try to update the grey list entry */
|
/* check & try to update the grey list entry */
|
||||||
snprint(file, sizeof file, "/mail/grey/%s/%s/%s",
|
snprint(file, sizeof file, "%s/mail/grey/%s/%s/%s",
|
||||||
nci->lsys, nci->rsys, user);
|
get9root(), nci->lsys, nci->rsys, user);
|
||||||
memset(gsp, 0, sizeof *gsp);
|
memset(gsp, 0, sizeof *gsp);
|
||||||
addgreylist(file, gsp);
|
addgreylist(file, gsp);
|
||||||
|
|
||||||
|
|
@ -258,10 +258,7 @@ vfysenderhostok(void)
|
||||||
|
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
seek(fd, 0, 2); /* paranoia */
|
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\n%s\n\n", fqdn, nci->rsys);
|
|
||||||
else
|
|
||||||
fprint(fd, "# unknown\n%s\n\n", nci->rsys);
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
<$PLAN9/src/mkhdr
|
<$PLAN9/src/mkhdr
|
||||||
|
|
||||||
TARG = # smtpd\
|
TARG=\
|
||||||
smtp\
|
smtp\
|
||||||
|
smtpd\
|
||||||
|
|
||||||
OFILES=
|
OFILES=
|
||||||
|
|
||||||
LIB=../common/libcommon.a\
|
LIB=../common/libcommon.a
|
||||||
$PLAN9/lib/libthread.a # why do i have to explicitly put this?
|
|
||||||
|
|
||||||
HFILES=../common/common.h\
|
HFILES=../common/common.h\
|
||||||
../common/sys.h\
|
../common/sys.h\
|
||||||
|
|
@ -27,7 +27,7 @@ UPDATE=\
|
||||||
${TARG:%=%.c}\
|
${TARG:%=%.c}\
|
||||||
|
|
||||||
<$PLAN9/src/mkmany
|
<$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.smtpd: smtpd.tab.$O rmtdns.$O spam.$O rfc822.tab.$O greylist.$O
|
||||||
$O.smtp: rfc822.tab.$O mxdial.$O
|
$O.smtp: rfc822.tab.$O mxdial.$O
|
||||||
|
|
@ -37,7 +37,7 @@ smtpd.$O: smtpd.h
|
||||||
smtp.$O to.$O: smtp.h
|
smtp.$O to.$O: smtp.h
|
||||||
|
|
||||||
smtpd.tab.c: smtpd.y smtpd.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
|
sed 's/yy/zz/g' < xxx > $target
|
||||||
rm xxx
|
rm xxx
|
||||||
|
|
||||||
|
|
@ -47,8 +47,6 @@ rfc822.tab.c: rfc822.y smtp.h
|
||||||
clean:V:
|
clean:V:
|
||||||
rm -f *.[$OS] [$OS].$TARG smtpd.tab.c rfc822.tab.c y.tab.? y.debug $TARG
|
rm -f *.[$OS] [$OS].$TARG smtpd.tab.c rfc822.tab.c y.tab.? y.debug $TARG
|
||||||
|
|
||||||
../common/libcommon.a$O:
|
../common/libcommon.a
|
||||||
@{
|
cd ../common; mk
|
||||||
cd ../common
|
|
||||||
mk
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <ndb.h>
|
#include <ndb.h>
|
||||||
#include "smtp.h" /* to publish dial_string_parse */
|
#include "smtp.h" /* to publish dial_string_parse */
|
||||||
|
#include <ip.h>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
@ -42,14 +43,20 @@ mxdial(char *addr, char *ddomain, char *gdomain)
|
||||||
|
|
||||||
/* try our mail gateway */
|
/* try our mail gateway */
|
||||||
rerrstr(err, sizeof(err));
|
rerrstr(err, sizeof(err));
|
||||||
if(fd < 0 && gdomain && strstr(err, "can't translate") != 0) {
|
if(fd < 0 && gdomain && strstr(err, "can't translate") != 0)
|
||||||
fprint(2,"dialing %s\n",gdomain);
|
|
||||||
fd = dial(netmkaddr(gdomain, 0, "smtp"), 0, 0, 0);
|
fd = dial(netmkaddr(gdomain, 0, "smtp"), 0, 0, 0);
|
||||||
}
|
|
||||||
|
|
||||||
return fd;
|
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,
|
* take an address and return all the mx entries for it,
|
||||||
* most preferred first
|
* most preferred first
|
||||||
|
|
@ -92,7 +99,11 @@ callmx(DS *ds, char *dest, char *domain)
|
||||||
mx[i].host, ds->service);
|
mx[i].host, ds->service);
|
||||||
if(debug)
|
if(debug)
|
||||||
fprint(2, "mxdial trying %s\n", addr);
|
fprint(2, "mxdial trying %s\n", addr);
|
||||||
|
atnotify(timeout, 1);
|
||||||
|
alarm(10*1000);
|
||||||
fd = dial(addr, 0, 0, 0);
|
fd = dial(addr, 0, 0, 0);
|
||||||
|
alarm(0);
|
||||||
|
atnotify(timeout, 0);
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
@ -316,6 +327,7 @@ expand_meta(DS *ds)
|
||||||
}
|
}
|
||||||
#endif /* jpc */
|
#endif /* jpc */
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
static void
|
static void
|
||||||
expand_meta(DS *ds)
|
expand_meta(DS *ds)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ threadmain(int argc, char **argv)
|
||||||
if(*argv == 0)
|
if(*argv == 0)
|
||||||
usage();
|
usage();
|
||||||
addr = *argv++; argc--;
|
addr = *argv++; argc--;
|
||||||
// expand $smtp if necessary
|
// expand $smtp if necessary XXX
|
||||||
addr = expand_addr(addr);
|
addr = expand_addr(addr);
|
||||||
farend = addr;
|
farend = addr;
|
||||||
|
|
||||||
|
|
@ -202,12 +202,12 @@ threadmain(int argc, char **argv)
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 10 minutes to get through the initial handshake */
|
/* mxdial uses its own timeout handler */
|
||||||
atnotify(timeout, 1);
|
|
||||||
|
|
||||||
alarm(10*alarmscale);
|
|
||||||
if((rv = connect(addr)) != 0)
|
if((rv = connect(addr)) != 0)
|
||||||
exits(rv);
|
exits(rv);
|
||||||
|
|
||||||
|
/* 10 minutes to get through the initial handshake */
|
||||||
|
atnotify(timeout, 1);
|
||||||
alarm(10*alarmscale);
|
alarm(10*alarmscale);
|
||||||
if((rv = hello(hellodomain, 0)) != 0)
|
if((rv = hello(hellodomain, 0)) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
@ -1097,6 +1097,7 @@ dBputc(int x)
|
||||||
return Bputc(&bout, x);
|
return Bputc(&bout, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
char*
|
char*
|
||||||
expand_addr(char* a)
|
expand_addr(char* a)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if(debug){
|
if(debug){
|
||||||
close(2);
|
close(2);
|
||||||
snprint(buf, sizeof(buf), "%s/smtpd", UPASLOG);
|
snprint(buf, sizeof(buf), "%s/smtpd.db", UPASLOG);
|
||||||
if (open(buf, OWRITE) >= 0) {
|
if (open(buf, OWRITE) >= 0) {
|
||||||
seek(2, 0, 2);
|
seek(2, 0, 2);
|
||||||
fprint(2, "%d smtpd %s\n", getpid(), thedate());
|
fprint(2, "%d smtpd %s\n", getpid(), thedate());
|
||||||
|
|
@ -1221,6 +1221,16 @@ data(void)
|
||||||
}
|
}
|
||||||
reply("%d mail process terminated abnormally\r\n", code);
|
reply("%d mail process terminated abnormally\r\n", code);
|
||||||
} else {
|
} 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)
|
if(filterstate == BLOCKED)
|
||||||
reply("554 we believe this is spam. we don't accept it.\r\n");
|
reply("554 we believe this is spam. we don't accept it.\r\n");
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ findkey(char *val, Keyword *p)
|
||||||
char*
|
char*
|
||||||
actstr(int a)
|
actstr(int a)
|
||||||
{
|
{
|
||||||
char buf[32];
|
static char buf[32];
|
||||||
Keyword *p;
|
Keyword *p;
|
||||||
|
|
||||||
for(p=actions; p->name; p++)
|
for(p=actions; p->name; p++)
|
||||||
|
|
@ -84,7 +84,8 @@ getaction(char *s, char *type)
|
||||||
return ACCEPT;
|
return ACCEPT;
|
||||||
|
|
||||||
for(k = actions; k->name != 0; k++){
|
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)
|
if(access(buf,0) >= 0)
|
||||||
return k->code;
|
return k->code;
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +100,7 @@ istrusted(char *s)
|
||||||
if(s == nil || *s == 0)
|
if(s == nil || *s == 0)
|
||||||
return 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;
|
return access(buf,0) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,6 +168,7 @@ getconf(void)
|
||||||
sysclose(bp);
|
sysclose(bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* match a user name. the only meta-char is '*' which matches all
|
* match a user name. the only meta-char is '*' which matches all
|
||||||
* characters. we only allow it as "*", which matches anything or
|
* characters. we only allow it as "*", which matches anything or
|
||||||
|
|
@ -186,6 +188,7 @@ usermatch(char *pathuser, char *specuser)
|
||||||
}
|
}
|
||||||
return strcmp(pathuser, specuser);
|
return strcmp(pathuser, specuser);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dommatch(char *pathdom, char *specdom)
|
dommatch(char *pathdom, char *specdom)
|
||||||
|
|
@ -493,7 +496,7 @@ dumpfile(char *sender)
|
||||||
return "/dev/null";
|
return "/dev/null";
|
||||||
}
|
}
|
||||||
|
|
||||||
char *validator = "/mail/lib/validateaddress";
|
char *validator = "#9/mail/lib/validateaddress";
|
||||||
|
|
||||||
int
|
int
|
||||||
recipok(char *user)
|
recipok(char *user)
|
||||||
|
|
@ -504,7 +507,12 @@ recipok(char *user)
|
||||||
Biobuf *bp;
|
Biobuf *bp;
|
||||||
int pid;
|
int pid;
|
||||||
Waitmsg *w;
|
Waitmsg *w;
|
||||||
|
static int beenhere;
|
||||||
|
|
||||||
|
if(!beenhere){
|
||||||
|
beenhere++;
|
||||||
|
validator = unsharp(validator);
|
||||||
|
}
|
||||||
if(shellchars(user)){
|
if(shellchars(user)){
|
||||||
syslog(0, "smtpd", "shellchars in user name");
|
syslog(0, "smtpd", "shellchars in user name");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -522,9 +530,7 @@ recipok(char *user)
|
||||||
if(w->pid != pid)
|
if(w->pid != pid)
|
||||||
continue;
|
continue;
|
||||||
if(w->msg[0] != 0){
|
if(w->msg[0] != 0){
|
||||||
/*
|
|
||||||
syslog(0, "smtpd", "validateaddress %s: %s", user, w->msg);
|
syslog(0, "smtpd", "validateaddress %s: %s", user, w->msg);
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -581,7 +587,7 @@ optoutofspamfilter(char *addr)
|
||||||
|
|
||||||
|
|
||||||
rv = 0;
|
rv = 0;
|
||||||
f = smprint("/mail/box/%s/nospamfiltering", p);
|
f = smprint("%s/mail/box/%s/nospamfiltering", get9root(), p);
|
||||||
if(f != nil){
|
if(f != nil){
|
||||||
rv = access(f, 0)==0;
|
rv = access(f, 0)==0;
|
||||||
free(f);
|
free(f);
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,7 @@
|
||||||
</$objtype/mkfile
|
<$PLAN9/src/mkhdr
|
||||||
|
|
||||||
TARG=unesc
|
TARG=unesc
|
||||||
|
OFILES=unesc.$O
|
||||||
|
|
||||||
OFILES=unesc.$O\
|
BIN=$BIN/upas
|
||||||
|
<$PLAN9/src/mkone
|
||||||
BIN=/$objtype/bin/upas
|
|
||||||
|
|
||||||
CC=pcc -c
|
|
||||||
CFLAGS=-B
|
|
||||||
|
|
||||||
UPDATE=\
|
|
||||||
mkfile\
|
|
||||||
$HFILES\
|
|
||||||
${OFILES:%.$O=%.c}\
|
|
||||||
|
|
||||||
</sys/src/cmd/mkone
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ hex(int c)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,13 @@ Mtype *mtypes;
|
||||||
int justreject;
|
int justreject;
|
||||||
char *savefile;
|
char *savefile;
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprint(2, "usage: upas/vf [-r] [-s savefile]\n");
|
||||||
|
exits("usage");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
@ -124,12 +131,15 @@ main(int argc, char **argv)
|
||||||
justreject = 1;
|
justreject = 1;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
savefile = ARGF();
|
savefile = EARGF(usage());
|
||||||
if(savefile == nil)
|
|
||||||
exits("usage");
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
|
if(argc)
|
||||||
|
usage();
|
||||||
|
|
||||||
Binit(&in, 0, OREAD);
|
Binit(&in, 0, OREAD);
|
||||||
Binit(&out, 1, OWRITE);
|
Binit(&out, 1, OWRITE);
|
||||||
|
|
||||||
|
|
@ -415,8 +425,7 @@ savetmp(Part *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX save the decoded file, run 9 unzip -tf on it, and then
|
* Run the external checker to do content-based checks.
|
||||||
* look at the file list.
|
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
runchecker(Part *p)
|
runchecker(Part *p)
|
||||||
|
|
@ -483,19 +492,18 @@ problemchild(Part *p)
|
||||||
if(runchecker(p) > 0)
|
if(runchecker(p) > 0)
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
fprint(2, "x\n");
|
if(justreject)
|
||||||
|
return p;
|
||||||
|
|
||||||
syslog(0, "mail", "vf wrapped %s %s", p->type?s_to_c(p->type):"?",
|
syslog(0, "mail", "vf wrapped %s %s", p->type?s_to_c(p->type):"?",
|
||||||
p->filename?s_to_c(p->filename):"?");
|
p->filename?s_to_c(p->filename):"?");
|
||||||
fprint(2, "x\n");
|
|
||||||
|
|
||||||
boundary = mkboundary();
|
boundary = mkboundary();
|
||||||
fprint(2, "x\n");
|
|
||||||
/* print out non-mime headers */
|
/* print out non-mime headers */
|
||||||
for(hl = p->hl; hl != nil; hl = hl->next)
|
for(hl = p->hl; hl != nil; hl = hl->next)
|
||||||
if(cistrncmp(s_to_c(hl->s), "content-", 8) != 0)
|
if(cistrncmp(s_to_c(hl->s), "content-", 8) != 0)
|
||||||
Bprint(&out, "%s", s_to_c(hl->s));
|
Bprint(&out, "%s", s_to_c(hl->s));
|
||||||
|
|
||||||
fprint(2, "x\n");
|
|
||||||
/* add in our own multipart headers and message */
|
/* add in our own multipart headers and message */
|
||||||
Bprint(&out, "Content-Type: multipart/mixed;\n");
|
Bprint(&out, "Content-Type: multipart/mixed;\n");
|
||||||
Bprint(&out, "\tboundary=\"%s\"\n", s_to_c(boundary));
|
Bprint(&out, "\tboundary=\"%s\"\n", s_to_c(boundary));
|
||||||
|
|
@ -539,11 +547,9 @@ fprint(2, "x\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprint(2, "z\n");
|
|
||||||
/* pass the body */
|
/* pass the body */
|
||||||
np = passbody(p, 0);
|
np = passbody(p, 0);
|
||||||
|
|
||||||
fprint(2, "w\n");
|
|
||||||
/* add the new boundary and the original terminator */
|
/* add the new boundary and the original terminator */
|
||||||
Bprint(&out, "--%s--\n", s_to_c(boundary));
|
Bprint(&out, "--%s--\n", s_to_c(boundary));
|
||||||
if(np && np->boundary){
|
if(np && np->boundary){
|
||||||
|
|
@ -551,7 +557,6 @@ fprint(2, "w\n");
|
||||||
Bwrite(&out, cp, Blinelen(&in));
|
Bwrite(&out, cp, Blinelen(&in));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprint(2, "a %p\n", np);
|
|
||||||
return np;
|
return np;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -871,8 +876,6 @@ badfile(char *name)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(justreject)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -887,9 +890,6 @@ badtype(char *type)
|
||||||
char *s, *fix;
|
char *s, *fix;
|
||||||
int rv = 1;
|
int rv = 1;
|
||||||
|
|
||||||
if(justreject)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
fix = s = strchr(type, '/');
|
fix = s = strchr(type, '/');
|
||||||
if(s != nil)
|
if(s != nil)
|
||||||
*s++ = 0;
|
*s++ = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue