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 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.

View File

@ -69,81 +69,81 @@ extern char *msgid; /* Original message id */
int Bounce(faddr *f, faddr *t, FILE *fp, char *reason)
{
int rc = 0, count = 0;
char *Buf;
FILE *np;
time_t Now;
faddr *from;
int rc = 0, count = 0;
char *Buf;
FILE *np;
time_t Now;
faddr *from;
Now = time(NULL);
if (SearchFidonet(f->zone))
f->domain = xstrcpy(fidonet.domain);
Now = time(NULL);
if (SearchFidonet(f->zone))
f->domain = xstrcpy(fidonet.domain);
Syslog('+', "Bounce msg from %s", ascfnode(f, 0xff));
Buf = calloc(2049, sizeof(char));
rewind(fp);
Syslog('+', "Bounce msg from %s", ascfnode(f, 0xff));
Buf = calloc(2049, sizeof(char));
rewind(fp);
np = tmpfile();
from = bestaka_s(f);
from->zone = t->zone;
from->net = t->net;
from->node = t->node;
from->point = t->point;
from->name = xstrcpy((char *)"Postmaster");
np = tmpfile();
from = bestaka_s(f);
from->zone = t->zone;
from->net = t->net;
from->node = t->node;
from->point = t->point;
from->name = xstrcpy((char *)"Postmaster");
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);
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);
}
/*
* 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));
}
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, "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, "======================================================================\r");
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, "Here are the first lines of the original message from you:\r\r");
fprintf(np, "======================================================================\r");
rewind(fp);
while ((fgets(Buf, 2048, fp)) != NULL) {
Striplf(Buf);
if (Buf[0] == '\001') {
fprintf(np, "^a");
fwrite(Buf + 1, strlen(Buf) -1, 1, np);
} else {
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");
rewind(fp);
while ((fgets(Buf, 2048, fp)) != NULL) {
Striplf(Buf);
if (Buf[0] == '\001') {
fprintf(np, "^a");
fwrite(Buf + 1, strlen(Buf) -1, 1, np);
} else {
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");
}
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);
tidy_faddr(from);
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, from->zone, f->zone);
tidy_faddr(from);
fclose(np);
fclose(np);
free(Buf);
return rc;
free(Buf);
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 rc = 0;
char *Buf;
FILE *np;
time_t Now;
faddr *from;
int rc = 0;
char *Buf;
FILE *np;
time_t Now;
faddr *from;
Now = time(NULL);
if (SearchFidonet(f->zone))
f->domain = xstrcpy(fidonet.domain);
Now = time(NULL);
if (SearchFidonet(f->zone))
f->domain = xstrcpy(fidonet.domain);
Syslog('+', "%s ping msg from %s", intransit ? "Intransit":"Final", ascfnode(f, 0xff));
Buf = calloc(2049, sizeof(char));
rewind(fp);
Syslog('+', "%s ping msg from %s", intransit ? "Intransit":"Final", ascfnode(f, 0xff));
Buf = calloc(2049, sizeof(char));
rewind(fp);
np = tmpfile();
from = bestaka_s(f);
if (intransit) {
from->name = xstrcpy((char *)"Ping TRACE service");
} else {
from->zone = t->zone;
from->net = t->net;
from->node = t->node;
from->point = t->point;
from->name = xstrcpy((char *)"Ping service");
np = tmpfile();
from = bestaka_s(f);
if (intransit) {
from->name = xstrcpy((char *)"Ping TRACE service");
} else {
from->zone = t->zone;
from->net = t->net;
from->node = t->node;
from->point = t->point;
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, "\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);
fprintf(np, " Dear %s\r\r", MBSE_SS(f->name));
if (intransit) {
fprintf(np, "You did send a PING to %s\r", ascfnode(t, 0x1f));
fprintf(np, "This is a TRACE response from \"%s\" aka %s\r", CFG.bbs_name, ascfnode(from, 0x1f));
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");
/*
* 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);
}
rewind(fp);
while ((fgets(Buf, 2048, fp)) != NULL) {
Striplf(Buf);
if (strncmp(Buf, "\1Via", 4) == 0) {
fprintf(np, "%s\r", Buf+1);
}
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));
if (intransit) {
fprintf(np, "You did send a PING to %s\r", ascfnode(t, 0x1f));
fprintf(np, "This is a TRACE response from \"%s\" aka %s\r", CFG.bbs_name, ascfnode(from, 0x1f));
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");
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, from->zone, f->zone);
tidy_faddr(from);
rewind(fp);
while ((fgets(Buf, 2048, fp)) != NULL) {
Striplf(Buf);
if (strncmp(Buf, "\1Via", 4) == 0) {
fprintf(np, "%s\r", Buf+1);
}
}
fprintf(np, "======================================================================\r");
fclose(np);
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);
tidy_faddr(from);
fclose(np);
free(Buf);
return rc;
free(Buf);
return rc;
}

View File

@ -70,375 +70,386 @@ 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];
int result = 1, email = FALSE, fmpt = 0, topt = 0;
faddr *ta, *ra;
fidoaddr na, routeto, Orig;
FILE *sfp, *net;
time_t now;
struct tm *tm;
char *p, *msgid = NULL, *reply = NULL, *flagstr = NULL;
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;
FILE *sfp, *net;
time_t now;
struct tm *tm;
Syslog('M', "Post netmail from: %s", ascfnode(f, 0xff));
Syslog('M', "Post netmail to : %s", ascfnode(t, 0xff));
Syslog('M', "Post netmail subj: %s", MBSE_SS(subject));
net_in++;
Syslog('M', "Post netmail from: %s", ascfnode(f, 0xff));
Syslog('M', "Post netmail to : %s", ascfnode(t, 0xff));
Syslog('M', "Post netmail subj: %s", MBSE_SS(subject));
net_in++;
/*
* Extract MSGID and REPLY kludges from this netmail.
*/
buf = calloc(2048, sizeof(char));
rewind(fp);
while ((fgets(buf, 2048, fp)) != NULL) {
Striplf(buf);
Syslogp('M', printable(buf, 0));
if (!strncmp(buf, "\001MSGID: ", 8)) {
msgid = xstrcpy(buf + 8);
/*
* Extra test to see if the mail comes from a pointaddress.
*/
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) {
Syslog('m', "Setting pointinfo (%d) from MSGID", 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");
/*
* Extract MSGID and REPLY kludges from this netmail.
*/
buf = calloc(2049, sizeof(char));
rewind(fp);
while ((fgets(buf, 2048, fp)) != NULL) {
Striplf(buf);
Syslogp('M', printable(buf, 0));
if (!strncmp(buf, "\001MSGID: ", 8)) {
msgid = xstrcpy(buf + 8);
/*
* Extra test to see if the mail comes from a pointaddress.
*/
l = strtok(buf," \n");
l = strtok(NULL," \n");
if ((ta = parsefnode(l))) {
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;
}
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.
* GoldED doesn't set FMPT and TOPT kludges.
* Check DOMAIN and INTL kludges
*/
if (fmpt)
f->point = fmpt;
if (topt)
t->point = topt;
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);
}
}
}
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;
na.net = t->net;
na.node = t->node;
na.point = t->point;
if (SearchFidonet(na.zone))
sprintf(na.domain, "%s", fidonet.domain);
/*
* 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");
}
}
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:
/*
* Check the To: field.
*/
if (strchr(t->name, '@') != NULL) {
sprintf(name, "%s", strtok(t->name, "@"));
sprintf(System, "%s", strtok(NULL, "\000"));
email = TRUE;
} else {
sprintf(name, "%s", t->name);
sprintf(System, "%s", CFG.sysdomain);
}
if (email) {
/*
* Send this netmail via ftn2rfc -> postemail.
*/
result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
return result;
}
/*
* Check the To: field.
*/
if (strchr(t->name, '@') != NULL) {
sprintf(name, "%s", strtok(t->name, "@"));
sprintf(System, "%s", strtok(NULL, "\000"));
email = TRUE;
} else {
sprintf(name, "%s", t->name);
sprintf(System, "%s", CFG.sysdomain);
}
if (email) {
/*
* If message to "sysop" or "postmaster" replace it
* with the sysops real name.
* Send this netmail via ftn2rfc -> postemail.
*/
if ((strncasecmp(name, "sysop", 5) == 0) || (strcasecmp(name, "postmaster") == 0)) {
Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name);
sprintf(name, "%s", CFG.sysop_name);
}
return result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
}
/*
* If the message is a service message, check the
* 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;
}
}
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++;
/*
* If message to "sysop" or "postmaster" replace it
* with the sysops real name.
*/
if ((strncasecmp(name, "sysop", 5) == 0) || (strcasecmp(name, "postmaster") == 0)) {
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;
}
/*
* If the message is a service message, check the
* 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_ROUTE:
Syslog('+', "Route netmail via %s", aka2str(routeto));
if (!strcasecmp(t->name, (char *)"ping") && DoPing) {
Syslog('+', "In transit \"Ping\" message detected");
Ping(f, t, fp, TRUE);
(void)noderecord(f);
}
Syslog('+', "Route netmail via %s", aka2str(routeto));
if (!strcasecmp(t->name, (char *)"ping") && DoPing) {
Syslog('+', "In transit \"Ping\" message detected");
Ping(f, t, fp, TRUE);
(void)noderecord(f);
}
/*
* Forward this message. Will not work for unknown
* direct links.
*/
if (SearchNode(routeto)) {
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);
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);
/*
* Forward this message. Will not work for unknown
* direct links.
*/
if (SearchNode(routeto)) {
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);
putc(0, net);
fclose(net);
free(buf);
net_out++;
Syslog('m', "Forward done.");
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);
putc(0, net);
fclose(net);
free(buf);
net_out++;
Syslog('m', "Forward done.");
return 0;
default:
/*
* If we came this far, there's definitly something wrong
* with this netmail.
*/
WriteError("No ROUTE for this netmail");
net_bad++;
flags |= M_ORPHAN;
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
break;
}
/*
* If we came this far, there's definitly something wrong
* with this netmail.
*/
WriteError("No ROUTE for this netmail");
net_bad++;
flags |= M_ORPHAN;
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
break;
}
/* Never reached */
return result;
/* Never reached */
return result;
}

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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)