💾 Archived View for ew.srht.site › en › 2023 › 20230114-bws-finger.gmi captured on 2023-05-24 at 17:47:49. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

➡️ Next capture (2024-06-16)

-=-=-=-=-=-=-

2023-01-14

Adding a minimal fingerd to bubblewrapped services (bws)

tags: software

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

local copy

The source of bws (bubblewrapped services) is available at

https://cloud.tobykurien.com/cgi-bin/repo/bws/

including installation instructions.

nanofingerd

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.

Adding finger as a service

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!

Home