doas insults

I moved to OpenBSD full time on my desktop and laptop a couple of months ago, having previously used it on servers (this website is hosted on OpenBSD.amsterdam). One of the biggest adaptations I had to make was retraining muscle memory to type doas instead of sudo. It didn’t take long to get the point where I now have opendoas installed on most of my linux machines (or at least alias doas=sudo).

There’s no question that doas does exactly what I need from a sudo replacement with simpler configuration, but there is one feature of sudo that I’ve found myself missing:

Insults. sudo has a marvelous feature where, if enabled, it insults you upon getting your password incorrect or authorization failing for some other reason. doas in its effort to be a sudo replacement without all the bloat, neglects to implement this. Fortunately, it’s easy enough to work around.

Obtaining the insults

We could probably use sudo’s insults, but why not use something a little more OpenBSD-esque as well as extending fortune’s repertoire while we’re at it? Namely, insults straight from the mouth/keyboard of Theo de Raadt.

The first thing we’ll need to do is build strfile, it’s source code is included in OpenBSD but it isn’t usually installed. If you have OpenBSD src tree downloaded somewhere, then strfile can be found under games/fortune/strfile.

$ pwd
/usr/src/games/fortune/strfile
$ make
$ ls -F
CVS/       strfile*   strfile.c  strfile.h
Makefile   strfile.8  strfile.d  strfile.o

9front is a continuation of Plan 9, and includes in its base system a program by the name of theo which prints out insults by Theo de Raadt when run. The following commands download and convert the list of insults into a format OpenBSD’s fortune can use:

$ ftp -o - \
    https://code.9front.org/hg/plan9front/raw-file/00bf6c34e13e/lib/theo |
    awk '{ print $0; print ".%" }' |
    fmt | 
    sed -e 's/^\.%/%/' > theo

$ strfile theo theo.dat
$ doas cp theo{,.dat} /usr/share/games/fortune/
$ doas chmod -w /usr/share/games/fortune/theo{,.dat}
$ doas chgrp bin /usr/share/games/fortune/theo{,.dat}

Try it out:

$ fortune theo
You are quite a persistant idiot.

Enabling insults

Now enabling insults is as simple as adding the following to ~/.kshrc and making sure that persist is enabled in doas.conf:

# ~/.kshrc
alias theo='fortune theo' # optional

doas() {
    # This requires persist to be enabled in doas.conf
    if ! /usr/bin/doas true; then
        fortune theo; false
    else
        /usr/bin/doas "$@"
    fi
}

© 2019 Joe Davis.  Creative Commons License