Fixes for netmail handling with missing zone info
This commit is contained in:
parent
16256e4a39
commit
0b3e629118
@ -32,6 +32,12 @@ v0.35.07 11-Dec-2002
|
||||
The index command displays LFN names in the webpages again.
|
||||
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:
|
||||
Code cleanup in opentcp, better handling of given ports and
|
||||
better logging.
|
||||
|
@ -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, "%s\r", TearLine());
|
||||
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);
|
||||
|
||||
fclose(np);
|
||||
|
@ -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, "%s\r", TearLine());
|
||||
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);
|
||||
|
||||
fclose(np);
|
||||
|
@ -70,11 +70,11 @@ extern int net_bad; /* Bad netmails */
|
||||
* 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 name[36], *buf, *l, *r, *q;
|
||||
char System[36], ext[4];
|
||||
char name[36], *buf, *l, *r, *q, System[36], ext[4];
|
||||
int result = 1, email = FALSE, fmpt = 0, topt = 0;
|
||||
faddr *ta, *ra;
|
||||
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.
|
||||
*/
|
||||
buf = calloc(2048, sizeof(char));
|
||||
buf = calloc(2049, sizeof(char));
|
||||
rewind(fp);
|
||||
while ((fgets(buf, 2048, fp)) != NULL) {
|
||||
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(NULL," \n");
|
||||
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);
|
||||
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)
|
||||
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));
|
||||
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.
|
||||
*/
|
||||
result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
|
||||
return result;
|
||||
return result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef _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
|
||||
|
||||
|
@ -134,23 +134,19 @@ int kludgewrite(char *s, FILE *fp)
|
||||
*/
|
||||
int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
{
|
||||
char sbe[16], *p, *q, *temp, *origin;
|
||||
int i, rc, incode, outcode, pgpsigned, newsmode;
|
||||
int seenlen, oldnet;
|
||||
char sbe[16], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL;
|
||||
int i, rc, incode, outcode, pgpsigned, newsmode, seenlen, oldnet;
|
||||
rfcmsg *msg = NULL, *tmsg, *tmp;
|
||||
ftnmsg *fmsg = NULL;
|
||||
FILE *ofp;
|
||||
fa_list *sbl = NULL, *ptl = NULL, *tmpl;
|
||||
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 needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders;
|
||||
char newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL;
|
||||
unsigned long acup_n = 0;
|
||||
int html_message = FALSE;
|
||||
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders, html_message = FALSE;
|
||||
time_t Now;
|
||||
|
||||
temp = calloc(4096, sizeof(char));
|
||||
temp = calloc(4097, sizeof(char));
|
||||
Syslog('m', "Entering rfc2ftn");
|
||||
if (recipient)
|
||||
Syslog('m', "Recipient: %s", ascfnode(recipient, 0xff));
|
||||
@ -351,7 +347,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
p[strlen(p)-1]='\0';
|
||||
if (strcasestr(q,p))
|
||||
removereplyto = TRUE;
|
||||
// free(r);
|
||||
}
|
||||
}
|
||||
Syslog('n', "removereplyto = %s", removereplyto ? "True":"False");
|
||||
@ -369,7 +364,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
p[strlen(p)-1]='\0';
|
||||
if (strcasestr(q,p))
|
||||
removereturnto = TRUE;
|
||||
// free(r);
|
||||
}
|
||||
}
|
||||
if (!removereturnto)
|
||||
@ -436,13 +430,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Syslog('-', "1");
|
||||
|
||||
if (newsmode) {
|
||||
|
||||
// Syslog('-', "1a");
|
||||
fprintf(ofp, "AREA:%s\n", msgs.Tag);
|
||||
// Syslog('-', "1b");
|
||||
} else {
|
||||
if (fmsg->to->point != 0)
|
||||
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,
|
||||
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);
|
||||
if (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));
|
||||
fmsg->subj = oldsubj;
|
||||
if ((p = hdr((char *)"X-FTN-REPLYADDR",msg))) {
|
||||
// Syslog('n', "replyaddr 1 %s", p);
|
||||
hdrsize += 10+strlen(p);
|
||||
fprintf(ofp,"\1REPLYADDR:");
|
||||
kludgewrite(p,ofp);
|
||||
} else if (replyaddr) {
|
||||
// Syslog('n', "replyaddr 2");
|
||||
hdrsize += 10+strlen(replyaddr);
|
||||
fprintf(ofp,"\1REPLYADDR: ");
|
||||
kludgewrite(replyaddr,ofp);
|
||||
}
|
||||
// Syslog('-', "2");
|
||||
if ((p = hdr((char *)"X-FTN-REPLYTO",msg))) {
|
||||
hdrsize += 8+strlen(p);
|
||||
fprintf(ofp,"\1REPLYTO:");
|
||||
@ -491,8 +476,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
if (!strcasestr(q,p)) {
|
||||
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)))) {
|
||||
@ -514,7 +499,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
fprintf(ofp, "\001PID: MBSE-FIDO %s\n", VERSION);
|
||||
}
|
||||
}
|
||||
// Syslog('-', "3");
|
||||
|
||||
hdrsize += 8 + strlen(getchrs(outcode));
|
||||
fprintf(ofp, "\001CHRS: %s\n", getchrs(outcode));
|
||||
if (html_message) {
|
||||
@ -548,8 +533,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
}
|
||||
if ((splitpart == 0) || (hdrsize < MAXHDRSIZE)) {
|
||||
for (tmp = msg; tmp; tmp = tmp->next) {
|
||||
if ((!strncmp(tmp->key,"X-Fsc-",6)) ||
|
||||
(!strncmp(tmp->key,"X-FTN-",6) &&
|
||||
if ((!strncmp(tmp->key,"X-Fsc-",6)) || (!strncmp(tmp->key,"X-FTN-",6) &&
|
||||
strcasecmp(tmp->key,"X-FTN-Tearline") &&
|
||||
strcasecmp(tmp->key,"X-FTN-Origin") &&
|
||||
strcasecmp(tmp->key,"X-FTN-Sender") &&
|
||||
@ -605,7 +589,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
kludgewrite(tmp->val,ofp);
|
||||
}
|
||||
|
||||
// Syslog('-', "4");
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
// Syslog('-', "5");
|
||||
|
||||
rfcheaders=0;
|
||||
for (tmp=msg;tmp;tmp=tmp->next) {
|
||||
if ((needputrfc(tmp) > 1)) {
|
||||
@ -650,11 +633,9 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
fprintf(ofp,PGP_SIGNED_BEGIN"\n");
|
||||
}
|
||||
if (replyaddr) {
|
||||
// free(replyaddr); /* Gives SIGSEGV */
|
||||
replyaddr = NULL;
|
||||
}
|
||||
|
||||
// Syslog('-', "6");
|
||||
if (needsplit) {
|
||||
fprintf(ofp," * Continuation %d of a split message *\n\n", splitpart);
|
||||
needsplit = FALSE;
|
||||
@ -838,7 +819,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
|
||||
if (newsmode)
|
||||
rc = postecho(NULL, fmsg->from, fmsg->to, origin, fmsg->subj, fmsg->date, fmsg->flags, 0, ofp, FALSE);
|
||||
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);
|
||||
fclose(ofp);
|
||||
|
@ -92,7 +92,7 @@ static int at_zero = 0;
|
||||
* Internal prototypes
|
||||
*/
|
||||
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.
|
||||
*
|
||||
*/
|
||||
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;
|
||||
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;
|
||||
} /* 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);
|
||||
else
|
||||
rc = postnetmail(fp, f, t, orig, subj, mdate, flags, TRUE);
|
||||
} else
|
||||
rc = postnetmail(fp, f, t, orig, subj, mdate, flags, TRUE, p_from->zone, tzone);
|
||||
|
||||
free(buf);
|
||||
return rc;
|
||||
@ -418,9 +420,6 @@ int getmessage(FILE *pkt, faddr *p_from, faddr *p_to)
|
||||
return 3;
|
||||
}
|
||||
|
||||
f.zone = p_from->zone;
|
||||
t.zone = p_to->zone;
|
||||
|
||||
if ((fp = tmpfile()) == NULL) {
|
||||
WriteError("$unable to open temporary file");
|
||||
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)
|
||||
rc+=10;
|
||||
if (rc > maxrc)
|
||||
|
Reference in New Issue
Block a user