Posts Tagged ‘web server’

osws, the one-shot web server

Monday, March 2nd, 2009

Something I had on my mind for a while and now got around to while I was setting up a new system – a way of serving a file over HTTP without having to set up a proper server, with some nicer traits than a straight `netcat -lc -p 8080 < file` does. This is the one-shot web server: run osws file.tar.bz2 and it immediately starts a server on port 8080 (by default, can be changed) that will redirect a request for / to /file.tar.bz2 (so it saves with the right name from wget, or shows up nicely elsewhere) and will serve out the content of the file for any other request, then terminate.

That means wget will save file.tar.bz2 on the remote client. Accessing from a web browser or other tools will work as well. osws can also serve on port 80, either when run as root or by using its fwd_osws tool, which is intended to be installed setuid and forwards the port locally to the real server. More details are in the README file; osws depends on netcat and the usual array of standard utilities, and a C compiler with root access for fwd_osws.

osws 0.1 tarball

make && make install will install to ~/.local by default; specify PREFIX to change that. make install-setuid will build and install osws-fwd: that needs to be runĀ  as root to make it setuid. That part is optional, the only missing feature will be the use of ports below 1024.