pastie - a simple web site for pasting Written in 2019 by Greg Wooledge To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see . ======================================================================= This is a simple web-based paste site, in the style of termbin.com. Users are expected to submit small textual snippets of information from a Unix (Linux, BSD, etc.) shell, for other users to read. These snippets are stored for one week, and are available for everyone to read during that time. There are a lot of web-based paste sites, and many of them are excellent. So, why add another? Some of the paste sites have issues: * Some of them mangle input (whitespace conversions, etc.). * Some of them require Javascript for the retrieval. * Some of them only offer HTML retrieval, with no option for raw output. * Some of them require a login to retrieve raw output. * Some of them use advertisements. * Some of them have already been blocked by workplace firewalls, etc. The goals of this service are to preserve the user's input exactly, and to return it upon request without any modifications, from any web user agent, without Javascript, advertisements, or logins. I cannot do anything about firewalls which block this service, so there are no guarantees that it will remain accessible from every network indefinitely. ======================================================================= Implementation choices: This implementation uses an SQLite3 database to hold the submitted information, and an SCGI web service script to retrieve them upon request by a web server. There are three programs which access this database: one to add new pastes, one to retrieve them, and one to remove expired submissions. Submission is done via a direct TCP socket (a la termbin.com), rather than a web interface. This presents the challenge of determining when the submission is complete, as there is no structure or format to the input. This implementation waits for a specific interval of time to pass without any new input being received, signalling the end of input. At this time, that interval is 250 milliseconds; if that's judged to be too short, it may be lengthened in the future. ======================================================================= Installation details: I created two user accounts, "pastiew" and "pastier". The pastiew account owns the SQLite3 database file and the directory where it sits, and has read and write permission on the file and directory. The pastier account is used for retrieval, and does not have write permission on the file or the directory. Obviously, it needs read permission. There are two daemontools services, one cron job, and one web server virtual host configuration file. The "pastie-write" service uses tcpserver (from http://cr.yp.to/ucspi-tcp.html) to listen on a TCP socket, and runs the "pastie-write" script for each new connection. The expectation is that the number of submissions will be smaller than the number of retrievals, and small enough that forking a new Tcl script for each submission will not be a problem. The "pastie-read" service runs the "pastie-read" script, which does its own socket listening for SCGI requests from the web server. There is no forking of new processes for handling requests. The "pastie-clean" script is run by cron, as user pastiew, as often as one wishes to see old submissions removed. I'm running it twice a day. The web server configuration under nginx looks like this: server { listen 80; listen 443 ssl; server_name paste.wooledge.org; location / { scgi_pass localhost:9997; include scgi_params; } } There are a few entries after that for favicon, robots.txt and so on, but this is the essential part.