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

@ -69,81 +69,81 @@ extern char *msgid; /* Original message id */
int Bounce(faddr *f, faddr *t, FILE *fp, char *reason) int Bounce(faddr *f, faddr *t, FILE *fp, char *reason)
{ {
int rc = 0, count = 0; int rc = 0, count = 0;
char *Buf; char *Buf;
FILE *np; FILE *np;
time_t Now; time_t Now;
faddr *from; faddr *from;
Now = time(NULL); Now = time(NULL);
if (SearchFidonet(f->zone)) if (SearchFidonet(f->zone))
f->domain = xstrcpy(fidonet.domain); f->domain = xstrcpy(fidonet.domain);
Syslog('+', "Bounce msg from %s", ascfnode(f, 0xff)); Syslog('+', "Bounce msg from %s", ascfnode(f, 0xff));
Buf = calloc(2049, sizeof(char)); Buf = calloc(2049, sizeof(char));
rewind(fp); rewind(fp);
np = tmpfile(); np = tmpfile();
from = bestaka_s(f); from = bestaka_s(f);
from->zone = t->zone; from->zone = t->zone;
from->net = t->net; from->net = t->net;
from->node = t->node; from->node = t->node;
from->point = t->point; from->point = t->point;
from->name = xstrcpy((char *)"Postmaster"); from->name = xstrcpy((char *)"Postmaster");
if (f->point) if (f->point)
fprintf(np, "\001TOPT %d\r", f->point); fprintf(np, "\001TOPT %d\r", f->point);
if (from->point) if (from->point)
fprintf(np, "\001FMPT %d\r", from->point); fprintf(np, "\001FMPT %d\r", from->point);
fprintf(np, "\001INTL %d:%d/%d %d:%d/%d\r", f->zone, f->net, f->node, from->zone, from->net, from->node); fprintf(np, "\001INTL %d:%d/%d %d:%d/%d\r", f->zone, f->net, f->node, from->zone, from->net, from->node);
/* /*
* Add MSGID, REPLY and PID * Add MSGID, REPLY and PID
*/ */
fprintf(np, "\001MSGID: %s %08lx\r", ascfnode(from, 0x1f), sequencer()); fprintf(np, "\001MSGID: %s %08lx\r", ascfnode(from, 0x1f), sequencer());
while ((fgets(Buf, 2048, fp)) != NULL) { while ((fgets(Buf, 2048, fp)) != NULL) {
Striplf(Buf); Striplf(Buf);
if (strncmp(Buf, "\001MSGID:", 7) == 0) { if (strncmp(Buf, "\001MSGID:", 7) == 0) {
fprintf(np, "\001REPLY:%s\r", Buf+7); fprintf(np, "\001REPLY:%s\r", Buf+7);
}
} }
fprintf(np, "\001PID: MBSE-FIDO %s\r", VERSION); }
fprintf(np, "\001TZUTC: %s\r", gmtoffset(Now)); fprintf(np, "\001PID: MBSE-FIDO %s\r", VERSION);
fprintf(np, "\001TZUTC: %s\r", gmtoffset(Now));
fprintf(np, " Dear %s\r\r", MBSE_SS(f->name)); fprintf(np, " Dear %s\r\r", MBSE_SS(f->name));
fprintf(np, "Your message could not be delevered, reason: %s\r\r", reason); fprintf(np, "Your message could not be delevered, reason: %s\r\r", reason);
fprintf(np, "Here are the first lines of the original message from you:\r\r"); fprintf(np, "Here are the first lines of the original message from you:\r\r");
fprintf(np, "======================================================================\r"); fprintf(np, "======================================================================\r");
rewind(fp); rewind(fp);
while ((fgets(Buf, 2048, fp)) != NULL) { while ((fgets(Buf, 2048, fp)) != NULL) {
Striplf(Buf); Striplf(Buf);
if (Buf[0] == '\001') { if (Buf[0] == '\001') {
fprintf(np, "^a"); fprintf(np, "^a");
fwrite(Buf + 1, strlen(Buf) -1, 1, np); fwrite(Buf + 1, strlen(Buf) -1, 1, np);
} else { } else {
fwrite(Buf, strlen(Buf), 1, np); fwrite(Buf, strlen(Buf), 1, np);
}
fputc('\r', np);
count++;
if (count == 50)
break;
}
fprintf(np, "======================================================================\r");
if (count == 50) {
fprintf(np, "\rOnly the first 50 lines are displayed\r");
} }
fputc('\r', np);
count++;
if (count == 50)
break;
}
fprintf(np, "======================================================================\r");
if (count == 50) {
fprintf(np, "\rOnly the first 50 lines are displayed\r");
}
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);
free(Buf); free(Buf);
return rc; return rc;
} }

View File

@ -69,80 +69,80 @@ extern char *msgid; /* Original message id */
int Ping(faddr *f, faddr *t, FILE *fp, int intransit) int Ping(faddr *f, faddr *t, FILE *fp, int intransit)
{ {
int rc = 0; int rc = 0;
char *Buf; char *Buf;
FILE *np; FILE *np;
time_t Now; time_t Now;
faddr *from; faddr *from;
Now = time(NULL); Now = time(NULL);
if (SearchFidonet(f->zone)) if (SearchFidonet(f->zone))
f->domain = xstrcpy(fidonet.domain); f->domain = xstrcpy(fidonet.domain);
Syslog('+', "%s ping msg from %s", intransit ? "Intransit":"Final", ascfnode(f, 0xff)); Syslog('+', "%s ping msg from %s", intransit ? "Intransit":"Final", ascfnode(f, 0xff));
Buf = calloc(2049, sizeof(char)); Buf = calloc(2049, sizeof(char));
rewind(fp); rewind(fp);
np = tmpfile(); np = tmpfile();
from = bestaka_s(f); from = bestaka_s(f);
if (intransit) { if (intransit) {
from->name = xstrcpy((char *)"Ping TRACE service"); from->name = xstrcpy((char *)"Ping TRACE service");
} else { } else {
from->zone = t->zone; from->zone = t->zone;
from->net = t->net; from->net = t->net;
from->node = t->node; from->node = t->node;
from->point = t->point; from->point = t->point;
from->name = xstrcpy((char *)"Ping service"); from->name = xstrcpy((char *)"Ping service");
}
if (f->point)
fprintf(np, "\001TOPT %d\r", f->point);
if (from->point)
fprintf(np, "\001FMPT %d\r", from->point);
fprintf(np, "\001INTL %d:%d/%d %d:%d/%d\r", f->zone, f->net, f->node, from->zone, from->net, from->node);
/*
* Add MSGID, REPLY and PID
*/
fprintf(np, "\001MSGID: %s %08lx\r", ascfnode(from, 0x1f), sequencer());
while ((fgets(Buf, 2048, fp)) != NULL) {
Striplf(Buf);
if (strncmp(Buf, "\001MSGID:", 7) == 0) {
fprintf(np, "\001REPLY:%s\r", Buf+7);
} }
}
fprintf(np, "\001PID: MBSE-FIDO %s\r", VERSION);
fprintf(np, "\001TZUTC: %s\r", gmtoffset(Now));
if (f->point) fprintf(np, " Dear %s\r\r", MBSE_SS(f->name));
fprintf(np, "\001TOPT %d\r", f->point); if (intransit) {
if (from->point) fprintf(np, "You did send a PING to %s\r", ascfnode(t, 0x1f));
fprintf(np, "\001FMPT %d\r", from->point); fprintf(np, "This is a TRACE response from \"%s\" aka %s\r", CFG.bbs_name, ascfnode(from, 0x1f));
fprintf(np, "\001INTL %d:%d/%d %d:%d/%d\r", f->zone, f->net, f->node, from->zone, from->net, from->node); fprintf(np, "The time of arrival is %s\r", rfcdate(Now));
} else
fprintf(np, "Your Ping arrived here at %s\r", rfcdate(Now));
fprintf(np, "Here are all the detected Via lines of the message from you:\r\r");
fprintf(np, "======================================================================\r");
/* rewind(fp);
* Add MSGID, REPLY and PID while ((fgets(Buf, 2048, fp)) != NULL) {
*/ Striplf(Buf);
fprintf(np, "\001MSGID: %s %08lx\r", ascfnode(from, 0x1f), sequencer()); if (strncmp(Buf, "\1Via", 4) == 0) {
while ((fgets(Buf, 2048, fp)) != NULL) { fprintf(np, "%s\r", Buf+1);
Striplf(Buf);
if (strncmp(Buf, "\001MSGID:", 7) == 0) {
fprintf(np, "\001REPLY:%s\r", Buf+7);
}
} }
fprintf(np, "\001PID: MBSE-FIDO %s\r", VERSION); }
fprintf(np, "\001TZUTC: %s\r", gmtoffset(Now)); fprintf(np, "======================================================================\r");
fprintf(np, " Dear %s\r\r", MBSE_SS(f->name)); fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name);
if (intransit) { fprintf(np, "%s\r", TearLine());
fprintf(np, "You did send a PING to %s\r", ascfnode(t, 0x1f)); Now = time(NULL) - (gmt_offset((time_t)0) * 60);
fprintf(np, "This is a TRACE response from \"%s\" aka %s\r", CFG.bbs_name, ascfnode(from, 0x1f)); rc = postnetmail(np, from, f, NULL, (char *)"Re: Ping", Now, 0x0000, FALSE, from->zone, f->zone);
fprintf(np, "The time of arrival is %s\r", rfcdate(Now)); tidy_faddr(from);
} else
fprintf(np, "Your Ping arrived here at %s\r", rfcdate(Now));
fprintf(np, "Here are all the detected Via lines of the message from you:\r\r");
fprintf(np, "======================================================================\r");
rewind(fp); fclose(np);
while ((fgets(Buf, 2048, fp)) != NULL) {
Striplf(Buf);
if (strncmp(Buf, "\1Via", 4) == 0) {
fprintf(np, "%s\r", Buf+1);
}
}
fprintf(np, "======================================================================\r");
fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); free(Buf);
fprintf(np, "%s\r", TearLine()); return rc;
Now = time(NULL) - (gmt_offset((time_t)0) * 60);
rc = postnetmail(np, from, f, NULL, (char *)"Re: Ping", Now, 0x0000, FALSE);
tidy_faddr(from);
fclose(np);
free(Buf);
return rc;
} }

View File

@ -70,375 +70,386 @@ 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; FILE *sfp, *net;
FILE *sfp, *net; time_t now;
time_t now; struct tm *tm;
struct tm *tm;
Syslog('M', "Post netmail from: %s", ascfnode(f, 0xff)); Syslog('M', "Post netmail from: %s", ascfnode(f, 0xff));
Syslog('M', "Post netmail to : %s", ascfnode(t, 0xff)); Syslog('M', "Post netmail to : %s", ascfnode(t, 0xff));
Syslog('M', "Post netmail subj: %s", MBSE_SS(subject)); Syslog('M', "Post netmail subj: %s", MBSE_SS(subject));
net_in++; net_in++;
/* /*
* 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);
Syslogp('M', printable(buf, 0)); Syslogp('M', printable(buf, 0));
if (!strncmp(buf, "\001MSGID: ", 8)) { if (!strncmp(buf, "\001MSGID: ", 8)) {
msgid = xstrcpy(buf + 8); msgid = xstrcpy(buf + 8);
/* /*
* Extra test to see if the mail comes from a pointaddress. * Extra test to see if the mail comes from a pointaddress.
*/ */
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;
}
tidy_faddr(ta);
}
}
if (!strncmp(buf, "\001FMPT", 5)) {
p = strtok(buf, " \n");
p = strtok(NULL, " \n");
fmpt = atoi(p);
}
if (!strncmp(buf, "\001TOPT", 5)) {
p = strtok(buf, " \n");
p = strtok(NULL, " \n");
topt = atoi(p);
}
if (!strncmp(buf, "\001REPLY: ", 8))
reply = xstrcpy(buf + 8);
/*
* Check DOMAIN and INTL kludges
*/
if (!strncmp(buf, "\001DOMAIN", 7)) {
l = strtok(buf," \n");
l = strtok(NULL," \n");
p = strtok(NULL," \n");
r = strtok(NULL," \n");
q = strtok(NULL," \n");
if ((ta = parsefnode(p))) {
t->point = ta->point;
t->node = ta->node;
t->net = ta->net;
t->zone = ta->zone;
tidy_faddr(ta);
}
t->domain = xstrcpy(l);
if ((ta = parsefnode(q))) {
f->point = ta->point;
f->node = ta->node;
f->net = ta->net;
f->zone = ta->zone;
tidy_faddr(ta);
}
f->domain = xstrcpy(r);
} else {
if (!strncmp(buf, "\001INTL", 5)) {
l = strtok(buf," \n");
l = strtok(NULL," \n");
r = strtok(NULL," \n");
if ((ta = parsefnode(l))) {
t->point = ta->point;
t->node = ta->node;
t->net = ta->net;
t->zone = ta->zone;
if (ta->domain) {
if (t->domain)
free(t->domain);
t->domain = ta->domain;
ta->domain = NULL;
}
tidy_faddr(ta);
}
if ((ta = parsefnode(r))) {
f->point = ta->point;
f->node = ta->node;
f->net = ta->net;
f->zone = ta->zone;
if (ta->domain) {
if (f->domain)
free(f->domain);
f->domain = ta->domain;
ta->domain = NULL;
}
tidy_faddr(ta);
}
}
}
/*
* Check FLAGS kludge
*/
if (!strncmp(buf, "\001FLAGS ", 7)) {
flagstr = xstrcpy(buf + 7);
Syslog('m', "^aFLAGS %s", flagstr);
}
if (!strncmp(buf, "\001FLAGS: ", 8)) {
flagstr = xstrcpy(buf + 8);
Syslog('m', "^aFLAGS: %s", flagstr);
}
/*
* Check for X-FTN- kludges, this could be gated email.
* This should be impossible.
*/
if (!strncmp(buf, "\001X-FTN-", 7)) {
email = TRUE;
Syslog('?', "Warning: detected ^aX-FTN- kludge in netmail");
} }
tidy_faddr(ta);
}
} }
free(buf); if (!strncmp(buf, "\001FMPT", 5)) {
p = strtok(buf, " \n");
p = strtok(NULL, " \n");
fmpt = atoi(p);
}
if (!strncmp(buf, "\001TOPT", 5)) {
p = strtok(buf, " \n");
p = strtok(NULL, " \n");
topt = atoi(p);
}
if (!strncmp(buf, "\001REPLY: ", 8))
reply = xstrcpy(buf + 8);
/* /*
* Only set point info if there was any info. * Check DOMAIN and INTL kludges
* GoldED doesn't set FMPT and TOPT kludges.
*/ */
if (fmpt) if (!strncmp(buf, "\001DOMAIN", 7)) {
f->point = fmpt; l = strtok(buf," \n");
if (topt) l = strtok(NULL," \n");
t->point = topt; p = strtok(NULL," \n");
r = strtok(NULL," \n");
q = strtok(NULL," \n");
if ((ta = parsefnode(p))) {
t->point = ta->point;
t->node = ta->node;
t->net = ta->net;
t->zone = ta->zone;
tidy_faddr(ta);
}
t->domain = xstrcpy(l);
if ((ta = parsefnode(q))) {
f->point = ta->point;
f->node = ta->node;
f->net = ta->net;
f->zone = ta->zone;
tidy_faddr(ta);
}
f->domain = xstrcpy(r);
} else {
if (!strncmp(buf, "\001INTL", 5)) {
l = strtok(buf," \n");
l = strtok(NULL," \n");
r = strtok(NULL," \n");
if ((ta = parsefnode(l))) {
t->point = ta->point;
t->node = ta->node;
t->net = ta->net;
t->zone = ta->zone;
if (ta->domain) {
if (t->domain)
free(t->domain);
t->domain = ta->domain;
ta->domain = NULL;
}
tidy_faddr(ta);
}
if ((ta = parsefnode(r))) {
f->point = ta->point;
f->node = ta->node;
f->net = ta->net;
f->zone = ta->zone;
if (ta->domain) {
if (f->domain)
free(f->domain);
f->domain = ta->domain;
ta->domain = NULL;
}
tidy_faddr(ta);
}
}
}
Syslog('m', "Final netmail from: %s", ascfnode(f, 0xff)); /*
Syslog('m', "Final netmail to : %s", ascfnode(t, 0xff)); * Check FLAGS kludge
*/
if (!strncmp(buf, "\001FLAGS ", 7)) {
flagstr = xstrcpy(buf + 7);
Syslog('m', "^aFLAGS %s", flagstr);
}
if (!strncmp(buf, "\001FLAGS: ", 8)) {
flagstr = xstrcpy(buf + 8);
Syslog('m', "^aFLAGS: %s", flagstr);
}
memset(&na, 0, sizeof(na)); /*
na.zone = t->zone; * Check for X-FTN- kludges, this could be gated email.
na.net = t->net; * This should be impossible.
na.node = t->node; */
na.point = t->point; if (!strncmp(buf, "\001X-FTN-", 7)) {
if (SearchFidonet(na.zone)) email = TRUE;
sprintf(na.domain, "%s", fidonet.domain); Syslog('?', "Warning: detected ^aX-FTN- kludge in netmail");
}
}
free(buf);
switch(TrackMail(na, &routeto)) { /*
* Only set point info if there was any info.
* GoldED doesn't set FMPT and TOPT kludges.
*/
if (fmpt)
f->point = fmpt;
if (topt)
t->point = topt;
/*
* 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;
na.net = t->net;
na.node = t->node;
na.point = t->point;
if (SearchFidonet(na.zone))
sprintf(na.domain, "%s", fidonet.domain);
switch(TrackMail(na, &routeto)) {
case R_LOCAL: case R_LOCAL:
/* /*
* Check the To: field. * Check the To: field.
*/ */
if (strchr(t->name, '@') != NULL) { if (strchr(t->name, '@') != NULL) {
sprintf(name, "%s", strtok(t->name, "@")); sprintf(name, "%s", strtok(t->name, "@"));
sprintf(System, "%s", strtok(NULL, "\000")); sprintf(System, "%s", strtok(NULL, "\000"));
email = TRUE; email = TRUE;
} else { } else {
sprintf(name, "%s", t->name); sprintf(name, "%s", t->name);
sprintf(System, "%s", CFG.sysdomain); sprintf(System, "%s", CFG.sysdomain);
} }
if (email) {
/*
* Send this netmail via ftn2rfc -> postemail.
*/
result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
return result;
}
if (email) {
/* /*
* If message to "sysop" or "postmaster" replace it * Send this netmail via ftn2rfc -> postemail.
* with the sysops real name.
*/ */
if ((strncasecmp(name, "sysop", 5) == 0) || (strcasecmp(name, "postmaster") == 0)) { return result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name); }
sprintf(name, "%s", CFG.sysop_name);
}
/* /*
* If the message is a service message, check the * If message to "sysop" or "postmaster" replace it
* services database to see what action is needed. * with the sysops real name.
* First make sure that the right noderecord is loaded. */
*/ if ((strncasecmp(name, "sysop", 5) == 0) || (strcasecmp(name, "postmaster") == 0)) {
(void)noderecord(f);
p = calloc(PATH_MAX, sizeof(char));
sprintf(p, "%s/etc/service.data", getenv("MBSE_ROOT"));
if ((sfp = fopen(p, "r")) == NULL) {
WriteError("$Can't open %s", p);
} else {
fread(&servhdr, sizeof(servhdr), 1, sfp);
while (fread(&servrec, servhdr.recsize, 1, sfp) == 1) {
if ((strncasecmp(servrec.Service, name, strlen(servrec.Service)) == 0) && servrec.Active) {
switch (servrec.Action) {
case AREAMGR: result = AreaMgr(f, t, msgid, subject, mdate, flags, fp);
break;
case FILEMGR: result = FileMgr(f, t, msgid, subject, mdate, flags, fp);
break;
case EMAIL: result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
if (result) {
if (result == 2)
Bounce(f, t, fp, (char *)"Could not post email");
else
Bounce(f, t, fp, (char *)"Could not convert to email");
}
break;
}
Syslog('m', "Handled service %s, rc=%d", servrec.Service, result);
fclose(sfp);
return result;
}
}
fclose(sfp);
}
free(p);
/*
* Ping function
*/
if (!strcasecmp(name, (char *)"ping") && DoPing) {
return Ping(f, t, fp, FALSE);
}
/*
* Check userlist real names, handles, unix names.
* Import if one fits.
*/
if (SearchUser(name)) {
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
}
Syslog('+', " \"%s\" is not a known BBS user", name);
/*
* Unknown, readdress it to the sysop.
*/
net_bad++;
Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name); Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name);
sprintf(name, "%s", CFG.sysop_name); sprintf(name, "%s", CFG.sysop_name);
if (SearchUser(name)) { }
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
} else { /*
WriteError("Readdress import failed, sysop doesn't exist. CHECK YOUR SETUP"); * If the message is a service message, check the
return 0; * services database to see what action is needed.
* First make sure that the right noderecord is loaded.
*/
(void)noderecord(f);
p = calloc(PATH_MAX, sizeof(char));
sprintf(p, "%s/etc/service.data", getenv("MBSE_ROOT"));
if ((sfp = fopen(p, "r")) == NULL) {
WriteError("$Can't open %s", p);
} else {
fread(&servhdr, sizeof(servhdr), 1, sfp);
while (fread(&servrec, servhdr.recsize, 1, sfp) == 1) {
if ((strncasecmp(servrec.Service, name, strlen(servrec.Service)) == 0) && servrec.Active) {
switch (servrec.Action) {
case AREAMGR: result = AreaMgr(f, t, msgid, subject, mdate, flags, fp);
break;
case FILEMGR: result = FileMgr(f, t, msgid, subject, mdate, flags, fp);
break;
case EMAIL: result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
if (result) {
if (result == 2)
Bounce(f, t, fp, (char *)"Could not post email");
else
Bounce(f, t, fp, (char *)"Could not convert to email");
}
break;
}
Syslog('m', "Handled service %s, rc=%d", servrec.Service, result);
fclose(sfp);
return result;
}
} }
break; fclose(sfp);
}
free(p);
/*
* Ping function
*/
if (!strcasecmp(name, (char *)"ping") && DoPing) {
return Ping(f, t, fp, FALSE);
}
/*
* Check userlist real names, handles, unix names.
* Import if one fits.
*/
if (SearchUser(name)) {
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
}
Syslog('+', " \"%s\" is not a known BBS user", name);
/*
* Unknown, readdress it to the sysop.
*/
net_bad++;
Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name);
sprintf(name, "%s", CFG.sysop_name);
if (SearchUser(name)) {
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
} else {
WriteError("Readdress import failed, sysop doesn't exist. CHECK YOUR SETUP");
return 0;
}
break;
case R_DIRECT: case R_DIRECT:
case R_ROUTE: case R_ROUTE:
Syslog('+', "Route netmail via %s", aka2str(routeto)); Syslog('+', "Route netmail via %s", aka2str(routeto));
if (!strcasecmp(t->name, (char *)"ping") && DoPing) { if (!strcasecmp(t->name, (char *)"ping") && DoPing) {
Syslog('+', "In transit \"Ping\" message detected"); Syslog('+', "In transit \"Ping\" message detected");
Ping(f, t, fp, TRUE); Ping(f, t, fp, TRUE);
(void)noderecord(f); (void)noderecord(f);
} }
/* /*
* Forward this message. Will not work for unknown * Forward this message. Will not work for unknown
* direct links. * direct links.
*/ */
if (SearchNode(routeto)) { if (SearchNode(routeto)) {
memset(&Orig, 0, sizeof(Orig)); memset(&Orig, 0, sizeof(Orig));
ra = fido2faddr(routeto); ra = fido2faddr(routeto);
ta = bestaka_s(ra); ta = bestaka_s(ra);
Orig.zone = ta->zone; Orig.zone = ta->zone;
Orig.net = ta->net; Orig.net = ta->net;
Orig.node = ta->node; Orig.node = ta->node;
Orig.point = ta->point; Orig.point = ta->point;
tidy_faddr(ra); tidy_faddr(ra);
tidy_faddr(ta);
memset(&ext, 0, sizeof(ext));
if (nodes.PackNetmail)
sprintf(ext, (char *)"qqq");
else if (nodes.Crash)
sprintf(ext, (char *)"ccc");
else if (nodes.Hold)
sprintf(ext, (char *)"hhh");
else
sprintf(ext, (char *)"nnn");
if ((net = OpenPkt(Orig , routeto, (char *)ext)) == NULL) {
net_bad++;
WriteError("Can't create netmail");
return 0;
}
} else {
/*
* If it's not a direct link, create a outbound
* .pkt anyway, better then that this mail is
* lost. It gets the normal status, it might
* get delivered during ZMH this way.
*/
Syslog('!', "Warning: not a direct link, check setup");
memset(&Orig, 0, sizeof(Orig));
ra = fido2faddr(routeto);
ta = bestaka_s(ra);
Orig.zone = ta->zone;
Orig.net = ta->net;
Orig.node = ta->node;
Orig.point = ta->point;
tidy_faddr(ra);
tidy_faddr(ta);
if ((net = OpenPkt(Orig , routeto, (char *)"nnn")) == NULL) {
net_bad++;
WriteError("Can't create netmail");
return 0;
}
}
/*
* Now start forward.
*/
Syslog('m', "Net from %s", ascfnode(f, 0xff));
Syslog('m', "Net to %s", ascfnode(t, 0xff));
Syslog('m', "Net flags %08x", flags);
Syslog('m', "Net subj %s", subject);
if (AddMsgHdr(net, f, t, flags, 0, mdate, t->name, f->name, subject)) {
WriteError("Can't write message header");
net_bad++;
return 0;
}
rewind(fp);
/*
* Copy all text including kludges, when
* finished, insert our ^aVia line.
*/
buf = calloc(2048, sizeof(char));
while ((fgets(buf, 2048, fp)) != NULL)
fprintf(net, "%s\r", buf);
now = time(NULL);
tm = gmtime(&now);
ta = bestaka_s(t);
fprintf(net, "\001Via %s @%d%02d%02d.%02d%02d%02d.00.UTC mbfido %s\r",
ascfnode(ta, 0x1f), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec, VERSION);
tidy_faddr(ta); tidy_faddr(ta);
putc(0, net); memset(&ext, 0, sizeof(ext));
fclose(net); if (nodes.PackNetmail)
free(buf); sprintf(ext, (char *)"qqq");
net_out++; else if (nodes.Crash)
Syslog('m', "Forward done."); sprintf(ext, (char *)"ccc");
else if (nodes.Hold)
sprintf(ext, (char *)"hhh");
else
sprintf(ext, (char *)"nnn");
if ((net = OpenPkt(Orig , routeto, (char *)ext)) == NULL) {
net_bad++;
WriteError("Can't create netmail");
return 0;
}
} else {
/*
* If it's not a direct link, create a outbound
* .pkt anyway, better then that this mail is
* lost. It gets the normal status, it might
* get delivered during ZMH this way.
*/
Syslog('!', "Warning: not a direct link, check setup");
memset(&Orig, 0, sizeof(Orig));
ra = fido2faddr(routeto);
ta = bestaka_s(ra);
Orig.zone = ta->zone;
Orig.net = ta->net;
Orig.node = ta->node;
Orig.point = ta->point;
tidy_faddr(ra);
tidy_faddr(ta);
if ((net = OpenPkt(Orig , routeto, (char *)"nnn")) == NULL) {
net_bad++;
WriteError("Can't create netmail");
return 0;
}
}
/*
* Now start forward.
*/
Syslog('m', "Net from %s", ascfnode(f, 0xff));
Syslog('m', "Net to %s", ascfnode(t, 0xff));
Syslog('m', "Net flags %08x", flags);
Syslog('m', "Net subj %s", subject);
if (AddMsgHdr(net, f, t, flags, 0, mdate, t->name, f->name, subject)) {
WriteError("Can't write message header");
net_bad++;
return 0; return 0;
}
rewind(fp);
/*
* Copy all text including kludges, when
* finished, insert our ^aVia line.
*/
buf = calloc(2048, sizeof(char));
while ((fgets(buf, 2048, fp)) != NULL)
fprintf(net, "%s\r", buf);
now = time(NULL);
tm = gmtime(&now);
ta = bestaka_s(t);
fprintf(net, "\001Via %s @%d%02d%02d.%02d%02d%02d.00.UTC mbfido %s\r",
ascfnode(ta, 0x1f), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec, VERSION);
tidy_faddr(ta);
putc(0, net);
fclose(net);
free(buf);
net_out++;
Syslog('m', "Forward done.");
return 0;
default: default:
/* /*
* If we came this far, there's definitly something wrong * If we came this far, there's definitly something wrong
* with this netmail. * with this netmail.
*/ */
WriteError("No ROUTE for this netmail"); WriteError("No ROUTE for this netmail");
net_bad++; net_bad++;
flags |= M_ORPHAN; flags |= M_ORPHAN;
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr); return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
break; break;
} }
/* Never reached */ /* Never reached */
return result; 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

File diff suppressed because it is too large Load Diff

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)