| 6 |
details. |
details. |
| 7 |
|
|
| 8 |
Process remailer messages |
Process remailer messages |
| 9 |
$Id: rem.c,v 1.1 2001/10/31 08:19:53 rabbi Exp $ */ |
$Id: rem.c,v 1.9 2001/12/17 00:32:42 rabbi Exp $ */ |
| 10 |
|
|
| 11 |
|
|
| 12 |
#include "mix3.h" |
#include "mix3.h" |
| 47 |
FILE *f; |
FILE *f; |
| 48 |
BUFFER *block; |
BUFFER *block; |
| 49 |
int err = 0; |
int err = 0; |
| 50 |
|
int quoted_printable = 0; /* is this message quoted printable encoded */ |
| 51 |
|
|
| 52 |
mix_init(NULL); |
mix_init(NULL); |
| 53 |
field = buf_new(); |
field = buf_new(); |
| 120 |
bufieq(field, "post-to") || bufieq(field, "anon-send-to") || |
bufieq(field, "post-to") || bufieq(field, "anon-send-to") || |
| 121 |
bufieq(field, "send-to") || bufieq(field, "remix-to")) |
bufieq(field, "send-to") || bufieq(field, "remix-to")) |
| 122 |
type = CPUNKMSG; |
type = CPUNKMSG; |
| 123 |
|
else if (bufieq(field, "content-transfer-encoding") |
| 124 |
|
&& bufieq(content, "quoted-printable")) { |
| 125 |
|
quoted_printable = 1; |
| 126 |
|
} |
| 127 |
|
|
| 128 |
} |
} |
| 129 |
hdrend: |
hdrend: |
| 130 |
|
if (quoted_printable) |
| 131 |
|
qp_decode_message(message); |
| 132 |
|
|
| 133 |
if (type > 0 && REMAIL == 0) |
if (type > 0 && REMAIL == 0) |
| 134 |
type = DISABLED; |
type = DISABLED; |
| 135 |
switch (type) { |
switch (type) { |
| 268 |
/* create a filename */ |
/* create a filename */ |
| 269 |
{ |
{ |
| 270 |
#ifdef SHORTNAMES |
#ifdef SHORTNAMES |
| 271 |
sprintf(fname, "%s/p%02x%02x%02x%01x.%02x", POOLDIR, |
sprintf(fname, "%s%cp%02x%02x%02x%01x.%02x", POOLDIR, DIRSEP, |
| 272 |
mid->data[0], mid->data[1], mid->data[2], mid->data[3] & 15, |
mid->data[0], mid->data[1], mid->data[2], mid->data[3] & 15, |
| 273 |
packetnum); |
packetnum); |
| 274 |
#else |
#else |
| 275 |
sprintf(fname, "%s/p%02x%02x%02x%02x%02x%02x%01x", POOLDIR, |
sprintf(fname, "%s%cp%02x%02x%02x%02x%02x%02x%01x", POOLDIR, DIRSEP, |
| 276 |
packetnum, mid->data[0], mid->data[1], mid->data[2], mid->data[3], |
packetnum, mid->data[0], mid->data[1], mid->data[2], mid->data[3], |
| 277 |
mid->data[4], mid->data[5] & 15); |
mid->data[4], mid->data[5] & 15); |
| 278 |
#endif |
#endif |
| 305 |
|
|
| 306 |
void logmail(char *mailbox, BUFFER *message) |
void logmail(char *mailbox, BUFFER *message) |
| 307 |
{ |
{ |
| 308 |
|
time_t t; |
| 309 |
|
struct tm *tc; |
| 310 |
|
char line[LINELEN]; |
| 311 |
|
|
| 312 |
/* mailbox is "|program", "user@host", "stdout" or "filename" */ |
/* mailbox is "|program", "user@host", "stdout" or "filename" */ |
| 313 |
buf_rewind(message); |
buf_rewind(message); |
| 314 |
if (mailbox[0] == '\0') /* default action */ |
if (mailbox[0] == '\0') /* default action */ |
| 348 |
return; |
return; |
| 349 |
} |
} |
| 350 |
lock(mbox); |
lock(mbox); |
| 351 |
if (!bufileft(message, "From ")) |
if (!bufileft(message, "From ")) { |
| 352 |
fprintf(mbox, "From Mixmaster Wed Jan 01 00:00:00 1970\n"); |
t = time(NULL); |
| 353 |
|
tc = localtime(&t); |
| 354 |
|
strftime(line, LINELEN, "From Mixmaster %a %b %d %H:%M:%S %Y\n", tc); |
| 355 |
|
fprintf(mbox, line); |
| 356 |
|
} |
| 357 |
buf_write(message, mbox); |
buf_write(message, mbox); |
| 358 |
fprintf(mbox, "\n"); |
fprintf(mbox, "\n"); |
| 359 |
unlock(mbox); |
unlock(mbox); |
| 380 |
if (bufieq(field, "from")) |
if (bufieq(field, "from")) |
| 381 |
buf_set(from, content); |
buf_set(from, content); |
| 382 |
else if (bufieq(field, "subject")) |
else if (bufieq(field, "subject")) |
| 383 |
buf_cat(message, content); |
buf_cat(message, content); |
| 384 |
|
/* Append the subject to the message body so destination block requests |
| 385 |
|
in the subject line work too (we process the body a few lines down) */ |
| 386 |
while (buf_getline(message, line) != -1) |
while (buf_getline(message, line) != -1) |
| 387 |
if (bufifind(line, "destination-block")) { |
if (bufifind(line, "destination-block")) { |
| 388 |
buf_clear(addr); |
buf_clear(addr); |
| 389 |
request = 1; |
request = 1; |
| 390 |
if (buffind(line, "@")) { |
{ |
| 391 |
int c = 0; |
int c = 0; |
| 392 |
|
|
| 393 |
while (!strileft(line->data + line->ptr, "block")) |
while (!strileft(line->data + line->ptr, "block")) |
| 394 |
line->ptr++; |
line->ptr++; |
| 395 |
while (c != ' ') |
while (c != ' ' && c != -1) |
| 396 |
c = tolower(buf_getc(line)); |
c = tolower(buf_getc(line)); |
| 397 |
while (c == ' ') |
while (c == ' ') |
| 398 |
c = buf_getc(line); |
c = buf_getc(line); |
| 399 |
do { |
if (c != -1) |
| 400 |
buf_appendc(addr, c); |
do { |
| 401 |
c = buf_getc(line); |
buf_appendc(addr, c); |
| 402 |
} while (c > ' '); |
c = buf_getc(line); |
| 403 |
} else |
} while (c > ' '); |
| 404 |
buf_set(addr, from); |
} |
| 405 |
|
if (addr->length == 0) { |
| 406 |
|
rfc822_addr (from, addr); |
| 407 |
|
buf_chop(addr); |
| 408 |
|
} |
| 409 |
|
if (addr->length == 0) { |
| 410 |
|
return (2); |
| 411 |
|
}; |
| 412 |
|
if (! buffind(addr, "@")) |
| 413 |
|
{ |
| 414 |
|
errlog(LOG, "Ignoring blocking request for %b from %b " |
| 415 |
|
"(no @ sign in address).\n", addr, from); |
| 416 |
|
return (2); |
| 417 |
|
}; |
| 418 |
if (bufieq(addr, REMAILERADDR)) { |
if (bufieq(addr, REMAILERADDR)) { |
| 419 |
errlog(LOG, "Ignoring blocking request for %b from %b.\n", addr, from); |
errlog(LOG, "Ignoring blocking request for %b from %b.\n", addr, from); |
| 420 |
return (2); |
return (2); |
| 421 |
} |
} |
| 422 |
|
if (bufleft(addr, "/")) { |
| 423 |
|
errlog(LOG, "Ignoring blocking request: %b from %b is a regex.\n", |
| 424 |
|
addr, from); |
| 425 |
|
return (2); |
| 426 |
|
} |
| 427 |
if (buf_ieq(addr, from)) |
if (buf_ieq(addr, from)) |
| 428 |
errlog(NOTICE, "Blocking request for %b\n", addr); |
errlog(NOTICE, "Blocking request for %b\n", addr); |
| 429 |
else |
else |
| 445 |
free( destblklst ); |
free( destblklst ); |
| 446 |
if (f != NULL) { |
if (f != NULL) { |
| 447 |
lock(f); |
lock(f); |
| 448 |
sendinfofile(BLOCKFILE, NULL, line, NULL); |
sendinfofile(BLOCKFILE, NULL, addr, NULL); |
| 449 |
if (line->length) { |
if (line->length) { |
| 450 |
if (domain) |
if (domain) |
| 451 |
fprintf(f, "%s", line->data + sizeof("postmaster") - 1); |
fprintf(f, "%s", line->data + sizeof("postmaster") - 1); |