diff --git a/ChangeLog b/ChangeLog index 85710866..1fe4d2f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4516,6 +4516,10 @@ v0.33.19 26-Oct-2001 be missing since a while. Fixes for Fido->internet gate for dropped characters during linewrap. Experimental. + Added netmail bounce function. + Protected the postemail function from posting to local FTN + addresses, this will cause a mailloop for undeliverable mail. + These mails will be bounced back. mbfile: During checks the file databases are reset to filemode 0660. diff --git a/mbfido/Makefile b/mbfido/Makefile index 881c350c..a4d578c5 100644 --- a/mbfido/Makefile +++ b/mbfido/Makefile @@ -13,7 +13,7 @@ SRCS = addbbs.c backalias.c flock.c hatch.c mbdiff.c mgrutil.c pack.c \ mbmsg.c newspost.c postemail.c scan.c toberep.c atoul.c filemgr.c \ hash.c mbaff.c mbseq.c notify.c postnetmail.c scannews.c tosspkt.c \ mbfkill.c mbfutil.c mbfindex.c mbfcheck.c mbfpack.c mbflist.c mbfadopt.c \ - mbfimport.c virscan.c mbftoberep.c mbfmove.c mbfdel.c + mbfimport.c virscan.c mbftoberep.c mbfmove.c mbfdel.c bounce.c HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h pack.h \ postnetmail.h scannews.h tosspkt.h addpkt.h bwrite.h forward.h \ lhash.h mbfido.h mkftnhdr.h paths.h ptic.h sendmail.h tracker.h \ @@ -23,9 +23,9 @@ HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h pack.h \ grlist.h maketags.h mbmsg.h newspost.h postecho.h rollover.h tic.h \ atoul.h filemgr.h hash.h mbaff.h mbseq.h notify.h postemail.h scan.h toberep.h \ mbfkill.h mbfutil.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfadopt.h \ - mbfimport.h virscan.h mbftoberep.h mbfmove.h mbfdel.h + mbfimport.h virscan.h mbftoberep.h mbfmove.h mbfdel.h bounce.h MBFIDO_OBJS = flock.o tosspkt.o mbfido.o hatch.o maketags.o virscan.o \ - tracker.o makestat.o scannews.o lhash.o \ + tracker.o makestat.o scannews.o lhash.o bounce.o \ pack.o ulock.o tic.o ptic.o utic.o mover.o hash.o mkftnhdr.o \ addbbs.o magic.o fsort.o toberep.o ftn2rfc.o atoul.o ping.o \ cookie.o forward.o sendmail.o scan.o addpkt.o storenet.o storeecho.o \ @@ -185,7 +185,7 @@ hash.o: ../lib/libs.h hash.h lhash.h mbaff.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h announce.h filefind.h mbaff.h mbseq.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbseq.h notify.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbnode.h filemgr.h areamgr.h sendmail.h notify.h -postnetmail.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/dbcfg.h ../lib/dbuser.h ../lib/dbnode.h ../lib/dbftn.h ../lib/common.h ../lib/clcomm.h tracker.h addpkt.h storenet.h ftn2rfc.h areamgr.h filemgr.h ping.h postemail.h +postnetmail.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/dbcfg.h ../lib/dbuser.h ../lib/dbnode.h ../lib/dbftn.h ../lib/common.h ../lib/clcomm.h tracker.h addpkt.h storenet.h ftn2rfc.h areamgr.h filemgr.h ping.h bounce.h postemail.h scannews.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h rollover.h pack.h storeecho.h rfc2ftn.h scannews.h tosspkt.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h tosspkt.h postnetmail.h postecho.h rollover.h mbfkill.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfkill.h mbfutil.h @@ -200,4 +200,5 @@ virscan.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib mbftoberep.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbftoberep.h mbfmove.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfmove.h mbfdel.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfmove.h +bounce.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbtic.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h sendmail.h mgrutil.h postnetmail.h ping.h # End of generated dependencies diff --git a/mbfido/areamgr.c b/mbfido/areamgr.c index 95185733..82b15fa2 100644 --- a/mbfido/areamgr.c +++ b/mbfido/areamgr.c @@ -53,6 +53,7 @@ * External declarations */ extern int do_quiet; +extern char *tearline; @@ -124,8 +125,7 @@ void A_Help(faddr *t, char *replyid) fprintf(fp, " -GENERAL\r"); fprintf(fp, " %%QUERY\r"); fprintf(fp, " %%LIST\r\r"); - - fprintf(fp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(fp, "%s\r", tearline); CloseMail(fp, t); net_out++; } else @@ -231,7 +231,7 @@ void A_Query(faddr *t, char *replyid) fprintf(qp, " P - The message area is temporary paused\r"); fprintf(qp, " C - You are cutoff from this area\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(qp, "%s\r", tearline); CloseMail(qp, t); net_out++; free(temp); @@ -338,7 +338,7 @@ void A_List(faddr *t, char *replyid, int Notify) fprintf(qp, " P - The message area is temporary paused\r"); fprintf(qp, " C - You are cutoff from this area\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(qp, "%s\r", tearline); CloseMail(qp, t); net_out++; free(temp); @@ -452,7 +452,7 @@ void A_Flow(faddr *t, char *replyid, int Notify) fprintf(qp, "Con means:\r"); fprintf(qp, " C - You connected to this area\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(qp, "%s\r", tearline); CloseMail(qp, t); net_out++; free(temp); @@ -493,7 +493,7 @@ void A_Status(faddr *t, char *replyid) fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(fp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(fp, "%s\r", tearline); CloseMail(fp, t); net_out++; } else @@ -599,7 +599,7 @@ void A_Unlinked(faddr *t, char *replyid) fprintf(qp, " P - The message area is temporary paused\r"); fprintf(qp, " C - You are cutoff from this area\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(qp, "%s\r", tearline); CloseMail(qp, t); net_out++; free(temp); @@ -1068,7 +1068,7 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla } fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(np, "%s\r", tearline); CloseMail(np, t); net_out++; } else diff --git a/mbfido/filemgr.c b/mbfido/filemgr.c index 3304fa3f..cc01707e 100644 --- a/mbfido/filemgr.c +++ b/mbfido/filemgr.c @@ -52,6 +52,7 @@ * External declarations */ extern int do_quiet; +extern char *tearline; @@ -123,7 +124,7 @@ void F_Help(faddr *t, char *replyid) fprintf(fp, " %%QUERY\r"); fprintf(fp, " %%LIST\r\r"); - fprintf(fp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(fp, "%s\r", tearline); CloseMail(fp, t); net_out++; } else @@ -225,7 +226,7 @@ void F_Query(faddr *t, char *replyid) fprintf(qp, " S - You may send files in this area\r"); fprintf(qp, " P - The file area is temporary paused\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(qp, "%s\r", tearline); CloseMail(qp, t); net_out++; free(temp); @@ -328,7 +329,7 @@ void F_List(faddr *t, char *replyid, int Notify) fprintf(qp, " S - You may send files in this area\r"); fprintf(qp, " P - The file area is temporary paused\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(qp, "%s\r", tearline); CloseMail(qp, t); net_out++; free(temp); @@ -378,7 +379,7 @@ void F_Status(faddr *t, char *replyid) fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(fp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(fp, "%s\r", tearline); CloseMail(fp, t); net_out++; } else @@ -480,7 +481,7 @@ void F_Unlinked(faddr *t, char *replyid) fprintf(qp, " S - You may send files in this area\r"); fprintf(qp, " P - The file area is temporary paused\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(qp, "%s\r", tearline); CloseMail(qp, t); net_out++; free(temp); @@ -941,7 +942,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla } fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "--- MBSE BBS v%s (Linux)\r", VERSION); + fprintf(np, "%s\r", tearline); CloseMail(np, t); net_out++; } else diff --git a/mbfido/mbaff.c b/mbfido/mbaff.c index a058d092..ebcace7e 100644 --- a/mbfido/mbaff.c +++ b/mbfido/mbaff.c @@ -48,6 +48,7 @@ extern int do_quiet; /* Supress screen output */ extern int show_log; /* Show logging */ time_t t_start; /* Start time */ time_t t_end; /* End time */ +char *tearline; /* Standard tearline */ @@ -82,6 +83,7 @@ void die(int onsig) colour(7, 0); printf("\n"); } + free(tearline); ExitClient(onsig); } @@ -105,6 +107,17 @@ int main(int argc, char **argv) Miy = t->tm_mon; umask(002); + tearline = calloc(41, sizeof(char *)); +#ifdef __linux__ + sprintf(tearline, "--- MBSE BBS v%s (Linux)", VERSION); +#elif __FreeBSD__ + sprintf(tearline, "--- MBSE BBS v%s (FreeBSD)", VERSION); +#elif __NetBSD__ + sprintf(tearline, "--- MBSE BBS v%s (NetBSD)", VERSION); +#else + sprintf(tearline, "--- MBSE BBS v%s (Unknown)", VERSION); +#endif + /* * Catch all signals we can, and ignore the rest. */ diff --git a/mbfido/mbfido.c b/mbfido/mbfido.c index 82f70223..a1bb1aff 100644 --- a/mbfido/mbfido.c +++ b/mbfido/mbfido.c @@ -93,6 +93,7 @@ time_t t_end; /* End time */ int packets = 0; /* Tossed packets */ int packets_ok = 0; /* Tossed packets Ok. */ char *envptr = NULL; +char *tearline; /* Standard tearline for mail */ extern int net_in, net_imp, net_out, net_bad; extern int echo_in, echo_imp, echo_out, echo_bad, echo_dupe; @@ -241,6 +242,7 @@ void die(int onsig) if (!do_quiet) colour(7, 0); + free(tearline); ExitClient(onsig); } @@ -303,6 +305,17 @@ int main(int argc, char **argv) Miy = t->tm_mon; umask(002); + tearline = calloc(41, sizeof(char *)); +#ifdef __linux__ + sprintf(tearline, "--- MBSE BBS v%s (Linux)", VERSION); +#elif __FreeBSD__ + sprintf(tearline, "--- MBSE BBS v%s (FreeBSD)", VERSION); +#elif __NetBSD__ + sprintf(tearline, "--- MBSE BBS v%s (NetBSD)", VERSION); +#else + sprintf(tearline, "--- MBSE BBS v%s (Unknown)", VERSION); +#endif + /* * Catch all the signals we can, and ignore the rest. */ diff --git a/mbfido/mbmsg.c b/mbfido/mbmsg.c index 432be590..0ad3a900 100644 --- a/mbfido/mbmsg.c +++ b/mbfido/mbmsg.c @@ -58,6 +58,7 @@ int msg_del = 0; /* Deleted messages */ int msg_link = 0; /* Linked messages */ int processed = FALSE; /* Did process something */ int oldmask; +char *tearline; /* Standard tearline */ @@ -95,6 +96,17 @@ int main(int argc, char **argv) oldmask = umask(007); t_start = time(NULL); + tearline = calloc(41, sizeof(char *)); +#ifdef __linux__ + sprintf(tearline, "--- MBSE BBS v%s (Linux)", VERSION); +#elif __FreeBSD__ + sprintf(tearline, "--- MBSE BBS v%s (FreeBSD)", VERSION); +#elif __NetBSD__ + sprintf(tearline, "--- MBSE BBS v%s (NetBSD)", VERSION); +#else + sprintf(tearline, "--- MBSE BBS v%s (Unknown)", VERSION); +#endif + /* * Catch all signals we can, and ignore or catch them */ @@ -244,6 +256,7 @@ void die(int onsig) colour(7, 0); printf("\r \n"); } + free(tearline); ExitClient(onsig); } diff --git a/mbfido/msgutil.c b/mbfido/msgutil.c index 640451ef..cc3e4a11 100644 --- a/mbfido/msgutil.c +++ b/mbfido/msgutil.c @@ -41,6 +41,7 @@ extern int do_quiet; /* Supress screen output */ +extern char *tearline; /* @@ -156,8 +157,7 @@ void Msg_Bot(fidoaddr UseAka, char *Org) sprintf(temp, "With regards, %s", CFG.sysop_name); MsgText_Add2(temp); MsgText_Add2((char *)""); - sprintf(temp, "--- MBSE BBS v%s (Linux)", VERSION); - MsgText_Add2(temp); + MsgText_Add2(tearline); if (UseAka.point) sprintf(aka, "(%d:%d/%d.%d)", UseAka.zone, UseAka.net, UseAka.node, UseAka.point); diff --git a/mbfido/ping.c b/mbfido/ping.c index 492c03e7..cc6a08ca 100644 --- a/mbfido/ping.c +++ b/mbfido/ping.c @@ -53,6 +53,7 @@ * External declarations */ extern int do_quiet; +extern char *tearline; @@ -133,8 +134,7 @@ int Ping(faddr *f, faddr *t, FILE *fp, int intransit) fprintf(np, "======================================================================\r"); fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "--- MBSE BBS v%s (Linux)\r", VERSION); - + 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); diff --git a/mbfido/post.c b/mbfido/post.c index 1ef926f7..2a0a0863 100644 --- a/mbfido/post.c +++ b/mbfido/post.c @@ -41,6 +41,7 @@ extern int do_quiet; /* Supress screen output */ +extern char *tearline; @@ -210,8 +211,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) */ aka = calloc(40, sizeof(char)); MsgText_Add2((char *)""); - sprintf(temp, "--- MBSE BBS v%s (Linux)", VERSION); - MsgText_Add2(temp); + MsgText_Add2(tearline); if (msgs.Aka.point) sprintf(aka, "(%d:%d/%d.%d)", msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node, msgs.Aka.point); diff --git a/mbfido/postemail.c b/mbfido/postemail.c index 12503bf4..c17edfc2 100644 --- a/mbfido/postemail.c +++ b/mbfido/postemail.c @@ -61,21 +61,40 @@ int postemail(FILE *fp, char *MailFrom, char *MailTo) char *temp, *p; char buf[4096]; int result = 1; + faddr *fa; - temp = calloc(2048, sizeof(char)); rewind(fp); - Syslog('+', "SMTP: posting email from \"%s\" to \"%s\"", MailFrom, MailTo); + + /* + * If a user forgets the To: line at the start of the FTN + * netmail, we end up here with a UUCP user with a local + * address as the destination. + * We can't deliver this and create a loop if we pass this + * message to SMTP. + */ + if ((fa = parsefaddr(MailTo))) { + if (is_local(fa)) { + WriteError("Destination is a local FTN address"); + email_bad++; + tidy_faddr(fa); + return 2; + } + tidy_faddr(fa); + } + if (smtp_connect() == -1) { WriteError("SMTP: connection refused"); email_bad++; return 2; } + temp = calloc(2048, sizeof(char)); sprintf(temp, "MAIL FROM:<%s>\r\n", MailFrom); if (smtp_cmd(temp, 250)) { WriteError("SMTP: refused FROM <%s>", MailFrom); email_bad++; + free(temp); return 2; } @@ -83,12 +102,14 @@ int postemail(FILE *fp, char *MailFrom, char *MailTo) if (smtp_cmd(temp, 250)) { WriteError("SMTP: refused TO <%s>", MailTo); email_bad++; + free(temp); return 2; } if (smtp_cmd((char *)"DATA\r\n", 354)) { WriteError("SMTP refused DATA mode"); email_bad++; + free(temp); return 2; } diff --git a/mbfido/postnetmail.c b/mbfido/postnetmail.c index 3c05dcbd..40d8967d 100644 --- a/mbfido/postnetmail.c +++ b/mbfido/postnetmail.c @@ -45,6 +45,7 @@ #include "areamgr.h" #include "filemgr.h" #include "ping.h" +#include "bounce.h" #include "postemail.h" @@ -278,6 +279,12 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t case EMAIL: most_debug = TRUE; result = ftn2rfc(f, t, subject, orig, mdate, flags, fp); most_debug = FALSE; + 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);