Viktor Dukhovni via Postfix-users:
> > So I would assume from that setting inet_interfaces to empty has the 
> > same effect as setting it to all (it will listen on all interfaces)?
> 
> No, it does not.  Rather, it leaves zero listener addresses enabled,
> which only works if all "inet" services are disabled or all use explicit
> IP endpoints:
> 
>     May 05 03:43:45 amnesiac postfix/postfix-script[2812173]: starting the 
> Postfix mail system
>     May 05 03:43:45 amnesiac postfix/master[2812175]: fatal: 
> /etc/postfix/master.cf: line 12: no valid IP address found: smtp
>     May 05 03:43:47 amnesiac postfix/postfix-script[2812176]: fatal: mail 
> system startup failed
> 
> This is rarely what you want.  I'd be inclined to require that the
> "inet_interfaces" parameter be non-empty (though it could still be
> effectively empty as a list by setting it to be a mixture of spaces and
> at least one comma).

There is code in Postfix that allows an empty inet_interfaces value.
That supports a valid use case, for example, an MTA that sends email
only.

Rather than tinkering with inet_interfaces semantics, I have
improved the error message a bit:

    postfix/master[10639]: fatal: /etc/postfix/master.cf: line 79:
    service definition requires valid host name or address, or
    non-empty inet_interfaces setting

With master.cf line 79 containing

    smtp       inet  n       -       n       -       1       postscreen

The improved error message should be actionable enough.

        Wietse

--- /var/tmp/postfix-3.9-20230504/src/master/master_ent.c       2021-01-08 
20:19:30.000000000 -0500
+++ src/master/master_ent.c     2023-05-05 13:45:44.747539001 -0400
@@ -367,10 +367,17 @@
            inet_addr_list_uniq(MASTER_INET_ADDRLIST(serv));
            serv->listen_fd_count = MASTER_INET_ADDRLIST(serv)->used;
        } else {
-           MASTER_INET_ADDRLIST(serv) =
-               strcasecmp(saved_interfaces, INET_INTERFACES_ALL) ?
-               own_inet_addr_list() :          /* virtual */
-               wildcard_inet_addr_list();      /* wild-card */
+           if (strcasecmp(saved_interfaces, INET_INTERFACES_ALL) == 0) {
+               MASTER_INET_ADDRLIST(serv) = wildcard_inet_addr_list();
+               /* Errors, and no interface found, are fatal. */
+           } else {
+               MASTER_INET_ADDRLIST(serv) = own_inet_addr_list();
+               /* Errors are fatal, but inet_interfaces can be empty. */
+               if (MASTER_INET_ADDRLIST(serv)->used == 0)
+                   fatal_with_context("service definition requires valid"
+                                      " host name or address, or non-empty"
+                                      " %s setting", VAR_INET_INTERFACES);
+           }
            inet_addr_list_uniq(MASTER_INET_ADDRLIST(serv));
            serv->listen_fd_count = MASTER_INET_ADDRLIST(serv)->used;
        }
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to