rsalz@uunet.uu.net (Rich Salz) (03/16/91)
Submitted-by: Rich $alz <rsalz@bbn.com> Posting-number: Volume 24, Issue 54 Archive-name: newsgate/part04 #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # Contents: Makefile TODO mkmailpost.1 news2mail.sh patchlevel.h # signoff.1 str.c test-addr test-gag # Wrapped by rsalz@litchi.bbn.com on Fri Mar 15 16:42:28 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH echo If this archive is complete, you will see the following message: echo ' "shar: End of archive 4 (of 4)."' if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(2636 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X## X## Makefile for mail/news gateway programs. X## $Header: /nfs/papaya/u2/rsalz/src/newsgate/src/RCS/Makefile,v 1.10 91/02/12 15:10:43 rsalz Exp $ X## XSHELL = /bin/sh X X## Edit appropriately. See gate.h before you touch UUCP_INET. X2_11 = /nfs/papaya/source/news2.11/src XUUCP_INET = /usr/lib/news/.admin/uucp-2-inet XDESTDIR = /usr/uucp/bin XOPT = -g X#OPT = -O XDEFS = XCFLAGS = $(OPT) $(DEFS) XLINKFLAGS = X#LINKFLAGS = -s -Bstatic X XTARFILE = newsgate.tar.Z X X## News files, copied over from $(2_11). XGETDATE = getdate.o X X## Gag, the gateway alias generator. XG_SRCS = gag.c lex.c misc.c XG_OBJS = gag.o lex.o misc.o X X## Mail2News, the mail into news part of the gateway. XM_SRCS = misc.c regex.c str.c hdr.c mail2news.c rfc822.c XM_OBJS = misc.o regex.o str.o hdr.o mail2news.o rfc822.o $(GETDATE) X X## News2Mail, the news into mail part of the gateway. XN_SRCS = misc.c news2mail.c XN_OBJS = misc.o news2mail.o X X## Manpages for the programs. XDOCS = gag.1 mail2news.1 mkmailpost.1 news2mail.1 signoff.1 X Xall: mail2news news2mail gag mkmailpost tags lint X Xinstall: all X @echo "Install as directed in the README file." X# @rm -f $(DESTDIR)/gag $(DESTDIR)/mail2news $(DESTDIR)/news2mail X# cp gag mail2news news2mail $(DESTDIR)/. X# cp uucp-2-inet $(UUCP_INET) X Xclean: X rm -f mail2news news2mail gag mkmailpost *.o X rm -f tags lint.? core gag.c gag.h lex.c X rm -f Part0? $(TARFILE) X Xtags: $(N_SRCS) $(M_SRCS) X ctags -tw $(N_SRCS) $(M_SRCS) $(G_SRCS) gate.h X Xlint: lint.d lint.g lint.m lint.n X X X## Xmail2news: $(M_OBJS) X @rm -f mail2news X $(CC) $(CFLAGS) $(LINKFLAGS) -o mail2news $(M_OBJS) X Xnews2mail: $(N_OBJS) X @rm -f news2mail X $(CC) $(CFLAGS) $(LINKFLAGS) -o news2mail $(N_OBJS) X Xgag: $(G_OBJS) X @rm -f gag X $(CC) $(CFLAGS) $(LINKFLAGS) -o gag $(G_OBJS) X Xmkmailpost: mkmailpost.sh X @rm -f mkmailpost X cp mkmailpost.sh mkmailpost X chmod 755 mkmailpost X X## X$(G_OBJS) $(M_OBJS) $(N_OBJS): gate.h X X X## Xlint.d: $(DOCS) X checknr -c.IR.BI.RI $(DOCS) regex.3 >lint.d Xlint.g: gag X lint -a -h $(DEFS) $(G_SRCS) |grep -v yaccpar >lint.g Xlint.m: mail2news X lint -a -b -h $(DEFS) $(M_SRCS) >lint.m Xlint.n: news2mail X lint -a -b -h $(DEFS) $(N_SRCS) >lint.n X X X## Keep intermediate files around. Xlex.o: lex.c Xgag.o: gag.c Xgag.c: gag.y X @rm -f gag.c gag.h X yacc -d gag.y X @mv y.tab.c gag.c X @mv y.tab.h gag.h X X X## Xshar: X @rm -f Part0? X makekit -m X @rm -f MANIFEST.BAK X @-chmod 444 Part0? Xtar: X @rm -f $(TARFILE) X tar cf newsgate.tar `awk 'NR > 2 { print $$1; }' <MANIFEST` X compress newsgate.tar X X X## Get the date parser from 2.11 news. X$(GETDATE): X @rm -f $(GETDATE) X cd $(2_11) ; make $(GETDATE) X cp $(2_11)/$(GETDATE) . END_OF_FILE if test 2636 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'TODO' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'TODO'\" else echo shar: Extracting \"'TODO'\" \(723 characters\) sed "s/^X//" >'TODO' <<'END_OF_FILE' X XA news2mail option that specifies an Errors-To header. XA mail2news option that specifies where errors get mailed to. XA news2mail option that specifies a Sender header. X XFrom tower@bu-it.BU.EDU XFrom looking!brad XFrom isaak!woerz XFrom ateng!chip XFrom auspex!guy XSummary: Generate References: line from X - indentical Subject line texts (less any 'Re: 's) X (Involves keeping a database of current subject lines; use iff X In-Relpy-To is missing subject starts with Re:) X - Message-ID's (where present) in In-Reply-To: kines X - Other information in In-Reply-To: lines. X XProblems -- Berkeley Mail doesn't generate them, do other UA's? X They don't always contain the Message-ID of the message to X which the user is replying. END_OF_FILE if test 723 -ne `wc -c <'TODO'`; then echo shar: \"'TODO'\" unpacked with wrong size! fi # end of 'TODO' fi if test -f 'mkmailpost.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mkmailpost.1'\" else echo shar: Extracting \"'mkmailpost.1'\" \(2475 characters\) sed "s/^X//" >'mkmailpost.1' <<'END_OF_FILE' X.\" $Header: /nfs/papaya/u2/rsalz/src/newsgate/src/RCS/mkmailpost.1,v 1.5 91/02/12 14:49:13 rsalz Exp $ X.TH MKMAILPOST 1 LOCAL X.SH NAME Xmkmailpost \- make a set of mailpost commands for a gag file X.SH SYNOPSIS X.B mkmailpost X[ X.B activefile X[ X.B mail2news_path X] ] X.SH DESCRIPTION X.I mkmailpost Xreads the news active file and generates a a set of ``mailpost'' commands Xfor feeding into X.IR gag (1L). XOutput is sent to the standard output. X.PP XThe first argument is the path to the news active file; the default is X.IR /usr/lib/news . XThe second argument is the path to the X.I mail2news Xprogram; if specified, then a ``default mail2news X.IR path '' Xis output. X.PP X.I Mkmailpost Xignores moderated groups, as well as ``junk,'' ``general,'' and those Xof the form X.RI ``to. site .'' XIt also ignores groups with the word ``test'' in them; such groups usually Xhave mail reflectors attached to them, so that the poster gets a copy of Xtheir message. XIt is assumed that this is not appropriate if someone is mailing into a site. X.I Mkmailpost Xalso ignores groups with with the words ``announce'' in them under the Xassumption that they are moderated groups and mail should be sent to Xthe moderator, instead. X(It is agreed that finding the moderator for non-Usenet sites can be Xproblematic.) X.PP XAssume the main X.I gag Xinput is named X.IR main.gag . XThe following command line can be useful: X.RS X.nf X( echo '#include "main.gag"' ; mkmailpost ) \e X | /lib/cpp | gag X.fi X.RE X(On some systems you may have to use ``cc \-E'' or ``cc \-P'' instead Xof ``/lib/cpp.'') X.SH BUGS XSince the name and number of Usenet groups changes very frequently, Xa better method is to define a more general way of feeding mail into Xnewsgroups. XFor example, with X.IR sendmail (8), Xit is possible to define a class for all top-level groups (this changes Xmuch less frequently), and define a ``news'' mailer to receive mail Xsent to such addresses. XIf the following class is defined: X.RS X.nf XCNcomp misc news rec sci soc talk alt XCNunix\-pc ddn gnu u3b pubnet X.fi X.RE Xthen these lines can be added to the ``mailer resolver'' part of ruleset zero: X.RS XR$=N.$* $#news$:$1.$2 Posting to news X.RE Xwith the following mailer defined: X.RS X.nf X.ta \w'Mnews, 'u XMnews, P=/usr/lib/news/mail2news, X F=DFMls, M=131071, A=mail2news -n $u X.fi X.RE XThis idea comes from Karl Kleinpaste <karl@cis.ohio-state.edu>. X.SH "SEE ALSO" Xgag(1L). X.SH AUTHOR XRich $alz <rsalz@bbn.com>, after an idea by X.br XErik E. Fair <fair@apple.com>. END_OF_FILE if test 2475 -ne `wc -c <'mkmailpost.1'`; then echo shar: \"'mkmailpost.1'\" unpacked with wrong size! fi # end of 'mkmailpost.1' fi if test -f 'news2mail.sh' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'news2mail.sh'\" else echo shar: Extracting \"'news2mail.sh'\" \(2032 characters\) sed "s/^X//" >'news2mail.sh' <<'END_OF_FILE' X#! /bin/sh X## $Header: /nfs/papaya/u2/rsalz/src/newsgate/src/RCS/news2mail.sh,v 1.3 91/02/12 14:50:28 rsalz Exp $ X## A short, mostly-awk, script to send news on stdin out as mail. X## Usage: news2mail <address> X## Written by John S. Quarterman <jsq@longway.tic.com>. X## Light editing by Rich $alz <rsalz@bbn.com>. XPATH=/usr/local:/usr/ucb:/bin:/usr/bin ; export PATH X Xcase $1 in X"") X echo "Usage: `basename $0` address" X exit 1 X ;; X"-") X TO="cat -u" X ;; X*) X TO="/bin/mail $1" X ;; Xesac X Xawk ' XBEGIN { X header = 1; X date = ""; X} Xheader == 1 && /^$/ { X # End of headers; print dates. X header = 0; X if (pdate != "" && date ~ /GMT/ && pdate !~ /GMT/) { X print "Date: "pdate; X print "Posted-Date: "date; X } else { X if (date != "") X print "Date: "date; X if (pdate != "") X print "Posted-Date: "pdate; X } X} Xheader == 0 { X print $0; X next; X} X$1 == "Relay-Version:" { next; } X$1 == "Posting-Version:" { next; } X$1 == "Path:" { next; } X$1 == "From" { next; } X$1 == "Date-Received:" { next; } X$1 == "Received-Date:" { next; } X#$1 == "Newsgroups:" { next; } X#$1 == "Organization:" { next; } X$1 == "Approved:" { next; } X$1 == "Lines:" { next; } X$1 == "Date:" { X date = $2; X for (i = 3; i <= NF; i++) X date = date " " $i; X next; X} X$1 == "Posted-Date:" { X pdate = $2; X for (i = 3; i <= NF; i++) X pdate = pdate " " $i; X next; X} X$1 == "From:" { X address=$2; X name = ""; X surround = 0; X for (f = 3; f <= NF; f++) { X if ($f ~ /,/) X surround=1; X if (split ($f, parts, "(") > 1) X it = parts[2]; X else X it = $f; X if (split ($f, parts, ")") > 1) X it = parts[1]; X if (name == "") X name = it; X else X name = name " " it; X } X if (address ~ /.UUCP$/) { X split(address, parts, "@"); X address = sprintf ("%s%%%s@%s", parts[1], parts[2], "'`hostname`'"); X } X if (surround != 0) X printf ("From: %s (%s)\n", address, name); X else X printf ("From: %s <%s>\n", name, address); X next; X} X{ X print $0; X}' | eval $TO END_OF_FILE if test 2032 -ne `wc -c <'news2mail.sh'`; then echo shar: \"'news2mail.sh'\" unpacked with wrong size! fi chmod +x 'news2mail.sh' # end of 'news2mail.sh' fi if test -f 'patchlevel.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patchlevel.h'\" else echo shar: Extracting \"'patchlevel.h'\" \(478 characters\) sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE' X/* X** HEADER FILE FOR NEWS/MAIL GATEWAY CODE. X** $Header: /nfs/papaya/u2/rsalz/src/newsgate/src/RCS/patchlevel.h,v 1.2 91/02/12 15:02:40 rsalz Exp $ X** X** $Log: patchlevel.h,v $ X** Revision 1.2 91/02/12 15:02:40 rsalz X** Incorporate all known major code fixes. X** For release to NNTP-MANAGERS, prior to posting. X** I hope next release will be 2.0, reasonable patches. X** X** Revision 1.1 89/07/10 13:04:23 rsalz X** Initial revision X** X*/ X#define PATCHLEVEL 10 END_OF_FILE if test 478 -ne `wc -c <'patchlevel.h'`; then echo shar: \"'patchlevel.h'\" unpacked with wrong size! fi # end of 'patchlevel.h' fi if test -f 'signoff.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'signoff.1'\" else echo shar: Extracting \"'signoff.1'\" \(2210 characters\) sed "s/^X//" >'signoff.1' <<'END_OF_FILE' X.\" $Header: /nfs/papaya/u2/rsalz/src/newsgate/src/RCS/signoff.1,v 1.3 91/02/12 14:54:40 rsalz Exp $ X.TH SIGNOFF 1 LOCAL X.SH NAME Xsignoff \- See if a message is a subscription request X.SH SYNOPSIS X.B signoff X[ X.I message_file X] X.SH DESCRIPTION X.PP X.I Signoff Xis a small hack used to see if a mail message is one of those annoying X\&``please add me'' or ``please drop me from your list'' messages. XSuch messages should be sent to a list maintainer, but often people Xmake mistakes and send them to the entire list. XThis behavior is particularly impolite when a message is gatewayed into Xa Usenet newsgroup. X.PP XWhen invoked as a front-end to X.IR mail2news , X.I signoff Xdoes a pretty good job of trapping such messages before they get posted. X.I Signoff Xreads the message from the file named in its first argument, or from Xstandard input if no arguments are given. XIt exits with a successful (zero) status if the message is a normal one, Xor does an ``exit(1)'' if the message is a subscription request. XFor example, here is a script that could be used as a wrapper around the X.I news2mail Xprogram: X.RS X.nf X#! /bin/sh Xcat >/tmp/signoff$$ Xif /usr/lib/news/signoff </tmp/signoff$$ ; then X /usr/ucb/Mail -s "Rejected subscription request" news </tmp/signoff$$ Xelse X /usr/lib/news/mail2news.real </tmp/signoff$$ Xfi Xexec rm /tmp/signoff$$ X.fi X.RE X.PP XNote that X.I signoff Xis already incorporated into X.IR mail2news ; Xsee the ``\-F'' option. XIt is provided here as a separate program for more conservative use. X(The ``\-F'' doesn't send rejected messages to the news account for Xverification.) XAlso, with the following line in your news sys file: X.RS X.nf Xsignoff:all::/usr/lib/news/test_signoff X.fi X.RE Xand the following script: X.RS X.nf X#! /bin/sh Xcat >/tmp/ts$$ X/usr/lib/news/signoff </tmp/ts$$ || Mail -s "Signoff found" news </tmp/ts$$ Xexec rm /tmp/ts$$ X.fi X.RE Xit is possible to test the ``algorithm'' used by X.IR signoff . X.SH BUGS XPerhaps a better way to test is to make the test less conservative, Xand see what valid articles get caught, and make adjustments then? XComments on the program are solicited. X.SH AUTHORS XRich $alz <rsalz@bbn.com>, after a program by X.br XRuss Nelson <nelson@clutx.clarkson.edu>. END_OF_FILE if test 2210 -ne `wc -c <'signoff.1'`; then echo shar: \"'signoff.1'\" unpacked with wrong size! fi # end of 'signoff.1' fi if test -f 'str.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'str.c'\" else echo shar: Extracting \"'str.c'\" \(612 characters\) sed "s/^X//" >'str.c' <<'END_OF_FILE' X/* X** String-related routines for mail2news. X*/ X#include "gate.h" X#ifdef RCSID Xstatic char RCS[] = X "$Header: /nfs/papaya/u2/rsalz/src/newsgate/src/RCS/str.c,v 1.6 91/03/13 15:57:16 rsalz Exp $"; X#endif /* RCSID */ X X X/* X** For Ozan Yigit's public domain regex. X*/ X/* ARGSUSED */ Xvoid Xre_fail(text, arg) X char *text; X int arg; X{ X} X X X/* X** Free up something that ReadFile made. This doesn't belong here, X** but news2mail doesn't need it, so we don't want it in misc.c. X*/ Xvoid XFreeFile(V) X char **V; X{ X register char **p; X X if (p = V) { X while (*p) X free(*p++); X free((char *)V); X } X} END_OF_FILE if test 612 -ne `wc -c <'str.c'`; then echo shar: \"'str.c'\" unpacked with wrong size! fi # end of 'str.c' fi if test -f 'test-addr' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'test-addr'\" else echo shar: Extracting \"'test-addr'\" \(540 characters\) sed "s/^X//" >'test-addr' <<'END_OF_FILE' X## X## Test re-write rules in hdr.c with -DTEST. X## $Header: /nfs/papaya/u2/rsalz/src/newsgate/src/RCS/test-addr,v 1.2 89/10/24 22:07:45 rsalz Exp $ X## Xuucp-site!user Xsite.dom.com!user Xsite1.dom.com!user@site2.dom2.com Xuser@site.arpa Xuser%site.edu@relay.cs.net Xuser%site@relay.cs.net Xuusite1!uusite2!uucp-site!user Xuusite1!uusite2!uucp-site.edu!user Xuusite1!uucp-site.bogus!user Xuser@dec-site.uucp Xuser@site.oz Xseismo!site.oz!user Xuser%site.bitnet@bitgate Xuser%gate1%gate.edu@bitgate X@router:user@site.com Xuser%site1.edu%site2.com@gateway END_OF_FILE if test 540 -ne `wc -c <'test-addr'`; then echo shar: \"'test-addr'\" unpacked with wrong size! fi # end of 'test-addr' fi if test -f 'test-gag' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'test-gag'\" else echo shar: Extracting \"'test-gag'\" \(2749 characters\) sed "s/^X//" >'test-gag' <<'END_OF_FILE' X/* X** Test suite for gag, Gateway Alias Generator. X** X** $Header: /nfs/papaya/u2/rsalz/src/newsgate/src/RCS/test-gag,v 1.3 89/11/01 17:36:56 rsalz Exp $ X*/ X X X/* X** BBN MAILING LISTS X*/ X/* default inews flags = ""; */ Xdefault distributions = "world usa na ne bbn ddn gnu inet"; Xdefault directory = "/usr/lib/news/.admin"; /* Where MMDF scripts are */ Xdefault mail2news = "/usr/uucp/bin/mail2news"; /* Paths to gateway */ Xdefault news2mail = "/usr/uucp/bin/news2mail"; /* programs */ Xdefault mailcontact = "usenet"; /* Put in mail headers */ Xdefault mailhost = "mailer.bbn.com"; /* MMDF list processor */ Xdefault mailinglist = true; /* Going both ways */ Xdefault organization = "BBN news/mail gateway"; Xdefault owner = "usenet"; /* Sendmail alias owner */ Xdefault site = "gateway"; /* Psuedo news site */ Xdefault user = "news"; /* MMDF script owner */ X X/* newsgroup mailing list */ Xgateway bbn.bboard bboard; Xgateway bbn.test usenet; X X/* Mail rec.equestrian articles to the list moderator, unless he's seen X * them already. */ Xgateway rec.equestrian horse X news2mail = X "v6mail -to kenr@ccp.bbn.com -subj 'Forwarded Horse Article'" X site = "ccp.bbn.com"; X X/* Set up post-comp-foo as an alias that posts articles. */ Xmailpost comp.foo; X X X/* X** GNU MAILING LISTS (OSU) X*/ Xdefault site = "internet"; /* Psuedo news site */ Xdefault inews flags = "-x internet -d gnu"; /* Flags for mail2news */ Xdefault mail2news = "/usr/lib/news/nrecnews"; /* Path to mail2news */ Xdefault mailhost = "prep.ai.mit.edu"; /* Home of mailing list */ Xdefault mailinglist = true; /* Going both ways */ Xdefault organization = dotify("GNUs Not Usenet"); Xdefault owner = "usenet"; /* Sendmail alias owner */ X Xgateway gnu.announce info-gnu X moderator = "info-gnu@prep.ai.mit.edu" X inews flags = "-d gnu"; Xgateway gnu.emacs info-gnu-emacs; Xgateway gnu.emacs.bug bug-gnu-emacs; Xgateway gnu.gdb.bug bug-gdb; Xgateway gnu.gcc info-gcc; Xgateway gnu.gcc.bug bug-gcc; Xgateway gnu.g++ info-g++; Xgateway gnu.g++.bug bug-g++; Xgateway gnu.chess info-chess; Xgateway gnu.ghostscript.bug bug-ghostscript; Xgateway gnu.utils.bug bug-gnu-utils; Xgateway gnu.emacs.gnus info-gnus-english X mailhost = "cis.ohio-state.edu"; Xgateway gnu.emacs.vms vms-gnu-emacs X mailhost = "harvard.havard.edu"; Xgateway gnu.emacs.lisp.manual gnu-manual X mailhost = "a.cs.uiuc.edu"; X X X/* X** OSU LOCAL MAILING LISTS X*/ Xgateway alt.sca sca X inews flags = "-d alt -x internet" X mailhost = "mc.lcs.mit.edu" X mailinglist = false X organization = dotify("Society for Creative Anachronism"); X Xgateway cis.big-lan big-lan X inews flags = "-d cis -x internet" X mailhost = "suvm.acs.syr.edu" X organization = dotify("The Internet"); END_OF_FILE if test 2749 -ne `wc -c <'test-gag'`; then echo shar: \"'test-gag'\" unpacked with wrong size! fi # end of 'test-gag' fi echo shar: End of archive 4 \(of 4\). cp /dev/null ark4isdone MISSING="" for I in 1 2 3 4 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 4 archives. rm -f ark[1-9]isdone else echo You still must unpack the following archives: echo " " ${MISSING} fi exit 0 exit 0 # Just in case... -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net. Use a domain-based address or give alternate paths, or you may lose out.