Michael W Lucas - Absolute OpenBSD
2003, No Starch Press | 1-886411-99-9
This time (especially since this book is a big one) I’m going to take notes here as I go rather than write them up when I’m done reading. (I’ve just started though so not much to see here yet!)
Opening rant
I had a rant here about the silly noob-shaming tone in this book, but I’ve since chilled out about it. With the benifet of distance from some toxic former coworkers, I’ve managed to find the humor in all this again.
Ok! Lucas is a great (and funny) writer and each section of the book I’ve read so far is brimming with practical information, historical context and an inspiring thoroughness.
Paritioning for installation
The book goes into enough detail about the why of the OpenBSD partitioning philosophy that I feel better equipped to make a decision about the partitioning scheme I’ll use on my laptop. There is some interesting reasoning behind the partitioning that extends beyond security considerations. From the security standpoint, it makes sense that you might not want to allow files (which could be malicious programs) to have setuid or setgid capabilities allowing them to run as other users, like root. It’s a kind of sandboxing for a partition which might store untrusted files like ones downloaded from the internet. I’m not really a security nut despite my interest in OpenBSD (which is driven primarily by UNIX-curiosity and a desire for simple human-audited tools wherever possible) but keeping a sandboxed partition for untrusted files actually makes a lot of sense.
Another reason behind the default partition scheme is to put certain parts of the system on faster parts of the disk – something I never even think about anymore since all of my machines boot from an SSD, but if you’re installing OpenBSD onto a disk with a spinning platter in the 90s, I guess the speed variance between different physical sections of the disk could be enough to make it worthwhile to put your root and swap partitions first on the disk. I’m not totally sure, but I think that must mean those disks were putting their initial sectors at the outer edge and working inward, and the speed gain would be from the advantage of having more bits per track on the outer rings, so you might not need to do as much track switching when reading from the disk? (Oh well yes, Lucas actually addresses this directly in the discussion of swap: outer rings are faster, I guess because of the latency of switching tracks but that isn’t explicitly mentioned.)
Anyway! It’s not a concern (for me) anymore, and neither is having to worry about supporting machines with a BIOS that can only read the first ~512MB of the disk.
Another rationale for partitioning that’s mentioned is to keep your
partition with /var or wherever you put logs at some
reasonable size to give it a hard cap preventing it from filling up the
entire disk and making it difficult to then actually use the system to
recover the system. I’ve actually seen this happen a few times on work
systems unfortunately, but even on my personal laptop I like the idea of
having a log partition with a hard cap to prevent runaway log bloat
taking down the system.
I’m sort of leaning toward having on big combined root + everything partition, plus capped partitions for untrusted files and another for logs and another for swap. So maybe just four partitions on my laptop? For the VPS proxy, I’ve already got the default partition scheme in place because the hosting provider set the image up like that, and I don’t see any reason to want to change it. On that (virtual) machine all the non-system files (like my website and all the luvsound releases etc) are already mounted on a (virtual) external drive.
Treating /home and /tmp as basically the
same would be interesting too. If /usr/local is used mostly
for scripts and local programs then /home could just be
file storage (as maybe it should be) and lumping it with
/tmp on the largest partition would let me keep putting
files in haphazard places as I tend to do. The only major change for me
would be getting into the habit of always compiling builds into
/usr/local and keeping other programs in /usr
too.
No notes on the intermediate chapters, forgot to take any! I don’t remember encountering anything terribly remarkable: more installation scenarios and a discussion of the rc init system. The section on serial consoles is another fun blast from the past (including a lament that it’s getting harder to find a laptop with an exposed serial port) but also has some good (still relevent) tips that I’d like to explore eventually to set up remote management on the physical machine(s) I’m setting up at the maker space here.
Managing Users
Running useradd for the first time on OpenBSD was a bit
surprising, and I was presented with the option to select a default
“login class” whose default was set to the default user
class to further confuse me.
I thought I’d found a difference from BSD circa 2003 versus today! Login classes must be new! Sure enough there’s a mention in the OpenBSD handbook.
But, I just needed to read on – it’s (of course) covered in good
detail as well later on. The default user class is named
that way since it’s meant to be configured to let you set the
capabilities of whatever the most typical kind of user might be on the
system – calling it default makes sense. There are also
staff and daemon classes defined by default in
/etc/login.conf among others.
I’m sticking with the defaults provided in
/etc/login.conf for now. The staff and
daemon classes probably cover all my needs for the moment:
the former for my personal non-root management account, and the latter
for accounts created to be used by services and tunnels. (I’m planning
to keep the services running on this instance to a minimum and tunnel
out to other machines for everything else.)
This machine won’t have a lot users, probably, because I’d like to keep the number of tunnels and services running to the bare minimum, and I’ll be the only one administering it for the forseeable future.
The useradd script seems to have some noticable little quality of
life differences from the ones I’m familar with bundled on debian and
arch systems, including creating an empty
.ssh/authorized_keys file on creation, which makes
populating keys very convenient. It also supports being run from scripts
in a batch mode. I suppose these are completely different
implementations, but a comparative glance between linux and bsd man
pages does show a lot of overlap. I’m a bit curious to dig into the
history of the development and divergence of these scripts at some
point.
Interestingly the book states that running cap_mkdb
isn’t needed in OpenBSD unless it’s been used once – then it needs to be
used going forward – but the OpenBSD handbook doesn’t mention this.
sudo -> doas
OK, here is a legit major difference between OpenBSD circa 2003
(~v3.3?) and now: doas! The man pages say this replaced
sudo in OpenBSD in version 5.8 which came out in September
of 2016. (Wow, as the world began to burn we quietly got
doas.)
The book covers user management and security with sudo,
since doas wouldn’t exist for another 13 years, but even
here all the principles discussed with sudo seem to hold
for doas.
I have a guess as to why it got replaced: the refrain in this section
is that sudo configuration is complex. We all know
complexity is a synonym for attack surface! I have barely spent any time
with the doas manual but the configuration syntax is very
OpenBSD-style: simple and it even reads almost like an english sentence
when it gets complex.
One of my favorite MWL jokes is in his httpd/relayd mastery book. To
paraphrase: if you need more features in your web server, choose a less
secure web server. He goes on to describe how httpd will never implement
regex routing as an example of this choice. I wouldn’t be surprised if
doas is similar: basically all the features you want, but
far simpler to configure.