Re: Bug: Postfix errors at startup for service listed in known_tcp_ports but not listed in /etc/services

2021-10-17 Thread Peter

On 17/10/21 8:00 pm, Viktor Dukhovni wrote:

The feature appears to have been released in an incomplete form.
I don't see any code in Postfix to actually use "known_tcp_ports"
to load the underlying hash table.


Hr, okay.


Also, while numeric service names work with getaddrinfo(3), I
don't believe they work with with getservbyname(3):

 +   if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) 
!= 0)
 +   if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) 
== 0)
 +   if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) 
== 0)
 +if ((sp = getservbyname(filter_known_tcp_port(service), proto)) != 0) 
{

So even when the parameter is properly loaded, only the last two changes
would work as expected.


That makes sense.  It seems like we need a wrapper function for 
getservbyname() that first checks htable_locate() and if the port exists 
there simply creates the servent structure itself with the proper 
service data, and if not passes the call onto getservbyname().



Peter


Re: Bug: Postfix errors at startup for service listed in known_tcp_ports but not listed in /etc/services

2021-10-17 Thread Viktor Dukhovni
On Sun, Oct 17, 2021 at 06:40:47PM +1300, Peter wrote:

> Just had someone come into the IRC chat with this issue and I was able 
> to reproduce it quite easily, this is with Postfix 3.6.2.  If your 
> /etc/services has smtps listed but not submissions (or vice-versa) and 
> you uncomment or add the relevant section to master.cf then postfix 
> gives an error like the following at startup:
> 
> Oct 17 18:28:59 CentOS8 postfix/master[79810]: fatal: 
> 127.0.0.1:submissions: Servname not supported for ai_socktype
> Oct 17 18:29:00 CentOS8 postfix/master[79809]: fatal: daemon 
> initialization failure
> Oct 17 18:29:01 CentOS8 postfix/postfix-script[79811]: fatal: mail 
> system startup failed

The feature appears to have been released in an incomplete form.
I don't see any code in Postfix to actually use "known_tcp_ports"
to load the underlying hash table.

Also, while numeric service names work with getaddrinfo(3), I
don't believe they work with with getservbyname(3):

--- a/src/posttls-finger/posttls-finger.c
+++ b/src/posttls-finger/posttls-finger.c
@@ -1495 +1496 @@ static char *parse_destination(char *destination, char 
*def_service,
-   if ((sp = getservbyname(service, protocol)) != 0)
+   if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) 
!= 0)
--- a/src/smtp/smtp_connect.c
+++ b/src/smtp/smtp_connect.c
@@ -363 +364 @@ static char *smtp_parse_destination(char *destination, char 
*def_service,
-   if ((sp = getservbyname(service, protocol)) == 0)
+   if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) 
== 0)
--- a/src/util/find_inet.c
+++ b/src/util/find_inet.c
@@ -92 +93 @@ int find_inet_port(const char *service, const char 
*protocol)
-   if ((sp = getservbyname(service, protocol)) == 0)
+   if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) 
== 0)
--- a/src/util/myaddrinfo.c
+++ b/src/util/myaddrinfo.c
@@ -284 +285 @@ static int find_service(const char *service, int socktype)
-if ((sp = getservbyname(service, proto)) != 0) {
+if ((sp = getservbyname(filter_known_tcp_port(service), proto)) != 0) {
@@ -447 +448 @@ int hostname_to_sockaddr_pf(const char *hostname, int 
pf,
-err = getaddrinfo(hostname, service, , res);
+err = getaddrinfo(hostname, filter_known_tcp_port(service), , 
res);
@@ -563 +564 @@ int hostaddr_to_sockaddr(const char *hostaddr, const 
char *service,
-err = getaddrinfo(hostaddr, service, , res);
+err = getaddrinfo(hostaddr, filter_known_tcp_port(service), , 
res);

So even when the parameter is properly loaded, only the last two changes
would work as expected.

-- 
Viktor.


Bug: Postfix errors at startup for service listed in known_tcp_ports but not listed in /etc/services

2021-10-16 Thread Peter
Just had someone come into the IRC chat with this issue and I was able 
to reproduce it quite easily, this is with Postfix 3.6.2.  If your 
/etc/services has smtps listed but not submissions (or vice-versa) and 
you uncomment or add the relevant section to master.cf then postfix 
gives an error like the following at startup:


Oct 17 18:28:59 CentOS8 postfix/master[79810]: fatal: 
127.0.0.1:submissions: Servname not supported for ai_socktype
Oct 17 18:29:00 CentOS8 postfix/master[79809]: fatal: daemon 
initialization failure
Oct 17 18:29:01 CentOS8 postfix/postfix-script[79811]: fatal: mail 
system startup failed


...the thing is that submissions is listed in known_tcp_ports:

known_tcp_ports = lmtp=24, smtp=25, smtps=submissions=465, submission=587

...so by rights postfix should know that submissions is port 465 and 
startup without error in spite of the service not being listed in 
/etc/services.


Is there a stray startup check that was missed when known_tcp_ports was 
added or something?



Peter