Fixes for netmail handling with missing zone info

This commit is contained in:
Michiel Broek 2002-12-22 14:41:33 +00:00
parent 16256e4a39
commit 0b3e629118
7 changed files with 1139 additions and 1141 deletions

View File

@ -32,6 +32,12 @@ v0.35.07 11-Dec-2002
The index command displays LFN names in the webpages again. The index command displays LFN names in the webpages again.
The real download still sends the 8.3 name. The real download still sends the 8.3 name.
mbfido:
Better detection of zone information in netmails when netmail
was stored in a netmail packet of a different network and the
netmail misses a lot of kludges. Better logging of processed
netmails.
mbcico: mbcico:
Code cleanup in opentcp, better handling of given ports and Code cleanup in opentcp, better handling of given ports and
better logging. better logging.

View File

@ -137,7 +137,7 @@ int Bounce(faddr *f, faddr *t, FILE *fp, char *reason)
fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name);
fprintf(np, "%s\r", TearLine()); fprintf(np, "%s\r", TearLine());
Now = time(NULL) - (gmt_offset((time_t)0) * 60); Now = time(NULL) - (gmt_offset((time_t)0) * 60);
rc = postnetmail(np, from, f, NULL, (char *)"Bounced message", Now, 0x0000, FALSE); rc = postnetmail(np, from, f, NULL, (char *)"Bounced message", Now, 0x0000, FALSE, from->zone, f->zone);
tidy_faddr(from); tidy_faddr(from);
fclose(np); fclose(np);

View File

@ -136,7 +136,7 @@ int Ping(faddr *f, faddr *t, FILE *fp, int intransit)
fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name);
fprintf(np, "%s\r", TearLine()); fprintf(np, "%s\r", TearLine());
Now = time(NULL) - (gmt_offset((time_t)0) * 60); Now = time(NULL) - (gmt_offset((time_t)0) * 60);
rc = postnetmail(np, from, f, NULL, (char *)"Re: Ping", Now, 0x0000, FALSE); rc = postnetmail(np, from, f, NULL, (char *)"Re: Ping", Now, 0x0000, FALSE, from->zone, f->zone);
tidy_faddr(from); tidy_faddr(from);
fclose(np); fclose(np);

View File

@ -70,11 +70,11 @@ extern int net_bad; /* Bad netmails */
* 2 - Can't find netmail board. * 2 - Can't find netmail board.
* *
*/ */
int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t mdate, int flags, int DoPing) int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t mdate,
int flags, int DoPing, unsigned int fzone, unsigned int tzone)
{ {
char *p, *msgid = NULL, *reply = NULL, *flagstr = NULL; char *p, *msgid = NULL, *reply = NULL, *flagstr = NULL;
char name[36], *buf, *l, *r, *q; char name[36], *buf, *l, *r, *q, System[36], ext[4];
char System[36], ext[4];
int result = 1, email = FALSE, fmpt = 0, topt = 0; int result = 1, email = FALSE, fmpt = 0, topt = 0;
faddr *ta, *ra; faddr *ta, *ra;
fidoaddr na, routeto, Orig; fidoaddr na, routeto, Orig;
@ -90,7 +90,7 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
/* /*
* Extract MSGID and REPLY kludges from this netmail. * Extract MSGID and REPLY kludges from this netmail.
*/ */
buf = calloc(2048, sizeof(char)); buf = calloc(2049, sizeof(char));
rewind(fp); rewind(fp);
while ((fgets(buf, 2048, fp)) != NULL) { while ((fgets(buf, 2048, fp)) != NULL) {
Striplf(buf); Striplf(buf);
@ -103,7 +103,7 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
l = strtok(buf," \n"); l = strtok(buf," \n");
l = strtok(NULL," \n"); l = strtok(NULL," \n");
if ((ta = parsefnode(l))) { if ((ta = parsefnode(l))) {
if (ta->zone == f->zone && ta->net == f->net && ta->node == f->node && !fmpt && ta->point) { if (ta->net == f->net && ta->node == f->node && !fmpt && ta->point) {
Syslog('m', "Setting pointinfo (%d) from MSGID", ta->point); Syslog('m', "Setting pointinfo (%d) from MSGID", ta->point);
fmpt = f->point = ta->point; fmpt = f->point = ta->point;
} }
@ -214,8 +214,20 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
if (topt) if (topt)
t->point = topt; t->point = topt;
Syslog('m', "Final netmail from: %s", ascfnode(f, 0xff)); /*
Syslog('m', "Final netmail to : %s", ascfnode(t, 0xff)); * If zone info is still missing, set the defaults which came from the
* original mail packet addressing.
*/
if (fzone && (f->zone == 0))
f->zone = fzone;
if (tzone && (t->zone == 0))
t->zone = tzone;
l = xstrcpy(ascfnode(f, 0xff));
r = xstrcpy(ascfnode(t, 0xff));
Syslog('+', "Netmail from \"%s\" to \"%s\"", l, r);
free(l);
free(r);
memset(&na, 0, sizeof(na)); memset(&na, 0, sizeof(na));
na.zone = t->zone; na.zone = t->zone;
@ -243,8 +255,7 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
/* /*
* Send this netmail via ftn2rfc -> postemail. * Send this netmail via ftn2rfc -> postemail.
*/ */
result = ftn2rfc(f, t, subject, orig, mdate, flags, fp); return result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
return result;
} }
/* /*

View File

@ -1,8 +1,8 @@
#ifndef _POSTNETMAIL_H #ifndef _POSTNETMAIL_H
#define _POSTNETMAIL_H #define _POSTNETMAIL_H
/* $Id$ */
int postnetmail(FILE *, faddr *, faddr *, char *, char *, time_t, int, int); int postnetmail(FILE *, faddr *, faddr *, char *, char *, time_t, int, int, unsigned int, unsigned int);
#endif #endif

View File

@ -134,23 +134,19 @@ int kludgewrite(char *s, FILE *fp)
*/ */
int rfc2ftn(FILE *fp, faddr *recipient) int rfc2ftn(FILE *fp, faddr *recipient)
{ {
char sbe[16], *p, *q, *temp, *origin; char sbe[16], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL;
int i, rc, incode, outcode, pgpsigned, newsmode; int i, rc, incode, outcode, pgpsigned, newsmode, seenlen, oldnet;
int seenlen, oldnet;
rfcmsg *msg = NULL, *tmsg, *tmp; rfcmsg *msg = NULL, *tmsg, *tmp;
ftnmsg *fmsg = NULL; ftnmsg *fmsg = NULL;
FILE *ofp; FILE *ofp;
fa_list *sbl = NULL, *ptl = NULL, *tmpl; fa_list *sbl = NULL, *ptl = NULL, *tmpl;
faddr *ta, *fta; faddr *ta, *fta;
unsigned long svmsgid, svreply; unsigned long svmsgid, svreply, acup_n = 0;
int sot_kludge = FALSE, eot_kludge = FALSE, qp_or_base64 = FALSE, tinyorigin = FALSE; int sot_kludge = FALSE, eot_kludge = FALSE, qp_or_base64 = FALSE, tinyorigin = FALSE;
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders; int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders, html_message = FALSE;
char newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL;
unsigned long acup_n = 0;
int html_message = FALSE;
time_t Now; time_t Now;
temp = calloc(4096, sizeof(char)); temp = calloc(4097, sizeof(char));
Syslog('m', "Entering rfc2ftn"); Syslog('m', "Entering rfc2ftn");
if (recipient) if (recipient)
Syslog('m', "Recipient: %s", ascfnode(recipient, 0xff)); Syslog('m', "Recipient: %s", ascfnode(recipient, 0xff));
@ -351,7 +347,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
p[strlen(p)-1]='\0'; p[strlen(p)-1]='\0';
if (strcasestr(q,p)) if (strcasestr(q,p))
removereplyto = TRUE; removereplyto = TRUE;
// free(r);
} }
} }
Syslog('n', "removereplyto = %s", removereplyto ? "True":"False"); Syslog('n', "removereplyto = %s", removereplyto ? "True":"False");
@ -369,7 +364,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
p[strlen(p)-1]='\0'; p[strlen(p)-1]='\0';
if (strcasestr(q,p)) if (strcasestr(q,p))
removereturnto = TRUE; removereturnto = TRUE;
// free(r);
} }
} }
if (!removereturnto) if (!removereturnto)
@ -436,13 +430,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
return 1; return 1;
} }
// Syslog('-', "1");
if (newsmode) { if (newsmode) {
// Syslog('-', "1a");
fprintf(ofp, "AREA:%s\n", msgs.Tag); fprintf(ofp, "AREA:%s\n", msgs.Tag);
// Syslog('-', "1b");
} else { } else {
if (fmsg->to->point != 0) if (fmsg->to->point != 0)
fprintf(ofp, "\001TOPT %d\n", fmsg->to->point); fprintf(ofp, "\001TOPT %d\n", fmsg->to->point);
@ -451,7 +440,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
fprintf(ofp, "\001INTL %d:%d/%d %d:%d/%d\n", fmsg->to->zone, fmsg->to->net, fmsg->to->node, fprintf(ofp, "\001INTL %d:%d/%d %d:%d/%d\n", fmsg->to->zone, fmsg->to->net, fmsg->to->node,
fmsg->from->zone, fmsg->from->net, fmsg->from->node); fmsg->from->zone, fmsg->from->net, fmsg->from->node);
} }
// Syslog('-', "1c");
fprintf(ofp, "\001MSGID: %s %08lx\n", MBSE_SS(fmsg->msgid_a),fmsg->msgid_n); fprintf(ofp, "\001MSGID: %s %08lx\n", MBSE_SS(fmsg->msgid_a),fmsg->msgid_n);
if (fmsg->reply_s) if (fmsg->reply_s)
fprintf(ofp, "\1REPLY: %s\n", fmsg->reply_s); fprintf(ofp, "\1REPLY: %s\n", fmsg->reply_s);
@ -461,17 +449,14 @@ int rfc2ftn(FILE *fp, faddr *recipient)
fprintf(ofp, "\001TZUTC: %s\n", gmtoffset(Now)); fprintf(ofp, "\001TZUTC: %s\n", gmtoffset(Now));
fmsg->subj = oldsubj; fmsg->subj = oldsubj;
if ((p = hdr((char *)"X-FTN-REPLYADDR",msg))) { if ((p = hdr((char *)"X-FTN-REPLYADDR",msg))) {
// Syslog('n', "replyaddr 1 %s", p);
hdrsize += 10+strlen(p); hdrsize += 10+strlen(p);
fprintf(ofp,"\1REPLYADDR:"); fprintf(ofp,"\1REPLYADDR:");
kludgewrite(p,ofp); kludgewrite(p,ofp);
} else if (replyaddr) { } else if (replyaddr) {
// Syslog('n', "replyaddr 2");
hdrsize += 10+strlen(replyaddr); hdrsize += 10+strlen(replyaddr);
fprintf(ofp,"\1REPLYADDR: "); fprintf(ofp,"\1REPLYADDR: ");
kludgewrite(replyaddr,ofp); kludgewrite(replyaddr,ofp);
} }
// Syslog('-', "2");
if ((p = hdr((char *)"X-FTN-REPLYTO",msg))) { if ((p = hdr((char *)"X-FTN-REPLYTO",msg))) {
hdrsize += 8+strlen(p); hdrsize += 8+strlen(p);
fprintf(ofp,"\1REPLYTO:"); fprintf(ofp,"\1REPLYTO:");
@ -491,8 +476,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
if (!strcasestr(q,p)) { if (!strcasestr(q,p)) {
fprintf(ofp,"\1REPLYTO: %s %s\n", ascfnode(ta,0x1f), ta->name); fprintf(ofp,"\1REPLYTO: %s %s\n", ascfnode(ta,0x1f), ta->name);
} }
tidy_faddr(ta);
} }
tidy_faddr(ta);
} }
} }
if ((p=strip_flags(hdr((char *)"X-FTN-FLAGS",msg)))) { if ((p=strip_flags(hdr((char *)"X-FTN-FLAGS",msg)))) {
@ -514,7 +499,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
fprintf(ofp, "\001PID: MBSE-FIDO %s\n", VERSION); fprintf(ofp, "\001PID: MBSE-FIDO %s\n", VERSION);
} }
} }
// Syslog('-', "3");
hdrsize += 8 + strlen(getchrs(outcode)); hdrsize += 8 + strlen(getchrs(outcode));
fprintf(ofp, "\001CHRS: %s\n", getchrs(outcode)); fprintf(ofp, "\001CHRS: %s\n", getchrs(outcode));
if (html_message) { if (html_message) {
@ -548,8 +533,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
} }
if ((splitpart == 0) || (hdrsize < MAXHDRSIZE)) { if ((splitpart == 0) || (hdrsize < MAXHDRSIZE)) {
for (tmp = msg; tmp; tmp = tmp->next) { for (tmp = msg; tmp; tmp = tmp->next) {
if ((!strncmp(tmp->key,"X-Fsc-",6)) || if ((!strncmp(tmp->key,"X-Fsc-",6)) || (!strncmp(tmp->key,"X-FTN-",6) &&
(!strncmp(tmp->key,"X-FTN-",6) &&
strcasecmp(tmp->key,"X-FTN-Tearline") && strcasecmp(tmp->key,"X-FTN-Tearline") &&
strcasecmp(tmp->key,"X-FTN-Origin") && strcasecmp(tmp->key,"X-FTN-Origin") &&
strcasecmp(tmp->key,"X-FTN-Sender") && strcasecmp(tmp->key,"X-FTN-Sender") &&
@ -605,7 +589,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
kludgewrite(tmp->val,ofp); kludgewrite(tmp->val,ofp);
} }
// Syslog('-', "4");
/* /*
* Add the Received: header from this system to the mesage. * Add the Received: header from this system to the mesage.
*/ */
@ -627,7 +610,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
kludgewrite(hdrconv(tmp->val, incode, outcode),ofp); kludgewrite(hdrconv(tmp->val, incode, outcode),ofp);
} }
} }
// Syslog('-', "5");
rfcheaders=0; rfcheaders=0;
for (tmp=msg;tmp;tmp=tmp->next) { for (tmp=msg;tmp;tmp=tmp->next) {
if ((needputrfc(tmp) > 1)) { if ((needputrfc(tmp) > 1)) {
@ -650,11 +633,9 @@ int rfc2ftn(FILE *fp, faddr *recipient)
fprintf(ofp,PGP_SIGNED_BEGIN"\n"); fprintf(ofp,PGP_SIGNED_BEGIN"\n");
} }
if (replyaddr) { if (replyaddr) {
// free(replyaddr); /* Gives SIGSEGV */
replyaddr = NULL; replyaddr = NULL;
} }
// Syslog('-', "6");
if (needsplit) { if (needsplit) {
fprintf(ofp," * Continuation %d of a split message *\n\n", splitpart); fprintf(ofp," * Continuation %d of a split message *\n\n", splitpart);
needsplit = FALSE; needsplit = FALSE;
@ -838,7 +819,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
if (newsmode) if (newsmode)
rc = postecho(NULL, fmsg->from, fmsg->to, origin, fmsg->subj, fmsg->date, fmsg->flags, 0, ofp, FALSE); rc = postecho(NULL, fmsg->from, fmsg->to, origin, fmsg->subj, fmsg->date, fmsg->flags, 0, ofp, FALSE);
else else
rc = postnetmail(ofp, fmsg->from, fmsg->to, origin, fmsg->subj, fmsg->date, fmsg->flags, FALSE); rc = postnetmail(ofp, fmsg->from, fmsg->to, origin, fmsg->subj, fmsg->date,
fmsg->flags, FALSE, fmsg->from->zone, fmsg->to->zone);
free(origin); free(origin);
fclose(ofp); fclose(ofp);

View File

@ -92,7 +92,7 @@ static int at_zero = 0;
* Internal prototypes * Internal prototypes
*/ */
char *aread(char *, int, FILE *); char *aread(char *, int, FILE *);
int importmsg(faddr *, faddr *, faddr *, char *, char *, time_t, int, int, FILE *); int importmsg(faddr *, faddr *, faddr *, char *, char *, time_t, int, int, FILE *, unsigned int);
@ -149,7 +149,8 @@ char *aread(char *s, int count, FILE *fp)
* 5 - Locking error. * 5 - Locking error.
* *
*/ */
int importmsg(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t mdate, int flags, int cost, FILE *fp) int importmsg(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t mdate,
int flags, int cost, FILE *fp, unsigned int tzone)
{ {
char *buf, *marea = NULL; char *buf, *marea = NULL;
int echomail = FALSE, rc = 0, bad = FALSE, Known = FALSE, FirstLine; int echomail = FALSE, rc = 0, bad = FALSE, Known = FALSE, FirstLine;
@ -234,11 +235,12 @@ int importmsg(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t
FirstLine = FALSE; FirstLine = FALSE;
} /* end of checking kludges */ } /* end of checking kludges */
if (echomail) {
if (echomail) f->zone = p_from->zone;
t->zone = tzone;
rc = postecho(p_from, f, t, orig, subj, mdate, flags, cost, fp, TRUE); rc = postecho(p_from, f, t, orig, subj, mdate, flags, cost, fp, TRUE);
else } else
rc = postnetmail(fp, f, t, orig, subj, mdate, flags, TRUE); rc = postnetmail(fp, f, t, orig, subj, mdate, flags, TRUE, p_from->zone, tzone);
free(buf); free(buf);
return rc; return rc;
@ -418,9 +420,6 @@ int getmessage(FILE *pkt, faddr *p_from, faddr *p_to)
return 3; return 3;
} }
f.zone = p_from->zone;
t.zone = p_to->zone;
if ((fp = tmpfile()) == NULL) { if ((fp = tmpfile()) == NULL) {
WriteError("$unable to open temporary file"); WriteError("$unable to open temporary file");
return 4; return 4;
@ -463,7 +462,7 @@ int getmessage(FILE *pkt, faddr *p_from, faddr *p_to)
} }
} }
rc = importmsg(p_from, &f,&t,orig,subj,mdate,flags,cost,fp); rc = importmsg(p_from, &f, &t, orig, subj, mdate, flags, cost, fp, p_to->zone);
if (rc) if (rc)
rc+=10; rc+=10;
if (rc > maxrc) if (rc > maxrc)