test / test (push) Canceled after 0s
Technical review (Opus, 11 findings, 2 medium) and security review (Fable, no high or medium) of 3c86280..HEAD. Both confirm the port gives dkim_mail_parse()'s result on every input it parses, and that no line the check passes is signed with another domain's key. - F1 (medium): OpenDKIM's parser takes lines no mail program reads as one address - "ceo@bank.com:me@mine.com", "Name <ceo@bank.com:me@mine.com>", "<b@evil.com, a@mine.com>", "ceo@bank.com <me@mine.com>", "ceo@bank.com@mine.com" - and signs for the last while a lenient reader shows the first. The line must now also be one address in RFC 5322's grammar (net/mail, display names in any charset passed through), at the domain OpenDKIM signs for. A quoted display name may still hold anything. - F2 (medium): the bindings were asked about OpenDKIM's form of the address, quotes and all, so "x"@mine.com passed for an application holding @mine.com while x@mine.com belonged to another. They are now asked about the reader's address, its local part unquoted, as Postfix holds the envelope's. - F3 / security (low): Bindings.Allowed and DomainOf fold case in ASCII only: Postfix folds as Unicode (casefold.c, ICU), but every key and login the panel writes is ASCII, and the Unicode fold let the Kelvin sign pass for "k" (net/mail then refuses such a line on the domain test). - F4 (low): a TERM between "postfix start-fg &" and "child=$!" is no longer lost: the wrapper stops Postfix as soon as the pid is known. - F5 (low): for startsecs after a start any failed reload passed as "not running". postfix-reload is now build/postfix-reload.sh: exit 75 when master -t says no master runs, else exec postfix reload; RunOnce returns EndError with the status, and only 75 is taken as done. supervisor.State goes. - F6 (low): crashexit spares postfix-reload too - a reload that could not be spawned is reported to whoever asked, not a reason to stop the container. - F7 (low): a certs/ that is itself a link is resolved before the walk (filepath.WalkDir does not follow its root). - F8 (low): at shutdown the tailer reads what is left of the rotated file before saving its place. Not changed: a refusal line still waiting on the old file at shutdown is not kept - the panel writes refused rows itself, only a kill loses one, and that window is the minute's grace. - F9 (low): pct read as text - empty or unreadable is 100, the rest held to 0..100. - F10 (low): the directory is synced after sasldb2's rename. - F11 (low): POSTFIX_STARTSECS by expr, so "010" or "08" in MILTER_WAIT_TIMEOUT are decimal, not octal or an error. - Security (low): pagehide also empties defaultValue - the input's value attribute and the textarea's text - not only .value. A sasldb2.new left by a killed panel is removed at start (entrypoint) and never archived. security.md says that links under certs/ are followed and by whom they can be placed. Tests: sender check cases for F1 (four lines), F2 (a bound address quoted, for its owner and for another), F3; EndError's state and status; pct cases. architecture.md and CHANGELOG describe the reader rule. Stand (2026-10-15, make e2e, exit 0); go vet and go test ./... pass on the server (24 packages). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
2.8 KiB
Python
75 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Supervisor event listener: bring the container down on unrecoverable failure.
|
|
|
|
If a managed program of the mail path exhausts its restart retries and
|
|
enters FATAL, this listener signals supervisord (its parent) to terminate, so
|
|
the whole container exits and Docker's `restart` policy starts it again —
|
|
rather than lingering "alive" with a dead Postfix/OpenDKIM/panel. logrotate is
|
|
not on the mail path: its FATAL (a config it would ignore) stays on
|
|
Server > Health, and mail keeps flowing (assumptions C-V5).
|
|
|
|
Communication with supervisord uses the event listener protocol over stdin and
|
|
stdout, so stdout must carry only protocol tokens.
|
|
|
|
supervisor 4.2.5, docs/events.rst, "Event Listener Notification Protocol": the
|
|
listener writes READY\\n, reads one header line of key:value tokens whose len
|
|
is the payload's length, reads the payload, and answers "RESULT 2\\nOK".
|
|
A PROCESS_STATE_FATAL payload is a token set, "processname:cat groupname:cat
|
|
from_state:BACKOFF" (docs/events.rst; supervisor/events.py,
|
|
ProcessStateEvent.payload()).
|
|
supervisord starts the listener as its own child, and on SIGTERM it shuts down
|
|
(docs/running.rst, "Signals"); it is PID 1 here (build/entrypoint.sh, exec).
|
|
"""
|
|
import os
|
|
import signal
|
|
import sys
|
|
|
|
# Programs whose FATAL does not take the container down (build/supervisord.conf):
|
|
# logrotate is not on the mail path, and postfix-reload runs on demand - a
|
|
# reload it could not start is reported to whoever asked for it.
|
|
SPARED = {"logrotate", "postfix-reload"}
|
|
|
|
|
|
def write_stdout(s):
|
|
sys.stdout.write(s)
|
|
sys.stdout.flush()
|
|
|
|
|
|
def main():
|
|
while True:
|
|
# Tell supervisord we are ready for the next event.
|
|
write_stdout("READY\n")
|
|
|
|
line = sys.stdin.readline()
|
|
if not line:
|
|
return
|
|
headers = dict(pair.split(":", 1) for pair in line.split())
|
|
payload_len = int(headers.get("len", 0))
|
|
payload = sys.stdin.read(payload_len) if payload_len else ""
|
|
tokens = dict(
|
|
pair.split(":", 1) for pair in payload.split() if ":" in pair
|
|
)
|
|
name = tokens.get("processname", "")
|
|
|
|
# We only subscribe to PROCESS_STATE_FATAL, so any event means a managed
|
|
# program can no longer be restarted.
|
|
if name in SPARED:
|
|
sys.stderr.write(
|
|
"crashexit: %s entered FATAL; it is not on the mail path, the "
|
|
"container stays up\n" % name
|
|
)
|
|
sys.stderr.flush()
|
|
else:
|
|
sys.stderr.write(
|
|
"crashexit: %s entered FATAL; shutting down container\n"
|
|
% (name or "a managed process")
|
|
)
|
|
sys.stderr.flush()
|
|
os.kill(os.getppid(), signal.SIGTERM)
|
|
|
|
write_stdout("RESULT 2\nOK")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|