test / test (push) Canceled after 0s
The runtime base is debian:trixie-slim, the build stage golang:1.26-trixie:
Postfix 3.10.13 with upstream's 2026 security fixes up to the August
batch, libmilter 8.18.1, OpenSSL 3.5. Every citation of another program in
code, scripts and documents was re-read against the trixie sources
(dev/upstream; bookworm's kept in dev/upstream-bookworm) and updated;
development.md's cited-package table holds the trixie versions.
What the re-reading changed in behaviour:
- logtail: reject lines with sasl_method/sasl_username/sasl_sender
(smtpd_check.c:1019-1026); cleanup's "removed (canceled)" forgets a
port-25 id (cleanup_api.c:363-364).
- internal/postfix/retry.go reads postconf's stdout only: since 3.9 a
deprecated-parameter warning on stderr made one value too many and the
panel fell back to the compiled-in retry policy.
- logrotate-loop.sh: logrotate 3.22 exits 1 when it ignores a config;
the loop refuses on that output whatever the status.
- postfix-config.sh: cyrus_sasl_config_path set explicitly (bookworm's
07_sasl_config.diff is gone); maillog_file_permissions=0640; mynetworks
explicit; Dockerfile: SYNC_CHROOT= in /etc/default/postfix,
opendkim-tools dropped, openssl named, systemd-standalone-sysusers so
cron does not bring the whole of systemd.
- The selfpost group is 10998, outside the system range 100-999: in
trixie a package took 998 and the build failed (owner's decision:
a conflict-free id, the distribution's own ids untouched). The
entrypoint hands /data back by name when the user or the group differs.
Guide, backup refusal text, help (design commit 68ec8b2), e2e.
- smtpd_hide_client_session=yes on smtps and submission (owner's
decision): Received: names no client, TLS, login or protocol; port 25
keeps the full header. e2e checks both.
- test/upstream/opendkim-probe.sh makes keys with openssl genrsa.
Tests: on the server, make e2e exit 0 (674 s, the image built on trixie),
go vet + go test 27 packages ok. CHANGELOG [Unreleased], guide,
architecture.md, security.md, roadmap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
139 lines
4.7 KiB
Go
139 lines
4.7 KiB
Go
package postfix
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// The postconf values in these tests are composed by hand: values main.cf
|
|
// could hold. Stock Postfix 3.10.13 prints "0h" for delay_warning_time
|
|
// (src/global/mail_params.h, DEF_DELAY_WARN_TIME), not "0".
|
|
func TestLoadRetryPolicyUsesPostconfValues(t *testing.T) {
|
|
old := readRetryConf
|
|
readRetryConf = func() ([]string, error) {
|
|
return []string{"300s", "300s", "4000s", "2d", "5d", "0"}, nil
|
|
}
|
|
t.Cleanup(func() { readRetryConf = old })
|
|
|
|
p := LoadRetryPolicy()
|
|
if p.FromDefaults {
|
|
t.Fatal("FromDefaults = true, want live postconf values")
|
|
}
|
|
if p.MinimalBackoff != 300*time.Second {
|
|
t.Errorf("MinimalBackoff = %v, want 300s", p.MinimalBackoff)
|
|
}
|
|
if p.MaximalBackoff != 4000*time.Second {
|
|
t.Errorf("MaximalBackoff = %v, want 4000s", p.MaximalBackoff)
|
|
}
|
|
if p.MaximalQueueLifetime != 2*24*time.Hour {
|
|
t.Errorf("MaximalQueueLifetime = %v, want 2d", p.MaximalQueueLifetime)
|
|
}
|
|
// 5d over a maximal 2d: qmgr uses 2d (Postfix 3.10.13, src/qmgr/qmgr.c,
|
|
// qmgr_post_init(), "adjusting bounce_queue_lifetime").
|
|
if p.BounceQueueLifetime != 2*24*time.Hour {
|
|
t.Errorf("BounceQueueLifetime = %v, want 2d", p.BounceQueueLifetime)
|
|
}
|
|
if p.DelayWarningTime != 0 {
|
|
t.Errorf("DelayWarningTime = %v, want 0", p.DelayWarningTime)
|
|
}
|
|
}
|
|
|
|
// A message lives at most maximal_queue_lifetime: qmgr caps
|
|
// bounce_queue_lifetime at it (Postfix 3.10.13, src/qmgr/qmgr.c,
|
|
// qmgr_post_init()), so a larger bounce lifetime does not lengthen it.
|
|
func TestLongestLifetimeIsTheQueueLifetime(t *testing.T) {
|
|
p, err := parseRetryPolicy([]string{"300s", "300s", "4000s", "1d", "5d", "0h"})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p.LongestLifetime() != 24*time.Hour || p.BounceQueueLifetime != 24*time.Hour {
|
|
t.Fatalf("LongestLifetime %v, BounceQueueLifetime %v; want 24h both", p.LongestLifetime(), p.BounceQueueLifetime)
|
|
}
|
|
}
|
|
|
|
func TestLoadRetryPolicyFallsBackWhenPostconfFails(t *testing.T) {
|
|
old := readRetryConf
|
|
readRetryConf = func() ([]string, error) {
|
|
return nil, errors.New("exec: not found")
|
|
}
|
|
t.Cleanup(func() { readRetryConf = old })
|
|
|
|
p := LoadRetryPolicy()
|
|
want := DefaultRetryPolicy()
|
|
if !p.FromDefaults {
|
|
t.Error("FromDefaults = false, want true when postconf fails")
|
|
}
|
|
if p.QueueRunDelay != want.QueueRunDelay || p.MinimalBackoff != want.MinimalBackoff ||
|
|
p.MaximalBackoff != want.MaximalBackoff || p.MaximalQueueLifetime != want.MaximalQueueLifetime {
|
|
t.Errorf("fallback = %+v, want compiled-in defaults %+v", p, want)
|
|
}
|
|
}
|
|
|
|
func TestLoadRetryPolicyFallsBackOnUnparseableValues(t *testing.T) {
|
|
old := readRetryConf
|
|
readRetryConf = func() ([]string, error) {
|
|
return []string{"300s", "nope", "4000s", "5d", "5d", "0"}, nil
|
|
}
|
|
t.Cleanup(func() { readRetryConf = old })
|
|
|
|
p := LoadRetryPolicy()
|
|
if !p.FromDefaults {
|
|
t.Error("FromDefaults = false, want true when a value cannot be parsed")
|
|
}
|
|
}
|
|
|
|
func TestParseRetryPolicyStock(t *testing.T) {
|
|
p, err := parseRetryPolicy([]string{"300s", "300s", "4000s", "5d", "5d", "0"})
|
|
if err != nil {
|
|
t.Fatalf("parseRetryPolicy: %v", err)
|
|
}
|
|
if p.FromDefaults {
|
|
t.Error("parsed policy should not be marked FromDefaults")
|
|
}
|
|
if p.QueueRunDelay != 300*time.Second || p.MaximalQueueLifetime != 5*24*time.Hour {
|
|
t.Errorf("parsed = %+v", p)
|
|
}
|
|
}
|
|
|
|
// TestFakePostconf is not a test: it is the fake `postconf -h -x` the test
|
|
// below runs in place of the real one. Its warning is composed after Postfix
|
|
// 3.10.13, src/postconf/postconf_unused.c, pcf_flag_unused_parameters(),
|
|
// written to stderr after the values (src/postconf/postconf.c, main()).
|
|
func TestFakePostconf(t *testing.T) {
|
|
if os.Getenv("SP_FAKE_POSTCONF") != "1" {
|
|
t.Skip("helper process")
|
|
}
|
|
fmt.Fprint(os.Stdout, "300s\n300s\n4000s\n2d\n5d\n0h\n")
|
|
fmt.Fprint(os.Stderr, "postconf: warning: /etc/postfix/main.cf: support for parameter \"smtpd_use_tls\" will be removed; instead, specify \"smtpd_tls_security_level\"\n")
|
|
os.Exit(0)
|
|
}
|
|
|
|
// postconf's warnings are not values: since Postfix 3.9 a deprecated
|
|
// main.cf parameter draws one on every run, and read with the values it made
|
|
// one line too many, so the panel showed the compiled-in defaults.
|
|
func TestPostconfRetryValuesReadsStdoutOnly(t *testing.T) {
|
|
old := postconfRetryCmd
|
|
postconfRetryCmd = func() *exec.Cmd {
|
|
cmd := exec.Command(os.Args[0], "-test.run=^TestFakePostconf$")
|
|
cmd.Env = append(os.Environ(), "SP_FAKE_POSTCONF=1")
|
|
return cmd
|
|
}
|
|
t.Cleanup(func() { postconfRetryCmd = old })
|
|
|
|
lines, err := postconfRetryValues()
|
|
if err != nil {
|
|
t.Fatalf("postconfRetryValues: %v", err)
|
|
}
|
|
p, err := parseRetryPolicy(lines)
|
|
if err != nil {
|
|
t.Fatalf("parse %q: %v", lines, err)
|
|
}
|
|
if p.MaximalQueueLifetime != 2*24*time.Hour || p.FromDefaults {
|
|
t.Errorf("policy = %+v, want the postconf values", p)
|
|
}
|
|
}
|