On Sat, Aug 24, 2019 at 10:16:26PM +0200, Martijn van Duren wrote:
> On 8/24/19 10:06 PM, Gilles Chehade wrote:
> > On Sat, Aug 24, 2019 at 12:32:05PM -0700, Darren S. wrote:
> >> OpenBSD 6.5 amd64
> >> OpenSMTPD 6.5.0
> >>
> >> port [port]
> >>         Listen on the given port instead of the default port 25.
> >>
> >> I wanted to confirm if service names are intended to be supported for
> >> `listen on` option in smtpd.conf.
> >>
> >> These result in syntax failure:
> >>
> >> listen on lo port smtp
> >> listen on lo port smtps
> >>
> >> These do not:
> >>
> >> listen on lo port 25
> >> listen on lo port 465
> >>
> >> This also does not:
> >>
> >> listen on lo port submission
> >>
> >> Found it curious that `submission` may be used in place of a port
> >> number but not the other service names.
> >>
> > 
> > this is because `smtp' and `smtps` are keywords, so they must be quoted:
> > 
> > listen on lo port "smtp"
> > 
> > 
> Don't know if there's interest, but considering the port argument is
> non-optional and smtp and smtps are valid (and imho not unreasonable)
> port names I reckon we could add them explicitly so they can be used
> without quotes.
> 

You beat me to it, yes this makes sense.


> Index: parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v
> retrieving revision 1.258
> diff -u -p -r1.258 parse.y
> --- parse.y   23 Aug 2019 19:05:01 -0000      1.258
> +++ parse.y   24 Aug 2019 20:14:40 -0000
> @@ -1863,6 +1863,38 @@ opt_if_listen : INET4 {
>                       free($2);
>                       listen_opts.port = ntohs(servent->s_port);
>               }
> +             | PORT SMTP                     {
> +                     struct servent *servent;
> +
> +                     if (listen_opts.options & LO_PORT) {
> +                             yyerror("port already specified");
> +                             YYERROR;
> +                     }
> +                     listen_opts.options |= LO_PORT;
> +
> +                     servent = getservbyname("smtp", "tcp");
> +                     if (servent == NULL) {
> +                             yyerror("invalid port: smtp");
> +                             YYERROR;
> +                     }
> +                     listen_opts.port = ntohs(servent->s_port);
> +             }
> +             | PORT SMTPS                    {
> +                     struct servent *servent;
> +
> +                     if (listen_opts.options & LO_PORT) {
> +                             yyerror("port already specified");
> +                             YYERROR;
> +                     }
> +                     listen_opts.options |= LO_PORT;
> +
> +                     servent = getservbyname("smtps", "tcp");
> +                     if (servent == NULL) {
> +                             yyerror("invalid port: smtps");
> +                             YYERROR;
> +                     }
> +                     listen_opts.port = ntohs(servent->s_port);
> +             }
>               | PORT NUMBER                   {
>                       if (listen_opts.options & LO_PORT) {
>                               yyerror("port already specified");
> 

-- 
Gilles Chehade                                                 @poolpOrg

https://www.poolp.org            patreon: https://www.patreon.com/gilles

Reply via email to