test / test (push) Canceled after 0s
All 2026-10-15; each written beside the code or text it settles. - A-43: /usr/sbin/postlog is -rwxr-xr-x root:root in the image (postfix 3.7.11-0+deb12u1; dpkg-statoverride lists postdrop and postqueue only): Debian does not install it set-gid, so it is no use to dmarc-ingest (cmd/panel/dmarc_ingest.go). - C-X1: OpenSSL 3.0.22 in the image prints the same public key from `x509 -pubkey` and `pkey -pubout` for RSA-2048, P-256, P-384 and a SEC1 P-256 key - cert-reload's same_pair holds for certbot's ECDSA keys. - C-K5, D-guide:933/:233: on the live server (Docker 29.6.1, userland proxy on 0.0.0.0 and ::, no IPv6 on the network) an outside IPv4 client and the host's own public IPv4 address are logged as themselves; the host's IPv6 address and 127.0.0.1 arrive as 172.18.0.1. Over IPv6 every client is the gateway: one level-1 budget, an application IP list cannot name them, rspamd sees the gateway. Guide paragraph under level 1, notes at the milter and allow-list, comments at the anvil setup and authip.go, and a Security entry in the CHANGELOG (an allow-list naming the gateway would admit every IPv6 client). - D-guide:61: a published port nothing listens on (a throwaway container, -p 20999:25) is refused from outside over IPv4 and from the host's public IPv4, accepted and closed through 127.0.0.1 - Docker's proxy, which IPv6 goes through too (not probed over IPv6 for this). - C-M8: the live installation has received one DMARC report, of one record: nothing to set maxReportRecords by yet - said at the constant. - D-S7, D-arch:516, D-arch:532: a new database filled through the store to 120 days at 1 900 messages a day (228 000 messages, 1.37 million lines, 464 MB) on the test server (2 cores): the longest write is the line prune after a 30-day gap, 1.9 s for 342 000 lines (0.4 s with nothing to delete); the send-log delete 0.6 s; 2 000 lines of a tailer pass 18 ms; VACUUM INTO 1.7 s; a second connection writing every 50 ms waited 1.8 s at most, no SQLITE_BUSY - inside busy_timeout's 5 s. architecture.md's "about a second per million lines" was five times too fast; its "six to ten lines of 200 bytes" is 6.0 lines of 146 bytes on the live data. - D-B16: which favicon is fetched, by the probe server's log: Edge 155 the SVG, the desktop app's embedded Chromium 152 the PNG, with or without sizes="any" - layout.html's "vector wins where supported, raster catches the rest" holds; Firefox and Safari not measured. - D-arch:121: the allow/deny trial again, in rspamd/rspamd:3.11.1-3 with today's multimap.conf: every mix of allow and deny entries matching one message ended reject; a changed map was used about 10 s later. - D-sec:424: rspamd runs as _rspamd, uid 11333; the panel is uid 999. Stand: go vet and go test ./... pass on the server (24 packages); make e2e exit 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95 lines
3.8 KiB
Bash
95 lines
3.8 KiB
Bash
#!/bin/sh
|
|
# Picks up a renewed TLS certificate while the container runs (spec 5.2 p.4;
|
|
# audit 2026-10-12, H2).
|
|
#
|
|
# Postfix does not read the mounted files: postfix-config.sh copies them at
|
|
# start into /etc/postfix/tls-internal, because Postfix wants the key owned by
|
|
# root with mode 0600, which a read-only bind mount owned by the host's user
|
|
# cannot give. A renewal of the mounted files therefore reaches Postfix only
|
|
# through a new copy. Every interval this compares the mounted files with the
|
|
# copy; when they differ it copies both beside their targets, checks that the
|
|
# copies - not the mounted files, which a renewer may be rewriting - are a
|
|
# certificate and the key that belongs to it, renames both over the targets
|
|
# and reloads Postfix. When nothing changed it does nothing.
|
|
# (Postfix 3.7.11: smtpd loads the certificate in pre_jail_init(), once per
|
|
# process, src/smtpd/smtpd.c; "postfix reload" is SIGHUP to master,
|
|
# conf/postfix-script, after which the old smtpd processes exit on the closed
|
|
# status pipe, src/master/master_conf.c, master_config() ->
|
|
# master_restart_service(), and new ones load the files again.)
|
|
#
|
|
# Runs under supervisord as root. It sleeps first: at container start the
|
|
# wrapper is still bringing Postfix up. It never exits non-zero, so a failure
|
|
# does not trip the crashexit listener; it is logged and tried again.
|
|
set -u
|
|
umask 077 # the key's copy is never readable by others, not even for an instant
|
|
|
|
INTERVAL="${TLS_RELOAD_INTERVAL_SECONDS:-86400}"
|
|
SRC_CERT="${TLS_CERT_FILE:-/etc/postfix/tls/fullchain.pem}"
|
|
SRC_KEY="${TLS_KEY_FILE:-/etc/postfix/tls/privkey.pem}"
|
|
DIR=/etc/postfix/tls-internal
|
|
CERT="$DIR/fullchain.pem"
|
|
KEY="$DIR/privkey.pem"
|
|
PENDING=0 # a copy was renewed and Postfix has not been reloaded since
|
|
|
|
reload() {
|
|
if postfix reload; then
|
|
echo "cert-reload: postfix reloaded ($1)"
|
|
PENDING=0
|
|
else
|
|
echo "cert-reload: postfix reload failed, will try again after ${INTERVAL}s" >&2
|
|
fi
|
|
}
|
|
|
|
# same_pair says whether a certificate file and a private key file belong
|
|
# together, by comparing the public key each one prints. openssl-x509(1) and
|
|
# openssl-pkey(1) do not say the two print it byte for byte alike; measured
|
|
# in the image, 2026-10-15, OpenSSL 3.0.22: identical for RSA-2048, P-256 and
|
|
# P-384 keys, and for a P-256 key written in SEC1 form ("EC PRIVATE KEY") -
|
|
# certbot 2.0 and later issue ECDSA keys by default (assumptions C-X1).
|
|
same_pair() {
|
|
cert_pub=$(openssl x509 -noout -pubkey -in "$1" 2>/dev/null) || return 1
|
|
key_pub=$(openssl pkey -pubout -in "$2" 2>/dev/null) || return 1
|
|
[ -n "$cert_pub" ] && [ "$cert_pub" = "$key_pub" ]
|
|
}
|
|
|
|
refresh() {
|
|
if [ "$PENDING" = 1 ]; then
|
|
reload "renewed certificate, earlier reload had failed"
|
|
fi
|
|
if [ "$(postconf -h smtpd_tls_cert_file 2>/dev/null)" != "$CERT" ]; then
|
|
# Postfix reads the mounted files themselves (they were missing at
|
|
# start, so no copy was made): a reload is what picks up a change.
|
|
reload "periodic TLS refresh"
|
|
return
|
|
fi
|
|
if [ ! -r "$SRC_CERT" ] || [ ! -r "$SRC_KEY" ]; then
|
|
echo "cert-reload: cannot read ${SRC_CERT} or ${SRC_KEY}; Postfix keeps the certificate it has" >&2
|
|
return
|
|
fi
|
|
if cmp -s "$SRC_CERT" "$CERT" && cmp -s "$SRC_KEY" "$KEY"; then
|
|
return
|
|
fi
|
|
rm -f "$CERT.new" "$KEY.new"
|
|
if ! cp "$SRC_CERT" "$CERT.new" || ! cp "$SRC_KEY" "$KEY.new"; then
|
|
rm -f "$CERT.new" "$KEY.new"
|
|
echo "cert-reload: copying the renewed certificate failed, will try again after ${INTERVAL}s" >&2
|
|
return
|
|
fi
|
|
if ! same_pair "$CERT.new" "$KEY.new"; then
|
|
rm -f "$CERT.new" "$KEY.new"
|
|
echo "cert-reload: the mounted certificate and key differ from Postfix's copy but do not belong together; will look again after ${INTERVAL}s" >&2
|
|
return
|
|
fi
|
|
chown root:root "$CERT.new" "$KEY.new"
|
|
chmod 0644 "$CERT.new"
|
|
chmod 0600 "$KEY.new"
|
|
mv -f "$KEY.new" "$KEY" && mv -f "$CERT.new" "$CERT"
|
|
PENDING=1
|
|
reload "renewed certificate"
|
|
}
|
|
|
|
while true; do
|
|
sleep "${INTERVAL}"
|
|
refresh
|
|
done
|