Search for Simplicity

Even before starting to self-host services, I had begun to develop an allergy to complexity.

In the world of instant text-based communication, there is no shortage of choice. Anything “modern” starts to look like a Slack clone (e.g. Mattermost, Riot, and Rocket, and for the less frivolous, you’re probably looking at IRC. I haven’t found IRC wanting as a user, but the when I got started with the UnrealIRCd install guide, I hit a bit of a snag.

Walk through the unrealircd.conf block by block / line by line and edit the settings to suit your needs. This takes 10 - 20 minutes.

Were I interested in hosting a larger service or specifically how to operate IRC servers, this would be no problem. However, I have little desire to read and understand several hundred lines of configuration when my goal is just to send text to one or two people. There has to be an easier way.

Inspiration

I’m a regular reader of Drew DeVault’s blog, and sourcehut was a big inspiration for the hacker ethic I aspire to. In particular this post demonstrates the relative ease of giving other users restricted SSH access to your server.

SSH is an essential part of a Linux server, so the basics of managing sshd is hardly any extra operational burden.

Implementation

The result is a ~500 line C program that serves as the entrypoint for the user’s SSH session. It runs two operations in a poll() loop:

  1. capture input and writes to a file
  2. watch for changes to the file and print them

I had never worked with the poll or inotify APIs before as I’ve still written far more not-C code than I have C, so it was fun to get some experience with those essentials.

I also found these two resources12 super helpful for learning the escape codes and working with <termios.h>.

image3