Fixed wrong To: address in gated newsmessages

This commit is contained in:
Michiel Broek 2002-03-27 20:12:30 +00:00
parent e6f0072fec
commit dfa2baebd3
3 changed files with 127 additions and 130 deletions

View File

@ -4675,6 +4675,8 @@ v0.33.20 10-Feb-2002
When a ticfile was received while our aka is in the path, the When a ticfile was received while our aka is in the path, the
bad tic counter wasn't increased. bad tic counter wasn't increased.
Made error message in AddMsgHdr function more clear. Made error message in AddMsgHdr function more clear.
Removed experimental patch in news->ftn gate were wrong To:
address was created.
mball: mball:
Will not crash anymore when it needs more then 10 minutes to Will not crash anymore when it needs more then 10 minutes to

View File

@ -105,132 +105,134 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f)
buf = calloc(4097, sizeof(char)); buf = calloc(4097, sizeof(char));
while (fgets(buf, 4096, ap)) { while (fgets(buf, 4096, ap)) {
tag = strtok(buf, "\t \r\n\0"); if (strlen(buf) && isalnum(buf[0])) {
p = strtok(NULL, "\r\n\0"); tag = strtok(buf, "\t \r\n\0");
desc = p; p = strtok(NULL, "\r\n\0");
while ((*desc == ' ') || (*desc == '\t')) desc = p;
desc++; while ((*desc == ' ') || (*desc == '\t'))
if (strcmp(tag, Area) == 0) { desc++;
Syslog('m', "Found tag \"%s\" desc \"%s\"", tag, desc); if (strcmp(tag, Area) == 0) {
Syslog('m', "Found tag \"%s\" desc \"%s\"", tag, desc);
/* /*
* Area is in AREAS file, now create area. * Area is in AREAS file, now create area.
* If needed, connect at uplink. * If needed, connect at uplink.
*/ */
if (SendUplink) { if (SendUplink) {
sprintf(temp, "+%s", Area); sprintf(temp, "+%s", Area);
if (UplinkRequest(fido2faddr(mgroup.UpLink), FALSE, temp)) { if (UplinkRequest(fido2faddr(mgroup.UpLink), FALSE, temp)) {
WriteError("Can't send netmail to uplink"); WriteError("Can't send netmail to uplink");
fclose(ap);
free(buf);
free(temp);
return 1;
}
}
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mp = fopen(temp, "r+")) == NULL) {
WriteError("$Can't open %s", temp);
fclose(ap); fclose(ap);
free(buf); free(buf);
free(temp); free(temp);
return 1; return 1;
} }
} fread(&msgshdr, sizeof(msgshdr), 1, mp);
offset = msgshdr.hdrsize + ((mgroup.StartArea -1) * (msgshdr.recsize + msgshdr.syssize));
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if (fseek(mp, offset, SEEK_SET)) {
if ((mp = fopen(temp, "r+")) == NULL) { WriteError("$Can't seek in %s", temp);
WriteError("$Can't open %s", temp); fclose(ap);
fclose(ap); fclose(mp);
free(buf); free(buf);
free(temp); free(temp);
return 1; return 1;
}
fread(&msgshdr, sizeof(msgshdr), 1, mp);
offset = msgshdr.hdrsize + ((mgroup.StartArea -1) * (msgshdr.recsize + msgshdr.syssize));
if (fseek(mp, offset, SEEK_SET)) {
WriteError("$Can't seek in %s", temp);
fclose(ap);
fclose(mp);
free(buf);
free(temp);
return 1;
}
/*
* Search a free record
*/
while (fread(&msgs, sizeof(msgs), 1, mp) == 1) {
if (!msgs.Active) {
fseek(mp, - msgshdr.recsize, SEEK_CUR);
offset = ((ftell(mp) - msgshdr.hdrsize) / (msgshdr.recsize + msgshdr.syssize)) + 1;
Syslog('m', "Found free slot at %ld", offset);
rc = 1;
break;
} }
/* /*
* Skip systems * Search a free record
*/ */
fseek(mp, msgshdr.syssize, SEEK_CUR); while (fread(&msgs, sizeof(msgs), 1, mp) == 1) {
} if (!msgs.Active) {
fseek(mp, - msgshdr.recsize, SEEK_CUR);
if (!rc) { offset = ((ftell(mp) - msgshdr.hdrsize) / (msgshdr.recsize + msgshdr.syssize)) + 1;
Syslog('m', "No free slot, append after last record"); Syslog('m', "Found free slot at %ld", offset);
fseek(mp, 0, SEEK_END); rc = 1;
if (ftell(mp) < msgshdr.hdrsize + ((mgroup.StartArea -1) * (msgshdr.recsize + msgshdr.syssize))) { break;
Syslog('m', "Database too small, expanding...");
memset(&msgs, 0, sizeof(msgs));
memset(&System, 0, sizeof(System));
while (TRUE) {
fwrite(&msgs, sizeof(msgs), 1, mp);
for (i = 0; i < (msgshdr.syssize / sizeof(System)); i++)
fwrite(&System, sizeof(System), 1, mp);
if (ftell(mp) >= msgshdr.hdrsize + ((mgroup.StartArea -1) * (msgshdr.recsize + msgshdr.syssize)))
break;
} }
/*
* Skip systems
*/
fseek(mp, msgshdr.syssize, SEEK_CUR);
} }
rc = 1;
}
/* if (!rc) {
* Create the record with the defaults from the group record. Syslog('m', "No free slot, append after last record");
*/ fseek(mp, 0, SEEK_END);
offset = ((ftell(mp) - msgshdr.hdrsize) / (msgshdr.recsize + msgshdr.syssize)) + 1; if (ftell(mp) < msgshdr.hdrsize + ((mgroup.StartArea -1) * (msgshdr.recsize + msgshdr.syssize))) {
memset(&msgs, 0, sizeof(msgs)); Syslog('m', "Database too small, expanding...");
strncpy(msgs.Tag, tag, 50); memset(&msgs, 0, sizeof(msgs));
strncpy(msgs.Name, desc, 40); memset(&System, 0, sizeof(System));
strncpy(msgs.QWKname, tag, 20); while (TRUE) {
msgs.MsgKinds = PUBLIC; fwrite(&msgs, sizeof(msgs), 1, mp);
msgs.Type = ECHOMAIL; for (i = 0; i < (msgshdr.syssize / sizeof(System)); i++)
msgs.DaysOld = CFG.defdays; fwrite(&System, sizeof(System), 1, mp);
msgs.MaxMsgs = CFG.defmsgs; if (ftell(mp) >= msgshdr.hdrsize + ((mgroup.StartArea -1) * (msgshdr.recsize + msgshdr.syssize)))
msgs.UsrDelete = mgroup.UsrDelete; break;
msgs.RDSec = mgroup.RDSec; }
msgs.WRSec = mgroup.WRSec; }
msgs.SYSec = mgroup.SYSec; rc = 1;
strncpy(msgs.Group, mgroup.Name, 12); }
msgs.Aka = mgroup.UseAka;
strncpy(msgs.Origin, CFG.origin, 50);
msgs.Aliases = mgroup.Aliases;
msgs.NetReply = mgroup.NetReply;
msgs.Active = TRUE;
msgs.Quotes = mgroup.Quotes;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
tag = tl(tag);
for (i = 0; i < strlen(tag); i++)
if (tag[i] == '.')
tag[i] = '/';
sprintf(msgs.Base, "%s/%s", mgroup.BasePath, tag);
fwrite(&msgs, sizeof(msgs), 1, mp);
memset(&System, 0, sizeof(System)); /*
System.aka = mgroup.UpLink; * Create the record with the defaults from the group record.
System.sendto = System.receivefrom = TRUE; */
fwrite(&System, sizeof(System), 1, mp); offset = ((ftell(mp) - msgshdr.hdrsize) / (msgshdr.recsize + msgshdr.syssize)) + 1;
memset(&System, 0, sizeof(System)); memset(&msgs, 0, sizeof(msgs));
for (i = 1; i < (msgshdr.syssize / sizeof(System)); i++) strncpy(msgs.Tag, tag, 50);
strncpy(msgs.Name, desc, 40);
strncpy(msgs.QWKname, tag, 20);
msgs.MsgKinds = PUBLIC;
msgs.Type = ECHOMAIL;
msgs.DaysOld = CFG.defdays;
msgs.MaxMsgs = CFG.defmsgs;
msgs.UsrDelete = mgroup.UsrDelete;
msgs.RDSec = mgroup.RDSec;
msgs.WRSec = mgroup.WRSec;
msgs.SYSec = mgroup.SYSec;
strncpy(msgs.Group, mgroup.Name, 12);
msgs.Aka = mgroup.UseAka;
strncpy(msgs.Origin, CFG.origin, 50);
msgs.Aliases = mgroup.Aliases;
msgs.NetReply = mgroup.NetReply;
msgs.Active = TRUE;
msgs.Quotes = mgroup.Quotes;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
tag = tl(tag);
for (i = 0; i < strlen(tag); i++)
if (tag[i] == '.')
tag[i] = '/';
sprintf(msgs.Base, "%s/%s", mgroup.BasePath, tag);
fwrite(&msgs, sizeof(msgs), 1, mp);
memset(&System, 0, sizeof(System));
System.aka = mgroup.UpLink;
System.sendto = System.receivefrom = TRUE;
fwrite(&System, sizeof(System), 1, mp); fwrite(&System, sizeof(System), 1, mp);
memset(&System, 0, sizeof(System));
for (i = 1; i < (msgshdr.syssize / sizeof(System)); i++)
fwrite(&System, sizeof(System), 1, mp);
fclose(mp); fclose(mp);
fclose(ap); fclose(ap);
free(buf); free(buf);
free(temp); free(temp);
Syslog('+', "Auto created echo %s, group %s, area %ld, for node %s", Syslog('+', "Auto created echo %s, group %s, area %ld, for node %s",
msgs.Tag, msgs.Group, offset, ascfnode(f , 0x1f)); msgs.Tag, msgs.Group, offset, ascfnode(f , 0x1f));
return 0; return 0;
} /* if (strcmp(tag, Area) == 0) */ } /* if (strcmp(tag, Area) == 0) */
} /* if (strlen(buf) && isalnum(buf[0])) */
} /* while (fgets(buf, 4096, ap)) */ } /* while (fgets(buf, 4096, ap)) */
Syslog('m', "Area %s not found in taglist", Area); Syslog('m', "Area %s not found in taglist", Area);

View File

@ -228,12 +228,9 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
p = xstrcpy(hdr((char *)"X-Fidonet-Comment-To",msg)); p = xstrcpy(hdr((char *)"X-Fidonet-Comment-To",msg));
if (p == NULL) if (p == NULL)
p = xstrcpy(hdr((char *)"X-Apparently-To",msg)); p = xstrcpy(hdr((char *)"X-Apparently-To",msg));
if (p == NULL)
p = xstrcpy(hdr((char *)"Reply-To", msg));
if (p == NULL) if (p == NULL)
p = xstrcpy(hdr((char *)"To", msg)); /* 14-Aug-2001 MB */ p = xstrcpy(hdr((char *)"To", msg)); /* 14-Aug-2001 MB */
if (p) { if (p) {
Syslog('n', "getting `to' address from: \"%s\"",p);
if ((tmsg->to = parsefaddr(p)) == NULL) if ((tmsg->to = parsefaddr(p)) == NULL)
tmsg->to = parsefaddr((char *)"All@p0.f0.n0.z0"); tmsg->to = parsefaddr((char *)"All@p0.f0.n0.z0");
if ((l = strrchr(p,'<')) && (r = strchr(p,'>')) && (l < r)) { if ((l = strrchr(p,'<')) && (r = strchr(p,'>')) && (l < r)) {
@ -285,7 +282,9 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
tmsg->to->point = msgs.Aka.point; tmsg->to->point = msgs.Aka.point;
tmsg->to->domain = xstrcpy(msgs.Aka.domain); tmsg->to->domain = xstrcpy(msgs.Aka.domain);
} else { } else {
Syslog('n', "Filling default To: address"); /*
* Filling a default To: address.
*/
tmsg->to = (faddr*)malloc(sizeof(faddr)); tmsg->to = (faddr*)malloc(sizeof(faddr));
tmsg->to->name = xstrcpy((char *)"All"); tmsg->to->name = xstrcpy((char *)"All");
tmsg->to->zone = msgs.Aka.zone; tmsg->to->zone = msgs.Aka.zone;
@ -294,7 +293,7 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
tmsg->to->point = msgs.Aka.point; tmsg->to->point = msgs.Aka.point;
tmsg->to->domain = xstrcpy(msgs.Aka.domain); tmsg->to->domain = xstrcpy(msgs.Aka.domain);
} }
Syslog('n', "TO: %s",ascfnode(tmsg->to,0xff)); Syslog('N', "TO: %s",ascfnode(tmsg->to,0xff));
} else { } else {
if (recipient) { if (recipient) {
/* /*
@ -363,9 +362,7 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
while (isspace(*freename)) while (isspace(*freename))
freename++; freename++;
} }
// if (p) NOT IN IFMAIL
// free(p);
// p = NULL;
if (rfcfrom) { if (rfcfrom) {
while (isspace(*rfcfrom)) while (isspace(*rfcfrom))
rfcfrom++; rfcfrom++;
@ -389,9 +386,8 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
if ((!freename) || ((freename) && (*freename == '\0')) || (strcmp(freename,".")==0)) if ((!freename) || ((freename) && (*freename == '\0')) || (strcmp(freename,".")==0))
freename=rfcfrom; freename=rfcfrom;
// p = NULL;
if (newsmode) if (newsmode)
Syslog('n', "FROM: %s <%s>", freename, rfcfrom); Syslog('M', "FROM: %s <%s>", freename, rfcfrom);
else else
Syslog('+', "from: %s <%s>",freename,rfcfrom); Syslog('+', "from: %s <%s>",freename,rfcfrom);
@ -419,11 +415,12 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
replyaddr=NULL; replyaddr=NULL;
} }
if (needreplyaddr && (tmsg->from == NULL)) { if (needreplyaddr && (tmsg->from == NULL)) {
Syslog('m', "fill replyaddr with \"%s\"",rfcfrom); Syslog('M', "fill replyaddr with \"%s\"",rfcfrom);
replyaddr=xstrcpy(rfcfrom); replyaddr=xstrcpy(rfcfrom);
} }
Syslog('m', "From address was%s distinguished as ftn", tmsg->from ? "" : " not"); if (tmsg->from)
Syslog('m', "From address was%s distinguished as ftn", tmsg->from ? "" : " not");
if (newsmode) if (newsmode)
bestaka = bestaka_s(fido2faddr(msgs.Aka)); bestaka = bestaka_s(fido2faddr(msgs.Aka));
@ -503,11 +500,7 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
} else { } else {
tmsg->subj = xstrcpy((char *)" "); tmsg->subj = xstrcpy((char *)" ");
} }
// if (p) Syslog('M', "SUBJ: \"%s\"", tmsg->subj);
// free(p);
// p = NULL;
Syslog('m', "SUBJ: \"%s\"", tmsg->subj);
if ((p = hdr((char *)"X-FTN-FLAGS",msg))) if ((p = hdr((char *)"X-FTN-FLAGS",msg)))
tmsg->flags |= flagset(p); tmsg->flags |= flagset(p);
@ -569,7 +562,7 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
else else
tmsg->reply_a=NULL; tmsg->reply_a=NULL;
Syslog('m', "DATE: %s, MSGID: %s %lx, REPLY: %s %lx", Syslog('M', "DATE: %s, MSGID: %s %lx, REPLY: %s %lx",
ftndate(tmsg->date), MBSE_SS(tmsg->msgid_a),tmsg->msgid_n, MBSE_SS(tmsg->reply_a),tmsg->reply_n); ftndate(tmsg->date), MBSE_SS(tmsg->msgid_a),tmsg->msgid_n, MBSE_SS(tmsg->reply_a),tmsg->reply_n);
p = hdr((char *)"Organization",msg); p = hdr((char *)"Organization",msg);
@ -589,7 +582,7 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
tmsg->origin = xstrcpy(CFG.origin); tmsg->origin = xstrcpy(CFG.origin);
} }
Syslog('m', "ORIGIN: %s", MBSE_SS(tmsg->origin)); Syslog('M', "ORIGIN: %s", MBSE_SS(tmsg->origin));
return tmsg; return tmsg;
} }