Better checking for empty *.msg netmails

This commit is contained in:
Michiel Broek 2005-02-03 20:23:29 +00:00
parent be82b565ac
commit 7d2e269c05
3 changed files with 159 additions and 135 deletions

View File

@ -12,6 +12,13 @@ v0.71.2 16-Jan-2005
data frames, this will case uncompress error -5 because zero data frames, this will case uncompress error -5 because zero
bytes can't be compressed ar all. bytes can't be compressed ar all.
mbfido:
Empty *.msg netmails for our own system are dropped with and
logged (just like received empty netmails). Empty netmails to
remote systems are still stored in the netmail base.
Added debug logging for exporting netmails from the messagebase
so that we later can decide to mark these messages auto deleted.
mbnntp: mbnntp:
Does now send the right mime headers recognised by new clients. Does now send the right mime headers recognised by new clients.
Fixed compile problem with some compilers. Fixed compile problem with some compilers.

View File

@ -4,7 +4,7 @@
* Purpose ...............: Read *.msg messages * Purpose ...............: Read *.msg messages
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -92,10 +92,11 @@ int toss_msgs(void)
* 3 = Missing zone info * 3 = Missing zone info
* 4 = No ftn network or netmailboard in setup * 4 = No ftn network or netmailboard in setup
* 5 = Can't open JAM area * 5 = Can't open JAM area
* 6 = Empty local netmail, dropped.
*/ */
int toss_onemsg(char *msgname) int toss_onemsg(char *msgname)
{ {
int rc = 0, islocal; int rc = 0, islocal, empty = TRUE;
char *temp, *dospath, *flagstr = NULL, *l, *r, *msgid = NULL; char *temp, *dospath, *flagstr = NULL, *l, *r, *msgid = NULL;
char fromUserName[36], toUserName[36], subject[72], DateTime[20]; char fromUserName[36], toUserName[36], subject[72], DateTime[20];
FILE *fp, *np; FILE *fp, *np;
@ -230,7 +231,12 @@ int toss_onemsg(char *msgname)
flagstr = xstrcpy(buf + 8); flagstr = xstrcpy(buf + 8);
Syslog('m', "^aFLAGS: %s", flagstr); Syslog('m', "^aFLAGS: %s", flagstr);
} }
if (buf[0] != '\0') {
if ((buf[0] != '\001') && (strcmp(buf, (char *)"--- ")))
empty = FALSE;
}
} }
Syslog('m', "Mail is %sempty", empty ? "":"not ");
Syslog('m', "From %d:%d/%d.%d to %d:%d/%d.%d", origZone, origNet, origNode, origPoint, destZone, destNet, destNode, destPoint); Syslog('m', "From %d:%d/%d.%d to %d:%d/%d.%d", origZone, origNet, origNode, origPoint, destZone, destNet, destNode, destPoint);
@ -291,6 +297,14 @@ int toss_onemsg(char *msgname)
/* /*
* Message is local, make the message appear as a received netmail * Message is local, make the message appear as a received netmail
*/ */
if (empty) {
Syslog('+', "Empty local netmail for %s dropped", toUserName);
Msg_UnLock();
Msg_Close();
fclose(fp);
free(temp);
return 6;
}
islocal = TRUE; islocal = TRUE;
if ((strncasecmp(toUserName, "sysop", 5) == 0) || if ((strncasecmp(toUserName, "sysop", 5) == 0) ||
(strncasecmp(toUserName, "postmaster", 10) == 0) || (strncasecmp(toUserName, "postmaster", 10) == 0) ||

View File

@ -4,7 +4,7 @@
* Purpose ...............: Scan for outgoing mail. * Purpose ...............: Scan for outgoing mail.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -75,61 +75,60 @@ void ExportEmail(unsigned long);
*/ */
void ScanMail(int DoAll) void ScanMail(int DoAll)
{ {
int DoFull = FALSE, i = 0; int DoFull = FALSE, i = 0;
unsigned long msg; unsigned long msg;
char *Fname = NULL, *temp, *path; char *Fname = NULL, *temp, *path;
FILE *fp; FILE *fp;
if (DoAll) { if (DoAll) {
DoFull = TRUE; DoFull = TRUE;
} else { } else {
scanned = 0; scanned = 0;
Fname = calloc(PATH_MAX, sizeof(char)); Fname = calloc(PATH_MAX, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
sprintf(Fname, "%s/tmp/echomail.jam", getenv("MBSE_ROOT")); sprintf(Fname, "%s/tmp/echomail.jam", getenv("MBSE_ROOT"));
if ((fp = fopen(Fname, "r")) != NULL) { if ((fp = fopen(Fname, "r")) != NULL) {
while ((fgets(temp, PATH_MAX - 1, fp)) != NULL) { while ((fgets(temp, PATH_MAX - 1, fp)) != NULL) {
path = strtok(temp, " "); path = strtok(temp, " ");
msg = atol(strtok(NULL, "\n")); msg = atol(strtok(NULL, "\n"));
Syslog('+', "Export message %lu from %s", msg, path); Syslog('+', "Export message %lu from %s", msg, path);
ScanOne(path, msg); ScanOne(path, msg);
i++; i++;
Nopper(); Nopper();
} }
fclose(fp); fclose(fp);
unlink(Fname); unlink(Fname);
}
sprintf(Fname, "%s/tmp/netmail.jam", getenv("MBSE_ROOT"));
if ((fp = fopen(Fname, "r")) != NULL) {
while ((fgets(temp, PATH_MAX - 1, fp)) != NULL) {
path = strtok(temp, " ");
msg = atol(strtok(NULL, "\n"));
Syslog('+', "Export message %lu from %s", msg, path);
ScanOne(path, msg);
i++;
Nopper();
}
fclose(fp);
unlink(Fname);
}
if ((i != scanned) || (i == 0)) {
Syslog('+', "Not all messages exported, forcing full mail scan");
Syslog('+', "i=%d scanned=%d", i, scanned);
DoFull = TRUE;
}
free(Fname);
free(temp);
} }
if (DoFull) sprintf(Fname, "%s/tmp/netmail.jam", getenv("MBSE_ROOT"));
ScanFull(); if ((fp = fopen(Fname, "r")) != NULL) {
while ((fgets(temp, PATH_MAX - 1, fp)) != NULL) {
path = strtok(temp, " ");
msg = atol(strtok(NULL, "\n"));
Syslog('+', "Export message %lu from %s", msg, path);
ScanOne(path, msg);
i++;
Nopper();
}
fclose(fp);
unlink(Fname);
}
if (echo_out || net_out) if ((i != scanned) || (i == 0)) {
do_flush = TRUE; Syslog('+', "Not all messages exported, forcing full mail scan to fix this");
RemoveSema((char *)"mailout"); DoFull = TRUE;
}
free(Fname);
free(temp);
}
if (DoFull)
ScanFull();
if (echo_out || net_out)
do_flush = TRUE;
RemoveSema((char *)"mailout");
} }
@ -673,98 +672,98 @@ void ExportEcho(sysconnect L, unsigned long MsgNum, fa_list **sbl)
*/ */
void ExportNews(unsigned long MsgNum, fa_list **sbl) void ExportNews(unsigned long MsgNum, fa_list **sbl)
{ {
char *p; char *p;
int seenlen, oldnet, flags = 0; int seenlen, oldnet, flags = 0;
char sbe[16]; char sbe[16];
fa_list *tmpl; fa_list *tmpl;
FILE *qp; FILE *qp;
faddr *from, *dest; faddr *from, *dest;
int kludges = TRUE; int kludges = TRUE;
qp = tmpfile(); qp = tmpfile();
Syslog('m', "Msg.From %s", Msg.From); Syslog('m', "Msg.From %s", Msg.From);
Syslog('m', "Msg.FromAddress %s", Msg.FromAddress); Syslog('m', "Msg.FromAddress %s", Msg.FromAddress);
Syslog('m', "Msg.To %s", Msg.To); Syslog('m', "Msg.To %s", Msg.To);
Syslog('m', "Msg.ToAdrress", Msg.ToAddress); Syslog('m', "Msg.ToAdrress", Msg.ToAddress);
flags |= (Msg.Private) ? M_PVT : 0; flags |= (Msg.Private) ? M_PVT : 0;
from = fido2faddr(msgs.Aka); from = fido2faddr(msgs.Aka);
/* /*
* Add name with echo to news gate. * Add name with echo to news gate.
*/ */
from->name = xstrcpy(Msg.From); from->name = xstrcpy(Msg.From);
Syslog('m', "from %s", ascinode(from, 0xff)); Syslog('m', "from %s", ascinode(from, 0xff));
dest = NULL; dest = NULL;
fprintf(qp, "AREA:%s\n", msgs.Tag); fprintf(qp, "AREA:%s\n", msgs.Tag);
Syslog('m', "AREA:%s", msgs.Tag); Syslog('m', "AREA:%s", msgs.Tag);
if (Msg_Read(MsgNum, 79)) { if (Msg_Read(MsgNum, 79)) {
if ((p = (char *)MsgText_First()) != NULL) { if ((p = (char *)MsgText_First()) != NULL) {
do { do {
if (kludges) { if (kludges) {
if (p[0] != '\001') { if (p[0] != '\001') {
/* /*
* After the first kludges, send RFC headers * After the first kludges, send RFC headers
*/ */
kludges = FALSE; kludges = FALSE;
fprintf(qp, "\001TID: MBSE-FIDO %s (%s-%s)\n", VERSION, OsName(), OsCPU()); fprintf(qp, "\001TID: MBSE-FIDO %s (%s-%s)\n", VERSION, OsName(), OsCPU());
fprintf(qp, "Subject: %s\n", Msg.Subject); fprintf(qp, "Subject: %s\n", Msg.Subject);
Syslog('m', "Subject: %s", Msg.Subject); Syslog('m', "Subject: %s", Msg.Subject);
fprintf(qp, "\n"); fprintf(qp, "\n");
Syslog('m', "\n"); Syslog('m', "\n");
fprintf(qp, "%s\n", p); fprintf(qp, "%s\n", p);
Syslog('m', "%s", p); Syslog('m', "%s", p);
} else { } else {
fprintf(qp, "%s\n", p+1); fprintf(qp, "%s\n", p+1);
Syslog('m', "%s", p+1); Syslog('m', "%s", p+1);
} }
} else { } else {
fprintf(qp, "%s", p); fprintf(qp, "%s", p);
Syslog('m', "%s", printable(p, 0)); Syslog('m', "%s", printable(p, 0));
if (strncmp(p, " * Origin:", 10) == 0) if (strncmp(p, " * Origin:", 10) == 0)
break; break;
/* /*
* Only append NL if not the last line * Only append NL if not the last line
*/ */
fprintf(qp, "\n"); fprintf(qp, "\n");
}
} while ((p = (char *)MsgText_Next()) != NULL);
} }
} while ((p = (char *)MsgText_Next()) != NULL);
} }
}
seenlen = MAXSEEN + 1; seenlen = MAXSEEN + 1;
/* /*
* Ensure that it will not match the first entry. * Ensure that it will not match the first entry.
*/ */
oldnet = (*sbl)->addr->net - 1; oldnet = (*sbl)->addr->net - 1;
for (tmpl = *sbl; tmpl; tmpl = tmpl->next) { for (tmpl = *sbl; tmpl; tmpl = tmpl->next) {
if (tmpl->addr->net == oldnet) if (tmpl->addr->net == oldnet)
sprintf(sbe, " %u", tmpl->addr->node); sprintf(sbe, " %u", tmpl->addr->node);
else else
sprintf(sbe, " %u/%u", tmpl->addr->net, tmpl->addr->node); sprintf(sbe, " %u/%u", tmpl->addr->net, tmpl->addr->node);
oldnet = tmpl->addr->net; oldnet = tmpl->addr->net;
seenlen += strlen(sbe); seenlen += strlen(sbe);
if (seenlen > MAXSEEN) { if (seenlen > MAXSEEN) {
seenlen = 0; seenlen = 0;
fprintf(qp, "\nSEEN-BY:"); fprintf(qp, "\nSEEN-BY:");
sprintf(sbe, " %u/%u", tmpl->addr->net, tmpl->addr->node); sprintf(sbe, " %u/%u", tmpl->addr->net, tmpl->addr->node);
seenlen = strlen(sbe); seenlen = strlen(sbe);
}
fprintf(qp, "%s", sbe);
} }
fprintf(qp, "\n\001PATH: %u/%u\n", msgs.Aka.net, msgs.Aka.node); fprintf(qp, "%s", sbe);
Syslog('m', "\\001PATH: %u/%u", msgs.Aka.net, msgs.Aka.node); }
fprintf(qp, "\n\001PATH: %u/%u\n", msgs.Aka.net, msgs.Aka.node);
Syslog('m', "\\001PATH: %u/%u", msgs.Aka.net, msgs.Aka.node);
rewind(qp); rewind(qp);
most_debug = TRUE; most_debug = TRUE;
ftn2rfc(from, dest, NULL, NULL, Msg.Written + (gmt_offset((time_t)0) * 60), flags, qp); ftn2rfc(from, dest, NULL, NULL, Msg.Written + (gmt_offset((time_t)0) * 60), flags, qp);
most_debug = FALSE; most_debug = FALSE;
tidy_faddr(from); tidy_faddr(from);
fclose(qp); fclose(qp);
} }
@ -775,7 +774,7 @@ void ExportNews(unsigned long MsgNum, fa_list **sbl)
void ExportNet(unsigned long MsgNum, int UUCPgate) void ExportNet(unsigned long MsgNum, int UUCPgate)
{ {
char *p, *q, ext[4], fromname[37], flavor, MailFrom[128], MailTo[128]; char *p, *q, ext[4], fromname[37], flavor, MailFrom[128], MailTo[128];
int i, rc, flags = 0, first, is_fmpt = FALSE, is_topt = FALSE, is_intl = FALSE, mypoint = FALSE; int i, rc, flags = 0, first, is_fmpt = FALSE, is_topt = FALSE, is_intl = FALSE, mypoint = FALSE, empty = TRUE;
FILE *qp, *fp, *fl; FILE *qp, *fp, *fl;
fidoaddr Dest, Route, *dest; fidoaddr Dest, Route, *dest;
time_t now; time_t now;
@ -802,10 +801,14 @@ void ExportNet(unsigned long MsgNum, int UUCPgate)
is_intl = TRUE; is_intl = TRUE;
if (strncmp(p, "--- ", 4) == 0) if (strncmp(p, "--- ", 4) == 0)
break; break;
if ((p[0] != '\001') && (p[0] != '\0')) {
empty = FALSE;
}
} while ((p = (char *)MsgText_Next()) != NULL); } while ((p = (char *)MsgText_Next()) != NULL);
} }
} }
Syslog('m', " netmail is %sempt", empty ? "":"not ");
/* /*
* Check if this a netmail to our own local UUCP gate. * Check if this a netmail to our own local UUCP gate.
*/ */