Added writing CHRS kludge

This commit is contained in:
Michiel Broek 2005-08-13 16:05:29 +00:00
parent 3e664a4f30
commit a8a07b73a2
2 changed files with 387 additions and 386 deletions

View File

@ -4,7 +4,7 @@
* Purpose ...............: Gate netmail->email or echomail->news * Purpose ...............: Gate netmail->email or echomail->news
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -300,36 +300,36 @@ void Send(int newsmode, char *outstr)
*/ */
int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int flags, FILE *pkt) int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int flags, FILE *pkt)
{ {
int rrq, result = 1, modtype = 0; int rrq, result = 1, modtype = 0;
int waskludge = FALSE, badkludge; int waskludge = FALSE, badkludge;
int bNeedToGetAddressFromMsgid = (int)NULL; int bNeedToGetAddressFromMsgid = (int)NULL;
int newsmode = 0, lines, pass, count, first; int newsmode = 0, lines, pass, count, first;
char *newsgroup = NULL, *distribution = NULL, *moderator = NULL; char *newsgroup = NULL, *distribution = NULL, *moderator = NULL;
char *temp, *p, *q, *r, *l, *b; char *temp, *p, *q, *r, *l, *b;
char *To = NULL, buf[4096], c; char *To = NULL, buf[4096], c;
time_t now; time_t now;
rfcmsg *kmsg = NULL, **tmsg, *qmsg, *msg = NULL; rfcmsg *kmsg = NULL, **tmsg, *qmsg, *msg = NULL;
off_t endmsg_off, tear_off, orig_off, via_off; off_t endmsg_off, tear_off, orig_off, via_off;
faddr *o, *bestaka, *ta, *tfaddr; faddr *o, *bestaka, *ta, *tfaddr;
FILE *fp; FILE *fp;
fa_list *rlist, *tfa, *ftnpath = NULL; fa_list *rlist, *tfa, *ftnpath = NULL;
struct utsname utsbuf; struct utsname utsbuf;
char MailFrom[128], MailTo[128]; char MailFrom[128], MailTo[128];
temp = calloc(32768, sizeof(char)); temp = calloc(32768, sizeof(char));
tmsg = &kmsg; tmsg = &kmsg;
tear_off = orig_off = via_off = 0L; tear_off = orig_off = via_off = 0L;
rbuf = NULL; rbuf = NULL;
if ((fp = tmpfile()) == NULL) { if ((fp = tmpfile()) == NULL) {
WriteError("$Unable to open temporary file"); WriteError("$Unable to open temporary file");
free(temp); free(temp);
return 4; return 4;
} }
Syslog('M', "Message input start ============="); Syslog('M', "Message input start =============");
rewind(pkt); rewind(pkt);
while ((fgets(buf, sizeof(buf)-2, pkt)) != NULL) { while ((fgets(buf, sizeof(buf)-2, pkt)) != NULL) {
/* /*
* Simple test to see how large the buffer must be. 2048 bytes has been seen. * Simple test to see how large the buffer must be. 2048 bytes has been seen.
*/ */
@ -469,10 +469,10 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
fputs(buf,fp); fputs(buf,fp);
} }
} }
Syslog('M', "Message input end ==============="); Syslog('M', "Message input end ===============");
if (bNeedToGetAddressFromMsgid && (p = hdr((char *)"MSGID", kmsg))) { if (bNeedToGetAddressFromMsgid && (p = hdr((char *)"MSGID", kmsg))) {
Syslog('m', "Need To Get Address From Msgid start..."); Syslog('m', "Need To Get Address From Msgid start...");
l = p; l = p;
while(isspace(*l) && *l) while(isspace(*l) && *l)
@ -496,38 +496,40 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
Syslog('+', "Origin from: %s (src MSGID)", ascfnode(f,0x7f)); Syslog('+', "Origin from: %s (src MSGID)", ascfnode(f,0x7f));
} }
} }
} }
endmsg_off=ftell(fp); endmsg_off=ftell(fp);
if ((tear_off) && (tear_off < endmsg_off)) if ((tear_off) && (tear_off < endmsg_off))
endmsg_off = tear_off; endmsg_off = tear_off;
if ((orig_off) && (orig_off < endmsg_off)) if ((orig_off) && (orig_off < endmsg_off))
endmsg_off = orig_off; endmsg_off = orig_off;
if ((via_off) && (via_off < endmsg_off)) if ((via_off) && (via_off < endmsg_off))
endmsg_off = via_off; endmsg_off = via_off;
Syslog('M', "end message offset %ld",(long)endmsg_off); Syslog('M', "end message offset %ld",(long)endmsg_off);
rewind(fp); rewind(fp);
msg = parsrfc(fp); msg = parsrfc(fp);
bestaka = bestaka_s(f); bestaka = bestaka_s(f);
rewind(fp); rewind(fp);
// p = hdr((char *)"CHRS", kmsg); p = hdr((char *)"CHRS", kmsg);
// if (p == NULL) if (p == NULL)
// p = hdr((char *)"CHARSET", kmsg); p = hdr((char *)"CHARSET", kmsg);
// if (p == NULL) if (p == NULL)
// p = hdr((char *)"CODEPAGE", kmsg); p = hdr((char *)"CODEPAGE", kmsg);
// if (p) if (p)
// outcode = readchrs(p); // outcode = readchrs(p);
// else { Syslog('m', "outcode from ftn kludge: %s", printable(p, 0));
// p=hdr((char *)"Content-Type",msg); else {
// if (p == NULL) p=hdr((char *)"Content-Type",msg);
// p=hdr((char *)"RFC-Content-Type",kmsg); if (p == NULL)
// if (p == NULL) p=hdr((char *)"RFC-Content-Type",kmsg);
// p=hdr((char *)"Content-Type",kmsg); if (p == NULL)
// if (p) p=hdr((char *)"Content-Type",kmsg);
// outcode=readcharset(p); if (p)
// else { // outcode=readcharset(p);
Syslog('m', "outcode from rfc header: %s", printable(p, 0));
else {
// q = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka); // q = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
// if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) || // if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
// (hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) || // (hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
@ -538,8 +540,9 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
// if (q) // if (q)
// free(q); // free(q);
// q = NULL; // q = NULL;
// } Syslog('m', "outcode will use default");
// } }
}
/* /*
* A hack for TerMail * A hack for TerMail
@ -553,26 +556,26 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
// if (pgpsigned) // if (pgpsigned)
// incode = outcode; // incode = outcode;
if (kmsg && !strcmp(kmsg->key,"AREA")) { if (kmsg && !strcmp(kmsg->key,"AREA")) {
/* /*
* The msgs record is already loaded. * The msgs record is already loaded.
*/ */
newsgroup = xstrcpy(msgs.Newsgroup); newsgroup = xstrcpy(msgs.Newsgroup);
if (strlen(msgs.Distribution)) if (strlen(msgs.Distribution))
distribution = xstrcpy(msgs.Distribution); distribution = xstrcpy(msgs.Distribution);
// if (strlen(msgs.Moderator)) { // if (strlen(msgs.Moderator)) {
// moderator = xstrcpy(msgs.Moderator); // moderator = xstrcpy(msgs.Moderator);
// if (msgs.MsgKinds == USEMOD) // if (msgs.MsgKinds == USEMOD)
// modtype = 1; // modtype = 1;
// } // }
Syslog('M', "newsgroup %s, distribution %s", printable(newsgroup, 0), printable(distribution, 0)); Syslog('M', "newsgroup %s, distribution %s", printable(newsgroup, 0), printable(distribution, 0));
newsmode = TRUE; newsmode = TRUE;
if ((modtype == 1) && (!hdr((char *)"Approved",msg)) && if ((modtype == 1) && (!hdr((char *)"Approved",msg)) &&
(!hdr((char *)"RFC-Approved",kmsg)) && (!hdr((char *)"Approved",kmsg))) (!hdr((char *)"RFC-Approved",kmsg)) && (!hdr((char *)"Approved",kmsg)))
newsmode = TRUE; newsmode = TRUE;
} else } else
newsmode = FALSE; newsmode = FALSE;
Syslog('m', "Got %s message", newsmode?"echo":"netmail"); Syslog('m', "Got %s message", newsmode?"echo":"netmail");
// if ((outcode == CHRS_NOTSET) && (hdr((char *)"MSGID", kmsg))) { // if ((outcode == CHRS_NOTSET) && (hdr((char *)"MSGID", kmsg))) {
// p = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka); // p = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
@ -590,282 +593,282 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
// incode = getincode(outcode); // incode = getincode(outcode);
/* /*
* fsc-0038 defines "^aDOMAIN: othernet 99:12/34 fidonet 2:293/2219" * fsc-0038 defines "^aDOMAIN: othernet 99:12/34 fidonet 2:293/2219"
*/ */
if ((p=hdr((char *)"DOMAIN",kmsg)) && (!strchr(p,'@'))) { if ((p=hdr((char *)"DOMAIN",kmsg)) && (!strchr(p,'@'))) {
strncpy(buf,p,sizeof(buf)-1); strncpy(buf,p,sizeof(buf)-1);
buf[sizeof(buf)-1]='\0'; buf[sizeof(buf)-1]='\0';
l=strtok(buf," \n"); l=strtok(buf," \n");
p=strtok(NULL," \n"); p=strtok(NULL," \n");
r=strtok(NULL," \n"); r=strtok(NULL," \n");
q=strtok(NULL," \n"); q=strtok(NULL," \n");
if ((ta=parsefnode(p))) { if ((ta=parsefnode(p))) {
t->point=ta->point; t->point=ta->point;
t->node=ta->node; t->node=ta->node;
t->net=ta->net; t->net=ta->net;
t->zone=ta->zone; t->zone=ta->zone;
tidy_faddr(ta); 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 ((p=hdr((char *)"INTL",kmsg))) {
strncpy(buf,p,sizeof(buf)-1);
buf[sizeof(buf)-1]='\0';
l=strtok(buf," \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);
}
} }
t->domain=xstrcpy(l);
/* if ((ta=parsefnode(q))) {
* fidogate generates "^aDOMAIN: Z2@fidonet" f->point=ta->point;
*/ f->node=ta->node;
if ((f->domain==NULL) && ((p=hdr((char *)"DOMAIN",kmsg)) && (q=strchr(p,'@')))) { f->net=ta->net;
*q='\0'; f->zone=ta->zone;
f->domain=xstrcpy(q+1); tidy_faddr(ta);
*q='@';
} }
f->domain=xstrcpy(r);
if ((p=hdr((char *)"FMPT",kmsg))) } else if ((p=hdr((char *)"INTL",kmsg))) {
f->point=atoi(p); strncpy(buf,p,sizeof(buf)-1);
if ((p=hdr((char *)"TOPT",kmsg))) buf[sizeof(buf)-1]='\0';
t->point=atoi(p); l=strtok(buf," \n");
r=strtok(NULL," \n");
if (!newsmode) { if ((ta=parsefnode(l))) {
Syslog('m', "final from: %s",ascfnode(f,0xff)); t->point=ta->point;
Syslog('m', "final to: %s",ascfnode(t,0xff)); 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);
}
}
if (!newsmode) { /*
p=hdr((char *)"Resent-To",msg); * fidogate generates "^aDOMAIN: Z2@fidonet"
if (p == NULL) */
p=hdr((char *)"To",msg); if ((f->domain==NULL) && ((p=hdr((char *)"DOMAIN",kmsg)) && (q=strchr(p,'@')))) {
if (p == NULL) *q='\0';
p=hdr((char *)"RFC-Resent-To",kmsg); f->domain=xstrcpy(q+1);
if (p == NULL) *q='@';
p=hdr((char *)"RFC-To",kmsg); }
if (p && is_local(t)) {
while (*p == ' ') if ((p=hdr((char *)"FMPT",kmsg)))
p++; f->point=atoi(p);
strncpy(buf, p, sizeof(buf) -1); if ((p=hdr((char *)"TOPT",kmsg)))
if (*(p = buf + strlen(buf) -1) == '\n') t->point=atoi(p);
*p='\0';
} else if (modtype == 1) if (!newsmode) {
sprintf(buf,"%s",moderator); Syslog('m', "final from: %s",ascfnode(f,0xff));
else Syslog('m', "final to: %s",ascfnode(t,0xff));
sprintf(buf,"%s",ascinode(t,0x7f)); }
substitute(buf);
Syslog('+', "mail from %s to %s",ascfnode(f,0x7f),buf); if (!newsmode) {
To = xstrcpy(buf); p=hdr((char *)"Resent-To",msg);
if (p == NULL)
p=hdr((char *)"To",msg);
if (p == NULL)
p=hdr((char *)"RFC-Resent-To",kmsg);
if (p == NULL)
p=hdr((char *)"RFC-To",kmsg);
if (p && is_local(t)) {
while (*p == ' ')
p++;
strncpy(buf, p, sizeof(buf) -1);
if (*(p = buf + strlen(buf) -1) == '\n')
*p='\0';
} else if (modtype == 1)
sprintf(buf,"%s",moderator);
else
sprintf(buf,"%s",ascinode(t,0x7f));
substitute(buf);
Syslog('+', "mail from %s to %s",ascfnode(f,0x7f),buf);
To = xstrcpy(buf);
// if (p) // if (p)
// free(p); // free(p);
p = NULL; p = NULL;
p = hdr((char *)"Return-Path",msg); p = hdr((char *)"Return-Path",msg);
if (p == NULL) if (p == NULL)
p=hdr((char *)"RFC-Return-Path",kmsg); p=hdr((char *)"RFC-Return-Path",kmsg);
if (p == NULL) if (p == NULL)
p=hdr((char *)"Return-Path",kmsg); p=hdr((char *)"Return-Path",kmsg);
if ((CFG.EmailMode == E_PRMISP) && (p == NULL)) if ((CFG.EmailMode == E_PRMISP) && (p == NULL))
p=hdr((char *)"From",msg); p=hdr((char *)"From",msg);
if (p) if (p)
sprintf(MailFrom, "%s", p); sprintf(MailFrom, "%s", p);
else else
sprintf(MailFrom, "%s", ascinode(f,0x7f)); sprintf(MailFrom, "%s", ascinode(f,0x7f));
Syslog('m', "MailFrom: %s", MailFrom); Syslog('m', "MailFrom: %s", MailFrom);
if (To) if (To)
sprintf(MailTo, "%s", To); sprintf(MailTo, "%s", To);
else else
sprintf(MailTo, "%s", t->name); sprintf(MailTo, "%s", t->name);
Syslog('m', "MailTo: %s", MailTo); Syslog('m', "MailTo: %s", MailTo);
/* /*
* Because we need the same stream for news and email * Because we need the same stream for news and email
* we need to check if the newsfile is already open. * we need to check if the newsfile is already open.
*/ */
if (newsopen) { if (newsopen) {
fclose(nfp); fclose(nfp);
newsopen = FALSE; newsopen = FALSE;
}
if ((nfp = tmpfile()) == NULL) {
WriteError("$Unable to open temporary file");
return 4;
}
Syslog('m', "Prepare is ready");
if (modtype == 1)
newsmode = TRUE;
} }
if (newsmode) { if ((nfp = tmpfile()) == NULL) {
/* WriteError("$Unable to open temporary file");
* Open temporary newsfile, append messages if it already exists. return 4;
*/ }
if (!newsopen) {
p = calloc(PATH_MAX, sizeof(char));
sprintf(p, "%s/tmp/newsout", getenv("MBSE_ROOT"));
if ((nfp = fopen(p, "a")) == NULL) {
WriteError("$Can't open %s", p);
free(p);
return 2;
}
free(p);
newsopen = TRUE;
}
if ((p=hdr((char *)"Path",msg)) == NULL) Syslog('m', "Prepare is ready");
p=hdr((char *)"RFC-Path",kmsg);
rlist=NULL;
fill_rlist(&rlist, p);
for (qmsg = kmsg; qmsg; qmsg = qmsg->next)
if (strcasecmp(qmsg->key, "SPTH") == 0)
fill_list(&ftnpath, qmsg->val, &rlist);
for (qmsg = kmsg; qmsg; qmsg = qmsg->next)
if (strcasecmp(qmsg->key, "PATH") == 0)
fill_list(&ftnpath, qmsg->val, &rlist);
tidy_falist(&rlist);
/* if (modtype == 1)
* Build Path: headerline newsmode = TRUE;
*/ }
q = xstrcpy((char *)"Path: ");
if (CFG.newsfeed == FEEDUUCP) { if (newsmode) {
/* /*
* If we don't run our own newsserver we have to simulate and * Open temporary newsfile, append messages if it already exists.
* add the UUCP nodename here. */
*/ if (!newsopen) {
memset(&utsbuf, 0, sizeof(utsbuf)); p = calloc(PATH_MAX, sizeof(char));
if (uname(&utsbuf)) { sprintf(p, "%s/tmp/newsout", getenv("MBSE_ROOT"));
WriteError("Can't get system nodename"); if ((nfp = fopen(p, "a")) == NULL) {
} else { WriteError("$Can't open %s", p);
q = xstrcat(q, utsbuf.nodename); free(p);
q = xstrcat(q, (char *)"!"); return 2;
} }
} free(p);
tfaddr = fido2faddr(msgs.Aka); newsopen = TRUE;
q = xstrcat(q, ascinode(tfaddr, 0x07)); }
tidy_faddr(tfaddr);
if ((p=hdr((char *)"Path",msg)) == NULL)
p=hdr((char *)"RFC-Path",kmsg);
rlist=NULL;
fill_rlist(&rlist, p);
for (qmsg = kmsg; qmsg; qmsg = qmsg->next)
if (strcasecmp(qmsg->key, "SPTH") == 0)
fill_list(&ftnpath, qmsg->val, &rlist);
for (qmsg = kmsg; qmsg; qmsg = qmsg->next)
if (strcasecmp(qmsg->key, "PATH") == 0)
fill_list(&ftnpath, qmsg->val, &rlist);
tidy_falist(&rlist);
/*
* Build Path: headerline
*/
q = xstrcpy((char *)"Path: ");
if (CFG.newsfeed == FEEDUUCP) {
/*
* If we don't run our own newsserver we have to simulate and
* add the UUCP nodename here.
*/
memset(&utsbuf, 0, sizeof(utsbuf));
if (uname(&utsbuf)) {
WriteError("Can't get system nodename");
} else {
q = xstrcat(q, utsbuf.nodename);
q = xstrcat(q, (char *)"!"); q = xstrcat(q, (char *)"!");
if (ftnpath) }
for (tfa=ftnpath->next;tfa;tfa=tfa->next) { }
/* FIXME: possible memory leak */ tfaddr = fido2faddr(msgs.Aka);
q = xstrcat(q, ascinode(tfa->addr,0x1f)); q = xstrcat(q, ascinode(tfaddr, 0x07));
q = xstrcat(q, (char *)"!"); tidy_faddr(tfaddr);
} q = xstrcat(q, (char *)"!");
tidy_falist(&ftnpath); if (ftnpath)
for (tfa=ftnpath->next;tfa;tfa=tfa->next) {
/* FIXME: possible memory leak */
q = xstrcat(q, ascinode(tfa->addr,0x1f));
q = xstrcat(q, (char *)"!");
}
tidy_falist(&ftnpath);
if (p) { if (p) {
while (isspace(*p)) while (isspace(*p))
p++; p++;
q = xstrcat(q, p); q = xstrcat(q, p);
} else } else
q = xstrcat(q, (char *)"not-for-mail"); q = xstrcat(q, (char *)"not-for-mail");
sprintf(temp, "%s\n", q); sprintf(temp, "%s\n", q);
Send(newsmode, temp);
free(q);
if ((p = hdr((char *)"Newsgroups",msg))) {
/*
* The gate at puddle.fidonet.org put spaces in Newsgroups header
*/
if ((strstr(p,", "))) {
while ((r = strchr(p, ' '))) {
*r = '\0';
strcat(p,r+1);
}
}
}
if (p == NULL)
p=hdr((char *)"RFC-Newsgroups",kmsg);
if (p == NULL)
p=hdr((char *)"Newsgroups",kmsg);
if (p) {
while (*p && isspace(*p))
p++;
sprintf(temp,"Newsgroups: %s\n",newsgroup);
Send(newsmode, temp);
sprintf(temp,"X-Origin-Newsgroups: %s",p);
Send(newsmode, temp);
} else {
sprintf(temp,"Newsgroups: %s\n",newsgroup);
Send(newsmode, temp);
}
if ((p=hdr((char *)"Distribution",msg))) {
sprintf(temp,"Distribution:%s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"RFC-Distribution",kmsg))) {
sprintf(temp,"Distribution: %s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"Distribution",kmsg))) {
sprintf(temp,"Distribution: %s",p);
Send(newsmode, temp);
} else if (distribution) {
sprintf(temp,"Distribution: %s\n",distribution);
Send(newsmode, temp);
}
p = hdr((char *)"Comment-To",msg);
if (p == NULL)
p=hdr((char *)"X-Comment-To",msg);
if (p == NULL)
p=hdr((char *)"To",msg);
if ((p) && (strcasecmp(p,"All\n"))) {
sprintf(temp,"X-Comment-To:%s", p);
Send(newsmode, temp);
} else {
if (p == NULL)
p=hdr((char *)"RFC-X-Comment-To",kmsg);
if (p == NULL)
p=hdr((char *)"RFC-Comment-To",kmsg);
if (p == NULL)
p=hdr((char *)"RFC-To",kmsg);
if ((p) && (strcasecmp(p,"All\n"))) {
sprintf(temp,"X-Comment-To: %s", p);
Send(newsmode, temp); Send(newsmode, temp);
free(q); } else if ((t) && (t->name) && (strcasecmp(t->name,"All"))) {
sprintf(temp,"X-Comment-To: %s\n", t->name);
if ((p = hdr((char *)"Newsgroups",msg))) { Send(newsmode, temp);
/* } else {
* The gate at puddle.fidonet.org put spaces in Newsgroups header sprintf(temp,"X-Comment-To: All\n");
*/ Send(newsmode, temp);
if ((strstr(p,", "))) { }
while ((r = strchr(p, ' '))) { }
*r = '\0';
strcat(p,r+1);
}
}
}
if (p == NULL)
p=hdr((char *)"RFC-Newsgroups",kmsg);
if (p == NULL)
p=hdr((char *)"Newsgroups",kmsg);
if (p) {
while (*p && isspace(*p))
p++;
sprintf(temp,"Newsgroups: %s\n",newsgroup);
Send(newsmode, temp);
sprintf(temp,"X-Origin-Newsgroups: %s",p);
Send(newsmode, temp);
} else {
sprintf(temp,"Newsgroups: %s\n",newsgroup);
Send(newsmode, temp);
}
if ((p=hdr((char *)"Distribution",msg))) {
sprintf(temp,"Distribution:%s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"RFC-Distribution",kmsg))) {
sprintf(temp,"Distribution: %s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"Distribution",kmsg))) {
sprintf(temp,"Distribution: %s",p);
Send(newsmode, temp);
} else if (distribution) {
sprintf(temp,"Distribution: %s\n",distribution);
Send(newsmode, temp);
}
p = hdr((char *)"Comment-To",msg);
if (p == NULL)
p=hdr((char *)"X-Comment-To",msg);
if (p == NULL)
p=hdr((char *)"To",msg);
if ((p) && (strcasecmp(p,"All\n"))) {
sprintf(temp,"X-Comment-To:%s", p);
Send(newsmode, temp);
} else {
if (p == NULL)
p=hdr((char *)"RFC-X-Comment-To",kmsg);
if (p == NULL)
p=hdr((char *)"RFC-Comment-To",kmsg);
if (p == NULL)
p=hdr((char *)"RFC-To",kmsg);
if ((p) && (strcasecmp(p,"All\n"))) {
sprintf(temp,"X-Comment-To: %s", p);
Send(newsmode, temp);
} else if ((t) && (t->name) && (strcasecmp(t->name,"All"))) {
sprintf(temp,"X-Comment-To: %s\n", t->name);
Send(newsmode, temp);
} else {
sprintf(temp,"X-Comment-To: All\n");
Send(newsmode, temp);
}
}
// for (tmpml=approve;tmpml;tmpml=tmpml->next) { // for (tmpml=approve;tmpml;tmpml=tmpml->next) {
// if ((strncmp(newsgroup,tmpml->prefix, strlen(tmpml->prefix)) == 0)) { // if ((strncmp(newsgroup,tmpml->prefix, strlen(tmpml->prefix)) == 0)) {
@ -875,22 +878,22 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
// } // }
// } // }
if ((p=hdr((char *)"Approved",msg))) { if ((p=hdr((char *)"Approved",msg))) {
sprintf(temp,"Approved:%s",p); sprintf(temp,"Approved:%s",p);
Send(newsmode, temp); Send(newsmode, temp);
} else if ((p=hdr((char *)"RFC-Approved",kmsg))) { } else if ((p=hdr((char *)"RFC-Approved",kmsg))) {
sprintf(temp,"Approved: %s",p); sprintf(temp,"Approved: %s",p);
Send(newsmode, temp); Send(newsmode, temp);
} else if ((p=hdr((char *)"Approved",kmsg))) { } else if ((p=hdr((char *)"Approved",kmsg))) {
sprintf(temp,"Approved: %s",p); sprintf(temp,"Approved: %s",p);
Send(newsmode, temp); Send(newsmode, temp);
} else if (modtype==2) { } else if (modtype==2) {
sprintf(temp,"Approved: %s\n",moderator); sprintf(temp,"Approved: %s\n",moderator);
Send(newsmode, temp); Send(newsmode, temp);
} }
} else { /* if newsmode */ } else { /* if newsmode */
now = time(NULL); now = time(NULL);
// if (CFG.EmailMode == E_NOISP) { // if (CFG.EmailMode == E_NOISP) {
// /* // /*
// * Probaly not needed as messages for systems without ISP never get here. // * Probaly not needed as messages for systems without ISP never get here.
@ -901,39 +904,39 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
// Send(FALSE, temp); // Send(FALSE, temp);
// } // }
Syslog('m', "Should send Received: header for mbfido"); Syslog('m', "Should send Received: header for mbfido");
sprintf(temp, "Received: from %s\n", ascinode(f, 0x3f)); sprintf(temp, "Received: from %s\n", ascinode(f, 0x3f));
Send(FALSE, temp); Send(FALSE, temp);
sprintf(temp, "\tby %s with FTN (mbfido v.%s) id AA%u\n", ascinode(bestaka,0x3f), VERSION, getpid()); sprintf(temp, "\tby %s with FTN (mbfido v.%s) id AA%u\n", ascinode(bestaka,0x3f), VERSION, getpid());
Send(FALSE, temp); Send(FALSE, temp);
sprintf(temp, "\t%s\n", rfcdate(now)); sprintf(temp, "\t%s\n", rfcdate(now));
Send(FALSE, temp); Send(FALSE, temp);
Syslog('m', "Is done now"); Syslog('m', "Is done now");
for (qmsg = kmsg; qmsg; qmsg = qmsg->next) for (qmsg = kmsg; qmsg; qmsg = qmsg->next)
if (!strcasecmp(qmsg->key,"RFC-Received")) { if (!strcasecmp(qmsg->key,"RFC-Received")) {
sprintf(temp, "%s: %s", qmsg->key+4, qmsg->val); sprintf(temp, "%s: %s", qmsg->key+4, qmsg->val);
Send(FALSE, temp); Send(FALSE, temp);
} }
for (qmsg = msg; qmsg; qmsg = qmsg->next) for (qmsg = msg; qmsg; qmsg = qmsg->next)
if (!strcasecmp(qmsg->key,"Received")) { if (!strcasecmp(qmsg->key,"Received")) {
sprintf(temp, "%s:%s", qmsg->key, qmsg->val); sprintf(temp, "%s:%s", qmsg->key, qmsg->val);
Send(FALSE, temp); Send(FALSE, temp);
} }
if ((p=hdr((char *)"Apparently-To",msg))) { if ((p=hdr((char *)"Apparently-To",msg))) {
sprintf(temp, "Apparently-To: %s\n",p); sprintf(temp, "Apparently-To: %s\n",p);
Send(FALSE, temp); Send(FALSE, temp);
} else if ((p=hdr((char *)"RFC-Apparently-To",kmsg))) { } else if ((p=hdr((char *)"RFC-Apparently-To",kmsg))) {
sprintf(temp, "Apparently-To: %s\n",p); sprintf(temp, "Apparently-To: %s\n",p);
Send(FALSE, temp); Send(FALSE, temp);
} else if ((p=hdr((char *)"Apparently-To",kmsg))) { } else if ((p=hdr((char *)"Apparently-To",kmsg))) {
sprintf(temp, "Apparently-To: %s\n",p); sprintf(temp, "Apparently-To: %s\n",p);
Send(FALSE, temp); Send(FALSE, temp);
} else if ((is_local(t))) { } else if ((is_local(t))) {
sprintf(temp, "Apparently-To: %s\n",buf); sprintf(temp, "Apparently-To: %s\n",buf);
Send(FALSE, temp); Send(FALSE, temp);
} }
if (flags & M_RRQ) if (flags & M_RRQ)
rrq=TRUE; rrq=TRUE;

View File

@ -44,7 +44,7 @@
#include "rfc2ftn.h" #include "rfc2ftn.h"
#define MAXHDRSIZE 2048 #define MAXHDRSIZE 4096
#define MAXSEEN 70 #define MAXSEEN 70
#define MAXPATH 73 #define MAXPATH 73
@ -164,7 +164,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders; int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders;
time_t Now; time_t Now;
temp = calloc(4097, sizeof(char)); temp = calloc(MAXHDRSIZE +1, 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));
@ -773,7 +773,6 @@ int needputrfc(rfcmsg *msg, int newsmode)
{ {
faddr *ta; faddr *ta;
// Syslog('M', "needputrfc(%s)", printable(msg->key,0));
if ((msg->key == NULL) || (strlen(msg->key) == 0)) return 0; if ((msg->key == NULL) || (strlen(msg->key) == 0)) return 0;
if (!strcasecmp(msg->key,"X-UUCP-From")) return -1; if (!strcasecmp(msg->key,"X-UUCP-From")) return -1;
@ -869,7 +868,6 @@ int needputrfc(rfcmsg *msg, int newsmode)
if (!strcasecmp(msg->key,"Complaints-To")) return 0; if (!strcasecmp(msg->key,"Complaints-To")) return 0;
/* Default X- headers */ /* Default X- headers */
if (!strncasecmp(msg->key,"X-",2)) return 0; if (!strncasecmp(msg->key,"X-",2)) return 0;
/*if (!strcasecmp(msg->key,"")) return ;*/
return 1; return 1;
} }