diff -ur mailgw-0.3.0/Makefile mailgw-0.3.1/Makefile --- mailgw-0.3.0/Makefile Thu Jul 10 00:25:08 1997 +++ mailgw-0.3.1/Makefile Thu Feb 4 21:00:09 1999 @@ -42,3 +42,4 @@ nntp_rcv.o: nntp_rcv.c config.h pbbs_out.h wildmat.h utils.h rfcutils.h log.h smtp_rcv.o: smtp_rcv.c config.h pbbs_out.h wildmat.h utils.h rfcutils.h log.h pbbs_rcv.o: pbbs_rcv.c config.h pbbs_out.h wildmat.h utils.h rfcutils.h log.h + diff -ur mailgw-0.3.0/README mailgw-0.3.1/README --- mailgw-0.3.0/README Mon Mar 24 01:43:15 1997 +++ mailgw-0.3.1/README Thu Feb 4 19:35:50 1999 @@ -1,7 +1,7 @@ mailgw - a bidirectional email/news <> packet bbs mail gateway - Copyright (C) 1997 Heikki Hannikainen, OH7LZB + Copyright (C) 1997, 1999 Heikki Hannikainen, OH7LZB See the doc/ subdirectory for some files which could probably diff -ur mailgw-0.3.0/config.c mailgw-0.3.1/config.c --- mailgw-0.3.0/config.c Thu Jul 10 02:24:12 1997 +++ mailgw-0.3.1/config.c Thu Feb 4 18:47:39 1999 @@ -3,6 +3,7 @@ #include #include #include +#include extern void panic(const char *fmt, ...); @@ -23,24 +24,26 @@ char *innxmit = NULL; char *sendmail = NULL; -static int do_string(dest, argc, argv); -static int do_int(dest, argc, argv); +static int do_string(char **dest, int argc, char **argv); +static int do_int(int *dest, int argc, char **argv); + +#define _CFUNC_ (int (*)(void *dest, int argc, char **argv)) static struct cmd cfg_cmds[] = { - { "hostname", do_string, &hostname }, - { "callsign", do_string, &callsign }, - { "hroute", do_string, &hroute }, - { "qth", do_string, &qth }, - { "loglevel", do_int, &loglevel }, - { "logdest", do_int, &logdest }, - { "importfile", do_string, &importfile }, - { "importlock", do_string, &importlock }, - { "exportfile", do_string, &exportfile }, - { "exportlock", do_string, &exportlock }, - { "spooldir", do_string, &spooldir }, - { "innxmit", do_string, &innxmit }, - { "sendmail", do_string, &sendmail }, - { NULL, NULL, NULL } + { "hostname", _CFUNC_ do_string, &hostname }, + { "callsign", _CFUNC_ do_string, &callsign }, + { "hroute", _CFUNC_ do_string, &hroute }, + { "qth", _CFUNC_ do_string, &qth }, + { "loglevel", _CFUNC_ do_int, &loglevel }, + { "logdest", _CFUNC_ do_int, &logdest }, + { "importfile", _CFUNC_ do_string, &importfile }, + { "importlock", _CFUNC_ do_string, &importlock }, + { "exportfile", _CFUNC_ do_string, &exportfile }, + { "exportlock", _CFUNC_ do_string, &exportlock }, + { "spooldir", _CFUNC_ do_string, &spooldir }, + { "innxmit", _CFUNC_ do_string, &innxmit }, + { "sendmail", _CFUNC_ do_string, &sendmail }, + { NULL, NULL, NULL } }; /* ***************************************************************** */ Only in mailgw-0.3.1: config.o Only in mailgw-0.3.1: crc.o diff -ur mailgw-0.3.0/doc/Changes mailgw-0.3.1/doc/Changes --- mailgw-0.3.0/doc/Changes Thu Jul 10 01:29:26 1997 +++ mailgw-0.3.1/doc/Changes Thu Feb 4 20:54:54 1999 @@ -7,3 +7,29 @@ - Fixed a bug in pbbs_rcv.c. - Added a X-BBS-Path: header on outgoing SMTP and NNTP messages. +0.3.1 4 February 1999: + - Compiles with libc6/glibc (#include ). + - Suppressed compiler warnings in config.c + - Fixed T: line handling in pbbs_rcv.c (bug pointed out and fix + offered by Lars Petterson, SM6RPZ ) + - Fixed datestr() static buffer clearing in pbbs_rcv.c (Lars) + - Fixed readl() to handle all weird newline combinations (Lars) + - Made parse_hdrs() to get X-BBS-To: too + - nntp_rcv.c relays to distribution defined in X-BBS-To: instead + of trusting newsgroup.map, if the header happens to exist + (to protect from accidental rewrites, suggestion from Lars) + - Added links to Dave G7PIT's mailgw and fbbforward web pages + in doc/README + - pbbs_out.c: Fixed Y2K problem in pbbstime() (thanks go to + Andrew Benham, G8FSL ) + - pbbs_rcv.c: Fixed Y2K problem in parsetime(). Also replaced + somehow problematic sscanf() with some others, which has + other problems (Ichiro Hieda ) + - First line of each received PBBS message was missing. Fixed. + (thanks Ichiro) + - Added message counter (msgc) as component in temporary files + (outgoing smtp and nntp spool), due to linux ftime() returning + inaccurate time and file names getting duplicated (problem + pointed out by Ichiro) + - pbbs_rcv.c: handlemesg(), freed mid* too early (Ichiro) + \ No newline at end of file diff -ur mailgw-0.3.0/doc/README mailgw-0.3.1/doc/README --- mailgw-0.3.0/doc/README Sat Jul 5 20:28:56 1997 +++ mailgw-0.3.1/doc/README Thu Feb 4 19:43:21 1999 @@ -15,3 +15,20 @@ inn/ - Example configuration files for inn, The news server + Links: + +http://www.tranquilandia.demon.co.uk/linux/mailgw/ + + More/better instructios in setting up mailgw to run with + Sendmail 8.8. ! Also includes general instructions about + mailgw configuring. Must read! + +http://www.tranquilandia.demon.co.uk/linux/fbbforward/ + + "Steve Fraser vk5asf and Dave Brown g7pit are pleased to + announce a release of a beta version of fbbforward. This is + a set of programs to allow a Linux system to natively forward + to/from FBB systems, and (if required) to send/receive mail + and news via Hessu Hannikainen's nntp/smtp gateway. It does + NOT require to run FBB." + Only in mailgw-0.3.1: log.o Only in mailgw-0.3.1: nntp_rcv diff -ur mailgw-0.3.0/nntp_rcv.c mailgw-0.3.1/nntp_rcv.c --- mailgw-0.3.0/nntp_rcv.c Thu Jul 10 00:24:30 1997 +++ mailgw-0.3.1/nntp_rcv.c Thu Feb 4 19:29:44 1999 @@ -53,10 +53,11 @@ int process(char *path) { - struct art_hdr art = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + struct art_hdr art = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; struct pb_hdr pb = { "", 0, "", "", "", "", "", "", "", 0 }; struct newsgroup_map *nm; char *src; + char *p; FILE *f; if ((f = fopen(path, "r")) == NULL) { @@ -75,8 +76,18 @@ strcpy(pb.toname, "News: "); hstrncat(pb.toname, art.newsgroups, NAMELEN); hstrncpy(pb.bid, (art.bid) ? art.bid : pbbsmid(art.mid, art.newsgroups), BIDLEN); - hstrncpy(pb.to, nm->to, CALLEN); - hstrncpy(pb.tobbs, nm->bbs, HRLEN); + if (art.x_bbs_to) { + if ((p = strchr(art.x_bbs_to, '@'))) { + *p = '\0'; + p++; + } else + p = nm->bbs; + hstrncpy(pb.to, art.x_bbs_to, CALLEN); + hstrncpy(pb.tobbs, p, HRLEN); + } else { + hstrncpy(pb.to, nm->to, CALLEN); + hstrncpy(pb.tobbs, nm->bbs, HRLEN); + } hstrncpy(pb.subj, art.subj, LINELEN); pb.time = 0; /* kröhöm... */ say(L_ROUTING, "%s %s > %s => $%s %s@%s > %s@%s", Only in mailgw-0.3.1: nntp_rcv.o diff -ur mailgw-0.3.0/pbbs_out.c mailgw-0.3.1/pbbs_out.c --- mailgw-0.3.0/pbbs_out.c Sat Jul 5 20:36:51 1997 +++ mailgw-0.3.1/pbbs_out.c Thu Feb 4 19:54:31 1999 @@ -5,6 +5,7 @@ #include #include #include +#include #include "config.h" #include "rfcutils.h" @@ -22,8 +23,8 @@ struct tm *t; t = gmtime(&ti); - snprintf(s, 13, "%02i%02i%02i/%02i%02iZ", t->tm_year, t->tm_mon+1, - t->tm_mday, t->tm_hour, t->tm_min); + snprintf(s, 13, "%02i%02i%02i/%02i%02iZ", t->tm_year % 100, + t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min); return s; } @@ -119,7 +120,7 @@ if (!(lh = fbblock(exportlock))) return -1; - + if (!(imf = fopen(importfile, "a"))) { syslog(LOG_ERR, "Couldn't open bbs import file %s: %s. Giving up.", importfile, strerror(errno)); } else { Only in mailgw-0.3.1: pbbs_out.o Only in mailgw-0.3.1: pbbs_rcv diff -ur mailgw-0.3.0/pbbs_rcv.c mailgw-0.3.1/pbbs_rcv.c --- mailgw-0.3.0/pbbs_rcv.c Thu Jul 10 02:24:02 1997 +++ mailgw-0.3.1/pbbs_rcv.c Thu Feb 4 21:03:52 1999 @@ -49,15 +49,31 @@ /* * Parse a PBBS style date/time string: yymmdd/hhmmZ */ - + time_t parsetime(char *s) { struct tm t = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + char ss[4]; + + /* FIXME: This WILL SCREW UP BAD if the date/time string is, + for example, shorter than expected, or otherwise corrupted */ + ss[0] = *s++; ss[1] = *s++; ss[2] = '\0'; + if (ss[0] == '0') ss[0] = ' '; + sscanf(ss, "%i", &t.tm_year); + ss[0] = *s++; ss[1] = *s++; + if (ss[0] == '0') ss[0] = ' '; + sscanf(ss, "%i", &t.tm_mon); + ss[0] = *s++; ss[1] = *s++; + sscanf(ss, "%i", &t.tm_mday); + s++; /* skip / */ + ss[0] = *s++; ss[1] = *s++; + sscanf(ss, "%i", &t.tm_hour); + ss[0] = *s++; ss[1] = *s++; + sscanf(ss, "%i", &t.tm_min); - sscanf(s, "%02i%02i%02i/%02i%02i", &t.tm_year, &t.tm_mon, &t.tm_mday, - &t.tm_hour, &t.tm_min); - t.tm_mon--; + if (t.tm_year < 34) /* Y2K workaround */ + t.tm_year += 100; return mktime(&t); } @@ -76,7 +92,7 @@ snprintf(s, 40, "%s, %i %s %i %02i:%02i:%02i +0000", daystr[tm->tm_wday], tm->tm_mday, monstr[tm->tm_mon], tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec); - s[40] = '\0'; /* Hey, just in case... */ + s[39] = '\0'; /* Hey, just in case... */ return s; } @@ -109,10 +125,14 @@ return NULL; /* EOF */ for (p = s; (*p); p++) - if (*p == '\r') + if (*p == '\r') { *p = '\n'; - else if (*p == '\n') + p++; *p = '\0'; + } else if (*p == '\n') { + p++; + *p = '\0'; + } return s; } @@ -153,20 +173,19 @@ int handlemesg(void) { char *s, *t; - int argc, arg = 2; char *argv[32]; - + struct pb_hdr pb = { "", 0, "", "", "", "", "", "", "", 0 }; char pbsrc[CALLEN + HRLEN], pbdst[CALLEN + HRLEN]; char pbpath[LINELEN] = ""; char *src = NULL, *dst = NULL, *newsgroups = NULL, *mid = NULL; - + struct timeb tp; char tfname[PATHLEN], str[PATHLEN]; FILE *tf; - + struct newsgroup_map *m; /* Read and parse message header */ @@ -265,9 +284,6 @@ /* Read the T: lines */ while (1) { - if (!(s = readln())) - break; /* EOF */ - if (strncmp(s, "T:", 2)) break; /* Finished with T: lines */ @@ -283,23 +299,28 @@ if ((!strncasecmp(s, "T:Message-ID: ", 14)) && (mid == NULL)) { mid = strdup(&s[14]); } + + if (!(s = readln())) + break; /* EOF */ } /* Decide the routing (smtp or nntp), and do the rewriting. */ snprintf(pbsrc, CALLEN + HRLEN, "%s@%s", pb.from, pb.frombbs); snprintf(pbdst, CALLEN + HRLEN, "%s@%s", pb.to, pb.tobbs); - + /* Rewrite source address, if it wasn't found on T: lines */ - if ((src) || (src = map_address(pbsrc, PBBS_SRC))) { + if (src) { + /* we have it from the T: line already. */ + } else if ((src = map_address(pbsrc, PBBS_SRC))) { t = strdup(src); src = t; - ftime(&tp); strlwr(src); } else { say(L_R_ERR, "$%s %s > %s: No source mapping", pb.bid, pbsrc, pbdst); pb.mtype = MT_NONE; } + ftime(&tp); if (!mid) mid = bidtomid(pb.bid); @@ -309,7 +330,9 @@ case MT_P: /* Personal message => smtp */ /* Rewrite destination address, if necessary */ - if ((dst) || (dst = map_address(pbdst, PBBS_DST))) { + if (dst) { + /* we have it from the T: line already. */ + } else if ((dst = map_address(pbdst, PBBS_DST))) { t = strdup(dst); dst = t; strlwr(dst); @@ -323,7 +346,7 @@ say(L_ROUTING, "$%s %s > %s => %s %s > %s", pb.bid, pbsrc, pbdst, mid, src, dst); - snprintf(tfname, PATHLEN, "/tmp/%i.%i.tmp", tp.time, tp.millitm); + snprintf(tfname, PATHLEN, "/tmp/%i.%i.%i.tmp", tp.time, tp.millitm, msgc); if (!(tf = fopen(tfname, "w"))) { say(L_ERR, "$%s: Cannot open temporary file %s: %s. Message lost.", pb.bid, tfname, strerror(errno)); @@ -349,7 +372,9 @@ case MT_B: /* Bulletin => nntp */ - if ((newsgroups) || ((m = pick_newsgroup(pb.to, pb.tobbs, pb.from, pb.frombbs))) ) { + if (newsgroups) { + /* we have it from the T: line already. */ + } else if ((m = pick_newsgroup(pb.to, pb.tobbs, pb.from, pb.frombbs))) { newsgroups = strdup(m->newsgroup); } else { say(L_R_ERR, "$%s %s > %s: No newsgroup mapping", @@ -361,7 +386,7 @@ say(L_ROUTING, "$%s %s > %s => %s %s > %s", pb.bid, pbsrc, pbdst, mid, src, newsgroups); - snprintf(tfname, PATHLEN, "%s/%i.%i.tmp", spooldir, tp.time, tp.millitm); + snprintf(tfname, PATHLEN, "%s/%i.%i.%s.tmp", spooldir, tp.time, tp.millitm, msgc); if (!(tf = fopen(tfname, "w"))) { say(L_ERR, "Cannot open temporary file %s: %s. Message lost.", tfname, strerror(errno)); @@ -388,12 +413,8 @@ free(src); free(dst); free(newsgroups); - free(mid); /* Read the message body */ - if (pb.mtype) /* This one was read in while looking for T: lines */ - fputs(s, tf); - while (1) { if (!(s = readln())) break; /* EOF */ @@ -425,6 +446,8 @@ break; } } + + free(mid); return 1; } Only in mailgw-0.3.1: pbbs_rcv.o diff -ur mailgw-0.3.0/rfcutils.c mailgw-0.3.1/rfcutils.c --- mailgw-0.3.0/rfcutils.c Sat Apr 12 09:26:54 1997 +++ mailgw-0.3.1/rfcutils.c Thu Feb 4 19:28:27 1999 @@ -108,14 +108,13 @@ *p = '\0'; if (art->path == NULL && !strncasecmp(s, "Path:", 5)) { art->path = hdrval(&s[5]); - } else - if (art->from == NULL && !strncasecmp(s, "From:", 5)) { + } else if (art->from == NULL && !strncasecmp(s, "From:", 5)) { art->from = hdrval(&s[5]); - } else - if (art->to == NULL && !strncasecmp(s, "To:", 3)) { + } else if (art->to == NULL && !strncasecmp(s, "To:", 3)) { art->to = hdrval(&s[3]); - } else - if (art->returnpath == NULL && !strncasecmp(s, "Return-Path:", 12)) { + } else if (art->x_bbs_to == NULL && !strncasecmp(s, "X-BBS-To:", 9)) { + art->x_bbs_to = hdrval(&s[3]); + } else if (art->returnpath == NULL && !strncasecmp(s, "Return-Path:", 12)) { art->returnpath = hdrval(&s[12]); } else if (art->date == NULL && !strncasecmp(s, "Date:", 5)) { diff -ur mailgw-0.3.0/rfcutils.h mailgw-0.3.1/rfcutils.h --- mailgw-0.3.0/rfcutils.h Fri Apr 11 19:51:10 1997 +++ mailgw-0.3.1/rfcutils.h Thu Feb 4 19:28:17 1999 @@ -8,6 +8,7 @@ char *returnpath; char *to; char *toaddr; + char *x_bbs_to; char *date; char *mid; char *bid; Only in mailgw-0.3.1: rfcutils.o Only in mailgw-0.3.1: smtp_rcv diff -ur mailgw-0.3.0/smtp_rcv.c mailgw-0.3.1/smtp_rcv.c --- mailgw-0.3.0/smtp_rcv.c Thu Jul 10 00:27:37 1997 +++ mailgw-0.3.1/smtp_rcv.c Thu Feb 4 19:20:41 1999 @@ -33,7 +33,7 @@ int process(char *fromaddr, char *tohost, char *toaddr) { - struct art_hdr art = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + struct art_hdr art = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; struct pb_hdr pb = { "", 0, "", "", "", "", "", "", "", 0 }; char *src, *dst, *t; Only in mailgw-0.3.1: smtp_rcv.o Only in mailgw-0.3.1: utils.o Only in mailgw-0.3.1: wildmat.o