=head1 NAME

tinyleaf - Very simple IHAVE-only NNTP server

=head1 SYNOPSIS

B<tinyleaf> I<spool> [I<processor>]

=head1 DESCRIPTION

B<tinyleaf> 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 (HELP, IHAVE, and QUIT).
When it receives an article, it saves it into the directory I<spool> and,
if I<processor> is given, passes information about the article to
I<processor> via a pipe.  The file name of the article will be the MD5
hash of its message-ID, and if a file by that name already exists,
B<tinyleaf> will refuse the article, reporting it as a duplicate.

If I<processor> is given, it should specify the path to a program.  That
program is started when B<tinyleaf> starts, and its current working
directory will be I<spool>.  For each article received by B<tinyleaf>, a
single line will be sent to standard input of I<processor>.  That line
will consist of the file name of the received article (relative to
I<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 field in the article.  When
B<tinyleaf> shuts down, standard input to I<processor> will be closed.

B<tinyleaf> does no syntax verification of received articles whatsoever;
it just stores them and optionally passes them off to I<processor>.  It
also never deletes articles; normally, I<processor> should do that when
it's finished doing whatever it needs to with the article.

B<tinyleaf> 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 B<tinyleaf> via tcpd(8) from TCP wrappers and use
F</etc/hosts.allow> and F</etc/hosts.deny> to restrict who can talk to the
server.)

B<tinyleaf> has a (currently hard-coded) maximum message size of S<1 MB> and a
(similarly hard-coded) timeout of ten minutes for each command or chunk of
article data.

=head1 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 \
      <pathbin>/tinyleaf <pathspool>/tinyleaf <pathbin>/archive

(all on one line S<-- the> backslash and split in this line is just for
readability) where C<archive> is the user that owns the archive,
F</usr/sbin/tcpd> is the path to tcpd(8), I<pathbin>/tinyleaf is
the path to this program, I<pathspool>/tinyleaf is some scratch directory
that the user C<archive> has write access to, and
I<pathbin>/archive is the path to your B<archive> script.

You can now restrict access to B<tinyleaf> to just your local news server
with C</etc/hosts.allow> and C</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 B<tinyleaf> doesn't.

This is the application that motivated the original development of this
program.

=head1 BUGS

The timeout and maximum message size should really be configurable.
B<tinyleaf> should also probably not just respond 500 to every command
other than HELP, IHAVE, and QUIT; there are more useful (and more
expected) error codes that could be returned.

An option to scan the spool directory for any left-over files and pass
them to the processor when starting up would be useful.

=head1 HISTORY

Written by Russ Allbery <eagle@eyrie.org> for InterNetNews.

=head1 SEE ALSO

hosts_access(5), inetd(8), tcpd(8).

=cut
