author | Alberto Bertogli
<albertito@blitiri.com.ar> 2023-12-02 14:50:17 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2023-12-02 15:08:09 UTC |
parent | d93d7cae10fd94fd4f1f6f67e3be48e23809f9bb |
chasquid.go | +7 | -2 |
test/t-20-bad_configs/c-10-empty_listening_addr/.expected-error | +1 | -0 |
test/t-20-bad_configs/c-10-empty_listening_addr/chasquid.conf | +6 | -0 |
test/t-20-bad_configs/c-10-empty_listening_addr/domains/testserver/users | +0 | -0 |
test/t-20-bad_configs/run.sh | +1 | -1 |
diff --git a/chasquid.go b/chasquid.go index 6e4f1ec..bd850bb 100644 --- a/chasquid.go +++ b/chasquid.go @@ -169,8 +169,13 @@ func main() { func loadAddresses(srv *smtpsrv.Server, addrs []string, ls []net.Listener, mode smtpsrv.SocketMode) int { naddr := 0 for _, addr := range addrs { - // The "systemd" address indicates we get listeners via systemd. - if addr == "systemd" { + if addr == "" { + // An empty address is invalid, to prevent accidental + // misconfiguration. + log.Errorf("Invalid empty listening address for %v", mode) + log.Fatalf("If you want to disable %v, remove it from the config", mode) + } else if addr == "systemd" { + // The "systemd" address indicates we get listeners via systemd. srv.AddListeners(ls, mode) naddr += len(ls) } else { diff --git a/test/t-20-bad_configs/c-10-empty_listening_addr/.expected-error b/test/t-20-bad_configs/c-10-empty_listening_addr/.expected-error new file mode 100644 index 0000000..f460846 --- /dev/null +++ b/test/t-20-bad_configs/c-10-empty_listening_addr/.expected-error @@ -0,0 +1 @@ +Invalid empty listening address for submission diff --git a/test/t-20-bad_configs/c-10-empty_listening_addr/chasquid.conf b/test/t-20-bad_configs/c-10-empty_listening_addr/chasquid.conf new file mode 100644 index 0000000..ff6c0de --- /dev/null +++ b/test/t-20-bad_configs/c-10-empty_listening_addr/chasquid.conf @@ -0,0 +1,6 @@ +mail_delivery_agent_bin: "test-mda" +mail_delivery_agent_args: "%to%" +data_dir: "../.data" +mail_log_path: "../.logs/mail_log" + +submission_address: "" diff --git a/test/t-20-bad_configs/c-10-empty_listening_addr/domains/testserver/users b/test/t-20-bad_configs/c-10-empty_listening_addr/domains/testserver/users new file mode 100644 index 0000000..e69de29 diff --git a/test/t-20-bad_configs/run.sh b/test/t-20-bad_configs/run.sh index 89255e1..9ba2130 100755 --- a/test/t-20-bad_configs/run.sh +++ b/test/t-20-bad_configs/run.sh @@ -18,7 +18,7 @@ mkdir -p c-04-no_cert_dirs/certs/ # Generate certs for the tests that need them. for i in c-05-no_addrs c-06-bad_maillog c-07-bad_domain_info \ - c-08-bad_sts_cache c-09-bad_queue_dir ; + c-08-bad_sts_cache c-09-bad_queue_dir c-10-empty_listening_addr ; do CONFDIR=$i/ generate_certs_for testserver done