test / test (push) Has been cancelled
Verified the tree against docs/plans/code-review-2026-08.md and finished the tasks that were only partly done, plus two defects the pass introduced. - bcrypt: the setup account was still hashed at DefaultCost (10). The work factor now has one definition, auth.BcryptCost = 12, used everywhere. - rate limiter: protecting blocked buckets from eviction was unbounded — an attacker with many source addresses could grow the map by making each one fail its way to blocked. Blocked buckets are now evicted past maxBuckets * 4, nearest expiry first, logged once per window. Tests cover both halves. - postqueue: the 5s timeout left the output size unbounded; reads are now capped at 4 MiB and report truncation. - spec references: the ~76 `spec N` citations CHANGELOG [0.5.0] claimed were gone are removed from build/, deploy/, the first two migrations and the release workflow, with the affected comment paragraphs re-wrapped. Comments only; shell/YAML/SQL syntax re-checked. - schema-migrations.md: schema section was headed v9 with the chain at v10, and three links pointed at deleted plan files. - internal/configsafe: the shared empty/forbidden-character check behind the OpenDKIM and Postfix config writers; each writer keeps its own forbidden set. - dropped the parseDomainRateLimitForm/parseAppRateLimitForm pass-throughs left behind by the parser merge (only their own tests still called them). - plan doc now carries a status table: what shipped, what was already in place, what was declined (//go:build linux for the /proc reader) and the open CSRF-token question. Not done, each its own phase: typed template data structs, log/slog, DMARC service and handler tests, error-page/corrupted-backup tests, backup re-auth. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
66 lines
2.0 KiB
Bash
66 lines
2.0 KiB
Bash
#!/bin/sh
|
|
# Periodic logrotate for /data/log/mail.log. Rotation renames the file,
|
|
# recreates it (`create 0640 postfix selfpost`, matching a cold container
|
|
# start), then runs `postfix reload` (the same mechanism `postfix logrotate`
|
|
# uses): postlogd keeps writing to the renamed inode until reload, and the
|
|
# panel's log-tailer holds its own descriptor on that inode, so nothing written
|
|
# before the reload is lost. `create` (rather than `nocreate`) matters here
|
|
# beyond timing: a postlogd-triggered recreate lands the file at 0600 owned by
|
|
# postfix, which the unprivileged panel process cannot read — confirmed on a
|
|
# live container — so logrotate must be the one to create it.
|
|
#
|
|
# logrotate itself only rotates once the configured "daily" period has elapsed
|
|
# (tracked in /var/lib/logrotate/status), so it is safe to invoke this more
|
|
# often than daily — polling merely bounds how late a legitimate rotation runs.
|
|
set -eu
|
|
|
|
CONFIG=/etc/logrotate.d/mail
|
|
INTERVAL="${LOGROTATE_INTERVAL_SECONDS:-21600}"
|
|
|
|
# logrotate refuses configs writable by group or others and exits 0 while
|
|
# ignoring them — fail here so supervisord reports the fault.
|
|
logrotate_config_ok() {
|
|
mode=$(stat -c '%a' "$CONFIG")
|
|
mode=${mode#0}
|
|
grp=$(( (mode / 10) % 10 ))
|
|
oth=$(( mode % 10 ))
|
|
case $grp in 2|3|6|7) return 1 ;; esac
|
|
case $oth in 2|3|6|7) return 1 ;; esac
|
|
return 0
|
|
}
|
|
|
|
logrotate_config_fatal() {
|
|
echo "logrotate-loop: refusing to run: $CONFIG mode $(stat -c '%a' "$CONFIG") is writable by group or others" >&2
|
|
exit 1
|
|
}
|
|
|
|
if ! logrotate_config_ok; then
|
|
logrotate_config_fatal
|
|
fi
|
|
|
|
run_logrotate() {
|
|
out=$(logrotate "$CONFIG" 2>&1) || {
|
|
echo "$out" >&2
|
|
return 1
|
|
}
|
|
case "$out" in
|
|
*Ignoring*|*Potentially\ dangerous\ mode*)
|
|
echo "$out" >&2
|
|
logrotate_config_fatal
|
|
;;
|
|
esac
|
|
return 0
|
|
}
|
|
|
|
while true; do
|
|
if ! logrotate_config_ok; then
|
|
logrotate_config_fatal
|
|
fi
|
|
if run_logrotate; then
|
|
:
|
|
else
|
|
echo "logrotate-loop: logrotate failed, will retry after ${INTERVAL}s" >&2
|
|
fi
|
|
sleep "${INTERVAL}"
|
|
done
|