Closed alxwr closed 5 years ago
Ohh. Wow.
That is an interesting situation. I wonder if you found a bug/unexpected behavior in postfix. The manpage clearly states "After changing master.cf you must execute "postfix reload" to reload the configuration."
Did a quick check, I cannot reproduce the behavior you see:
# rpm -q postfix; ss -tanp | grep LISTEN.*:25; grep '^smtp[ ]*inet' /etc/postfix/master.cf
postfix-3.2.2-3.el7.centos.x86_64
LISTEN 0 100 193.7.176.38:25 *:* users:(("smtpd",pid=17820,fd=7),("master",pid=1469,fd=16))
LISTEN 0 100 127.0.0.1:25 *:* users:(("smtpd",pid=17820,fd=6),("master",pid=1469,fd=14))
smtp inet n - n - - smtpd
So I have an smtp listener on port 25. Let's deactivate it and check again:
# sed -i -e 's/^\(smtp[ ]*inet.*\)/#\1/' /etc/postfix/master.cf; systemctl reload postfix; ss -tanp | grep LISTEN.*:25; grep '^smtp[ ]*inet' /etc/postfix/master.cf
#
No listener anymore. Let's reactivate the port and check again:
sed -i -e 's/^#\(smtp[ ]*inet.*smtpd$\)/\1/' /etc/postfix/master.cf; systemctl reload postfix; ss -tanp | grep LISTEN.*:25; grep '^smtp[ ]*inet' /etc/postfix/master.cf
LISTEN 0 100 193.7.176.38:25 *:* users:(("master",pid=1469,fd=16))
LISTEN 0 100 127.0.0.1:25 *:* users:(("master",pid=1469,fd=14))
smtp inet n - n - - smtpd
#
Looks good to me.
So I am wondering if either the reload did not run for some reason or if your system is acting weird. Restarting the service still seems unnecessary to me.
@ixs Thanks for the review. I'll try to reproduce the bug. If I fail, I'll close this PR.
@alxwr 👍🏻
@ixs You were right. service postfix reload
does work. But it was not triggered, because I made a mistake.
Sounds strange, but nevertheless: Thanks for questioning my PR. :-)
Notes for someone who may come across a similar bug:
I was using this pillar data:
postfix:
config:
inet_interfaces: loopback-only
mydestination: ''
myhostname: {{ __grains__['id'] }}
myorigin: '$mydomain'
relayhost: '$mydomain'
manage_master_config: True
master_config:
services:
smtp:
enable: False
# There's the culprit:
enable_service: False
# I made the mistake of equating (for whatever reason) the concept of a running service with an open port 25/tcp.
# That fixed it:
enable_service: True
I was configuring Postfix to run as a null client (which does not listen on 25/tcp). The socket only was closed when I manually did a
service postfix restart
.So when
master.cf
changes it's appropriate to restart (instead of reload) Postfix. This is a follow-up to #74.Tested on
@ixs this may be of interest to you.