mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
Reject empty listening addresses
Using an empty listening address will result in chasquid listening on a random port, which is a dangerous misconfiguration. That is most likely done to prevent it from listening at all. To prevent this misconfiguration, explicitly reject empty listening addresses early and with a warning, so there is no ambiguity. Users can still prevent chasquid from listening by just commenting out the entry in the config (and not passing any systemd file descriptors). See https://github.com/albertito/chasquid/issues/45 for more details and discussion, including alternatives considered. Thanks to xavierg who reported this via IRC.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user