tinyfeed miniature transit server
Russ Allbery
rra at stanford.edu
Thu Jul 15 05:21:56 UTC 2004
I wrote this a while back for a personal project, and have just finished
updating it to build against the current INN sources. I find this pretty
useful, but it's sort of strange. Do people think that this is useful
enough to include in INN and install along with everything else?
(And if so, should I create a new daemons or tiny directory in the source
tree for it? It doesn't seem quite right to drop it in with innd, but
there isn't another good directory in our source tree right now for it.)
Here's the documentation:
NAME
tinyfeed - Very simple IHAVE-only NNTP server
SYNOPSIS
tinyfeed *spool* [*processor*]
DESCRIPTION
tinyfeed is intended to be the simplest possible transit news server
that still does something useful. It must be run under inetd(8) or some
equivalent, and only implements three commands (IHAVE, HELP, and QUIT).
When it receives an article, it saves it into the directory *spool* and,
if *processor* is given, passes information about the article to
*processor* via a pipe.
When tinyfeed starts, it will scan the contents of *spool*, looking for
any file names that are integer numbers. It takes the largest number
found as a file name of any file in that directory, increments it by
one, and uses that as the first file name for a newly received article.
Each additional article received will be stored in a file named with the
next highest number. (Unpredictable things will happen if the article
name overflows an unsigned long.)
If *processor* is given, it should specify the path to a program. That
program is started when tinyfeed starts, and its current working
directory will be *spool*. For each article received by tinyfeed, a
single line will be sent to standard input of *processor*. That line
will consist of the file name of the received article (relative to
*spool*), a single space, and the message ID of the received article.
Note that the message ID will be taken from the argument to the IHAVE
command and may not match the Message-ID header in the article. When
tinyfeed shuts down, standard input to *processor* will be closed.
tinyfeed does no syntax verification of received articles whatsoever; it
just stores them and optionally passes them off to *processor*. It also
never deletes articles; normally, *processor* should do that when it's
finished doing whatever it needs to with the article.
tinyfeed expects NNTP commands on standard input and replies on standard
output. Status information and any error messages are sent to standard
error. It does no authentication; any authentication must be done by
inetd(8) or by a wrapper program. (One simple authentication mechanism
is to invoke tinyfeed via tcpd(8) from TCP wrappers and use
/etc/hosts.allow and /etc/hosts.deny to restrict who can talk to the
server.)
tinyfeed has a (currently hard-coded) maximum message size of 1MB and a
(similarly hard-coded) timeout of ten minutes for each command or chunk
of article data.
EXAMPLE
Suppose that you want to archive news articles on a particular host
(like the FTP server for a newsgroup archive) where you don't want the
overhead of running a full-blown news server. Write a program that
reads one line at a time from standard input and treats everything
before the first space as the filename of a news article to archive.
Each time the program reads a line, it should archive that file and then
delete it, and it should exit when it gets end of file on standard
input.
Then, add a line like:
nntp stream tcp nowait archive /usr/sbin/tcpd \
/usr/local/bin/tinyfeed /var/spool/tinyfeed /usr/local/bin/archive
(all on one line -- the backslash and split in this line is just for
readability) where "archive" is the user that owns the archive,
"/usr/sbin/tcpd" is the path to tcpd(8), "/usr/local/bin/tinyfeed" is
the path to this program, /var/spool/tinyfeed is some scratch directory
that the user "archive" has write access to, and
"/usr/local/bin/archive" is the path to your archive script.
You can now restrict access to tinyfeed to just your local news server
with "/etc/hosts.allow" and "/etc/hosts.deny" and set up an ordinary
feed from the server to the archive host, just like you would to any
other news server, of only the newsgroup that you want to archive.
Note that the archiving script should probably perform basic syntax and
validity checks on the input, since tinyfeed doesn't.
This is the application that motivated the original development of this
program.
BUGS
The timeout and maximum message size should really be configurable.
tinyfeed should also probably not just respond 500 to every command
other than IHAVE, HELP, and QUIT; there are more useful (and more
expected) error codes that could be returned.
HISTORY
Written by Russ Allbery <rra at stanford.edu> for InterNetNews.
$Id$
SEE ALSO
hosts_access(5), inetd(8), tcpd(8).
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
Please send questions to the list rather than mailing me directly.
<http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
More information about the inn-workers
mailing list