[1] Having asked this question directly to DJB in person, I can say that I am at least convinced he wrote this stuff in C.
[1] Having asked this question directly to DJB in person, I can say that I am at least convinced he wrote this stuff in C.
But really that's just the way he codes. It's very intricate. It's like a very ugly Swiss watch.
I haven't read the qmail source (just some design docs about how the whole system fits together, which I found rather impressive), so I'm not talking specifically about that.
NB: Qmail's license wasn't public domain until 2007. (Also, damn, tptacek, you're fast! I deleted that part, since I'm talking about auto-generated code in general.)
(I'm in 100% full-on maximum overdrive procrastination mode today, since what I need to get done is to script and record a screencast of my app, and I'm frozen up about where to start with it. Sorry for being so fast to respond).
But that has nothing to do with the code, which is not only epsilon from assembly (Bernstein fully embraces the notion of writing code in high-level assembly), but also clever and concise almost to a fault.
As someone who ran qmail since it was originally released in beta, I also remember vividly Bernstein's original idea about configuration, which is that "configuring" your mail server with C code was more reasonable than learning another programming language (Sendmail "cf"). Which implies that a lot of the code in the interesting parts of qmail are less about design, and more about encoding mail routing policy as C code.
- Split the system into small components that do one thing and do them well. - Give each part of the system the minimal set of privileges needed (if necessary by running as different users and set filesystem privileges accordingly). I.e. qmail has separate binaries for inbound smtp, pop3, managing the queue, local delivery, remote delivery and more. - Make each part of the system communicate only via well defined interfaces (using pipes in qmail) where it is explicitly assumed that you can't really trust the sender. - Don't ever use library functions that don't length check things. Then again he uses his own stdio replacement, and his own string functions.