Some time back Toby Kurien published details and code about his favourite setup regarding self hosting services at home. He did put in quite some effort to make this simple to install and run. I quite like this setup and I have written a minimal finger daemon to run in this setup.
gemini://tobykurien.com/articles/2022-10-08-simpler-linux-selfhosting.gmi
The source of bws (bubblewrapped services) is available at
https://cloud.tobykurien.com/cgi-bin/repo/bws/
including installation instructions.
Finger is one of the oldest toys found on what evolved into the so called internet. It does have a specification, and it was created in times, when the network participants were mostly friendly. But times have changed, a standard finger installation could rightly be called a data leak daemon.
https://datatracker.ietf.org/doc/html/rfc1288
I looked around to see, what implementations were available. Most of them need inetd to start finger in order to answer a request. I did not like this, I wanted to have the finger daemon run standalone. Additionally, finger is using port 79, which is not usable for a daemon not running or starting with root priviledges. The following features or requirements are on my list:
Quite certainly such a thing exists already, however, I couldn't find it. So I set out to write my own implementation in C, recycling code from example echo server implementations:
https://mohsensy.github.io/programming/2019/09/25/echo-server-and-client-using-sockets-in-c.html
https://github.com/mafintosh/echo-servers.c/blob/master/tcp-echo-server.c
My code can be found at
https://git.sr.ht/~ew/nanofingerd
The C source comes in at a whopping 154 lines of code, a Makefile for compilation is provided. I have attempted to ignore input or .plan files too big to fit into the given buffer. Upon a readable request, the server just serves the content of the .plan file, nothing else.
So, how to integrate this thing into the bubblewrapped services mentioned abobe?
In the ~/services directory we add a new directory named nanofingerd. It basically holds 3 files:
--ro-bind $HOME/public/finger/plan $HOME/.plan
#!/bin/sh OS="$(uname -s)" PLATFORM="$(uname -m)" BIN="unknown" if test "$OS" = "Linux"; then BIN="linux-$PLATFORM" elif test "$OS" = "Darwin"; then BIN="macos-$PLATFORM" fi ./bin/$BIN/nanofingerd 10079
Have the appropriate amount of fun!