OpenIMAPD: credits and lineage

Each file under src/ carries its copyright lines and the ISC licence text.
Where a file carries a copyright other than David Williams', the notes
below say what was borrowed from whom and why that copyright is carried.
They were the files' header comments until 2026-10-05, and are kept here
so the headers can take the form the rest of the tree uses; the
attribution they record is unchanged.

log.c
-----
This file's log_init()/log_procinit()/log_setverbose()/log_getverbose()/
vlog()/logit()/log_warn()/log_warnx()/log_info()/log_debug()/fatal()/
fatalx() API is the same daemon-logging idiom Henning Brauer wrote and
that is carried, nearly verbatim, across essentially every privsep
daemon in the OpenBSD base system (smtpd, bgpd, and many others all
credit him in their own log.c). This file's implementation details
(log_procname storage, log_init()'s parameters) are this project's own,
but the API shape and name are that same shared idiom, so his copyright
is carried forward here too, same rationale as parse.y's copyright
chain.

log.h
-----
The declarations here, log_init(), log_procinit(), log_setverbose(),
log_getverbose(), log_warn(), log_warnx(), log_info(), log_debug(),
logit(), vlog(), fatal() and fatalx(), have the names, argument types
and return types of those in smtpd's log.h (usr.sbin/smtpd/log.h:26-55).
That is the daemon-logging idiom Henning Brauer wrote and that smtpd,
bgpd and most other privsep daemons in the OpenBSD base system carry
his copyright for. smtpd's _r variants are not declared here. His
copyright is carried forward for the same reason as log.c's.

imsgev.c
--------
This file's name and its "struct imsgev" wrapper-around-imsgbuf+
event(3) concept match Eric Faurot's imsgev.c in OpenBSD's ldapd
(usr.sbin/ldapd/imsgev.c), not a generic/obvious name, so his copyright
is carried forward here even though this file's actual function
signatures and dispatch design (a caller-supplied raw libevent handler,
vs. ldapd's callback+needfd model) were written independently and differ
from his implementation.

imsgev_add() below is the exception: it is a verbatim copy (up to
whitespace and the choice of iev vs. iev->data as event_set()'s last
argument) of the imsg_event_add() idiom shared across OpenBSD privsep
daemons, traceable to usr.sbin/ospfd/ospfd.c:525-534 (Claudio Jeker
2005, Esben Norby 2004, Henning Brauer 2003-2004) and copied with only
that one-argument variation into dvmrpd.c, npppd.c, and rad.c. Their
copyright is carried forward for that function specifically, same
rationale as log.c's and parse.y's shared-idiom copyright chains.

parent.c
--------
This file's boot-time peer-wiring handshake, setup_peer_send() and
setup_done_send(), and the IMSG_SETUP_PEER/IMSG_SETUP_DONE message names
they and imapd.h use, follows smtpd's setup_peers()/ setup_done()
(usr.sbin/smtpd/smtpd.c:861-903) and its identically-named
IMSG_SETUP_PEER/IMSG_SETUP_DONE enumerators (smtpd.h:212-213), which no
other daemon in the OpenBSD base system defines under those names. The
functions here are reworked onto imapd's own struct imsgev and multi-
child bookkeeping rather than copied verbatim, but the message protocol
and handshake shape are smtpd's; see the inline citations at this file's
setup_peer_send() and setup_done_send().

send_keymgr_init()'s TLS key permission check, fstat(2), then st_uid
!= 0 and st_mode & (S_IRWXU|S_IRWXG|S_IRWXO) & ~0740, reuses smtpd's
ssl_load_key() check (usr.sbin/smtpd/ssl.c:132-145) verbatim for that
mask and rejection order; only the fixed 0740 bound and the imsg
delivery around it are this file's own.

listener.c
----------
The RSA_METHOD/EC_KEY_METHOD engine override below (keymgr_engine_
init() and everything it installs) adapts smtpd's ca.c
(rsa_engine_init()/ecdsa_engine_init()/rsae_priv_enc()/rsae_priv_
dec()/ecdsae_do_sign(), ca.c:329-508) to imapd's own imsg conventions:
the OpenSSL API shape leaves little room for independent structure, and
this project's own licensing precedent (log.c, imsgev.c) already treats
a borrow this close as needing the original author's copyright even
where the implementation differs. keymgr_use_fake_private_key()'s two-
line call shape is lifted from smtpd's smtp.c:187-194 (Gilles Chehade,
Pierre-Yves Ritschard, Jacek Masiulaniec); see that function's own
comment.

keymgr.c
--------
This file's overall architecture, a dedicated process holding the real
TLS private key, a "fake private key" installed in the TLS-terminating
process instead, and a process-wide OpenSSL RSA_METHOD/EC_KEY_METHOD
engine override that forwards every private-key operation here as a
synchronous imsg round-trip, is smtpd's ca.c (Reyk Floeter, Gilles
Chehade), ported to imapd's own imsg/privsep conventions rather than
copied verbatim. The RSA_METHOD/ EC_KEY_METHOD engine-override code
itself (the code this file's request/reply pair answers) lives in
listener.c, not here; see the listener.c entry above for the matching
attribution.

keymgr_pubkey_hash() below additionally replicates, byte-for-byte,
smtpd's ssl.c hash_x509()/ssl_pubkey_hash() algorithm (Pierre-Yves
Ritschard, Reyk Floeter, Gilles Chehade): SHA256 of the certificate's
DER-encoded SubjectPublicKeyInfo, formatted "SHA256:" plus lowercase
hex. That exact format is what libtls's own (unexported)
tls_cert_pubkey_hash() tags onto the fake key's OpenSSL ex_data slot 0
at TLS-config time (lib/libtls/tls.c); this process's key lookup only
works if it derives the identical string from the same certificate.

parse.y
-------
The parser skeleton below (lgetc()/lungetc()/findeol(), the hand-
written yylex() built on top of them, pushfile()/popfile(), and
symset()/symget()) follows the structure common to ripd's, smtpd's, and
httpd's own parse.y in the OpenBSD base system, all of which carry this
same four-name copyright chain at their root. This file's grammar and
domain-specific rules are original; the above four names are carried
forward for the shared parser-skeleton lineage only.

mbox_manage.c
-------------
Carries Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> in its
header.
