tinyleaf - Very simple IHAVE-only NNTP server
tinyleaf spool [processor]
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 spool and, if processor is given, passes information about the article to 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, tinyleaf will refuse the article, reporting it as a duplicate. If processor is given, it should specify the path to a program. That program is started when tinyleaf starts, and its current working directory will be spool. For each article received by tinyleaf, 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 tinyleaf shuts down, standard input to processor will be closed. tinyleaf 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. 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 tinyleaf via tcpd(8) from TCP wrappers and use /etc/hosts.allow and /etc/hosts.deny to restrict who can talk to the server.) tinyleaf has a (currently hard-coded) maximum message size of 1 MB and a (similarly hard-coded) timeout of ten minutes for each command or chunk of article data.
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 -- 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), pathbin/tinyleaf is the path to this program, pathspool/tinyleaf is some scratch directory that the user "archive" has write access to, and pathbin/archive is the path to your archive script. You can now restrict access to tinyleaf 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 tinyleaf doesn't. This is the application that motivated the original development of this program.
The timeout and maximum message size should really be configurable. 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.
Written by Russ Allbery <eagle@eyrie.org> for InterNetNews. $Id: tinyleaf.pod 9767 2014-12-07 21:13:43Z iulius $
hosts_access(5), inetd(8), tcpd(8).
Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.
Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.
Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.
Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.
The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.
Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.
Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.
Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.