diff --git a/Dockerfile b/Dockerfile index 46c9369..f722cfe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ netcat-openbsd \ && rm -rf /var/lib/apt/lists/* \ && (getent group postdrop || groupadd -r postdrop) \ - && usermod -aG postdrop postfix + && usermod -aG postdrop postfix \ + # /etc/sasldb2 es root:sasl 0640: sin este grupo, smtpd no puede abrirlo y + # devuelve "454 4.7.0 Temporary authentication failure: generic failure" + # (incidente 2026-07-29, fallo 3). + && (getent group sasl || groupadd -r sasl) \ + && usermod -aG sasl postfix COPY main.cf /etc/postfix/main.cf COPY master.cf /etc/postfix/master.cf diff --git a/entrypoint.sh b/entrypoint.sh index 4c8dc0b..3267921 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -15,6 +15,12 @@ fi # Create SASL user in sasldb2 echo "${RELAY_AUTH_PASS}" | saslpasswd2 -p -c -u "${RELAY_AUTH_DOMAIN}" "${RELAY_AUTH_USER}" +# El realm SASL tiene que ser EL MISMO dominio con el que se acaba de crear la entrada +# del sasldb (arriba). Se deriva de la misma variable a propósito: si se declara aparte +# en main.cf, los dos valores pueden divergir sin que nadie lo note y la autenticación +# falla con "454 4.7.0 Temporary authentication failure" (incidente 2026-07-29). +postconf -e "smtpd_sasl_local_domain=${RELAY_AUTH_DOMAIN}" + chown root:sasl /etc/sasldb2 2>/dev/null || true chmod 640 /etc/sasldb2 2>/dev/null || true diff --git a/main.cf b/main.cf index eb3cec8..6f3c8f8 100644 --- a/main.cf +++ b/main.cf @@ -6,13 +6,21 @@ inet_interfaces = all inet_protocols = all mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 +# Logging a fichero — requiere el servicio postlog/postlogd en master.cf. +# Sin esto Postfix escribe a syslog, que aquí no existe, y `kubectl logs` sale vacío. +maillog_file = /var/log/postfix.log + # SASL authentication (Cyrus SASL / sasldb2) smtpd_sasl_auth_enable = yes smtpd_sasl_type = cyrus smtpd_sasl_path = smtpd smtpd_sasl_security_options = noanonymous -smtpd_sasl_local_domain = $myhostname cyrus_sasl_config_path = /etc/postfix/sasl +# smtpd_sasl_local_domain lo fija el entrypoint desde RELAY_AUTH_DOMAIN — la MISMA +# variable con la que saslpasswd2 crea la entrada del sasldb. Antes estaba aquí a +# $myhostname y divergía: el realm salía relayuser@relay.manabo.org y la entrada real +# era relayuser@manabo.org ⇒ "454 4.7.0 Temporary authentication failure" +# (incidente 2026-07-29, fallo 3). No lo pongas aquí: se volverían a poder separar. # Only accept mail from authenticated clients smtpd_relay_restrictions = permit_sasl_authenticated, reject diff --git a/master.cf b/master.cf index d07a0f2..cc7311c 100644 --- a/master.cf +++ b/master.cf @@ -1,36 +1,52 @@ # Postfix master process configuration # service type private unpriv chroot wakeup maxproc command + args +# +# chroot = n en TODOS los servicios (incidente 2026-07-29, fallo 4). +# El chroot de Postfix exige poblar /var/spool/postfix/{etc,dev} en el build; sin +# resolv.conf dentro del jail no hay resolución de MX y el correo se queda en cola +# con "Name service error for name= type=MX" — aunque `getent hosts` dentro +# del contenedor SÍ resuelva. En un contenedor el chroot no aporta nada: el +# contenedor ES el jail. # Port 25 — SMTP (TLS optional, SASL required to relay) -smtp inet n - y - - smtpd +smtp inet n - n - - smtpd # Port 587 — Submission (TLS required, SASL required) -submission inet n - y - - smtpd +submission inet n - n - - smtpd -o smtpd_tls_security_level=encrypt -o smtpd_tls_auth_only=yes -o smtpd_sasl_auth_enable=yes -o smtpd_relay_restrictions=permit_sasl_authenticated,reject -o smtpd_tls_loglevel=1 -pickup unix n - y 60 1 pickup -cleanup unix n - y - 0 cleanup +pickup unix n - n 60 1 pickup +cleanup unix n - n - 0 cleanup qmgr unix n - n 300 1 qmgr -rewrite unix - - y - - trivial-rewrite -bounce unix - - y - 0 bounce -defer unix - - y - 0 bounce -trace unix - - y - 0 bounce -verify unix - - y - 1 verify -flush unix n - y 1000? 0 flush +rewrite unix - - n - - trivial-rewrite +bounce unix - - n - 0 bounce +defer unix - - n - 0 bounce +trace unix - - n - 0 bounce +verify unix - - n - 1 verify +flush unix n - n 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap -smtp unix - - y - - smtp -relay unix - - y - - smtp -showq unix n - y - - showq -error unix - - y - - error -retry unix - - y - - error -discard unix - - y - - discard +smtp unix - - n - - smtp +relay unix - - n - - smtp +showq unix n - n - - showq +error unix - - n - - error +retry unix - - n - - error +discard unix - - n - - discard local unix - n n - - local virtual unix - n n - - virtual -lmtp unix - - y - - lmtp -anvil unix - - y - 1 anvil -scache unix - - y - 1 scache +lmtp unix - - n - - lmtp +anvil unix - - n - 1 anvil +scache unix - - n - 1 scache + +# tlsmgr — sin este daemon smtpd ANUNCIA STARTTLS en el EHLO pero no puede hacerlo, +# y devuelve "454 4.7.0 TLS not available due to local problem" (incidente, fallo 2). +tlsmgr unix - - n 1000? 1 tlsmgr + +# postlogd — Postfix escribe a syslog y en este contenedor no corre ninguno, así que +# `kubectl logs` salía VACÍO y el incidente se diagnosticó a ciegas (fallo 5). +# Junto con maillog_file en main.cf, manda el log a un fichero legible. +postlog unix-dgram n - n - 1 postlogd