diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2019-08-25 03:40:46 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2019-08-25 03:40:46 +0000 |
commit | f32bdae103ba11fe074161ffaf2194c62d58f85f (patch) | |
tree | 9e59bcf310bc701699b3ac2f75031ebe1e30ce22 | |
parent | 3ac6cffbfe44b6aaf2ed0152287da43e5722e1d2 (diff) |
Allow for "port smtp" and "port smtps" on listen statement.
This was previously not allowed, because both smtp and smtps are keywords.
Since port's argument is non-optional and smtp and smtps are common enough
there is no chance for misinterpretation.
Problem reported by phatbuckett <at> gmail <dot> com
OK gilles@
-rw-r--r-- | usr.sbin/smtpd/parse.y | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index bafa3bccf21..6d7ba697bba 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.258 2019/08/23 19:05:01 martijn Exp $ */ +/* $OpenBSD: parse.y,v 1.259 2019/08/25 03:40:45 martijn Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -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"); |