Download raw body.
smtpd: allow braces for `listen' options
On Fri, 18 Oct 2024 00:50:45 +0200,
Omar Polo <op@omarpolo.com> wrote:
>
> it seemed easier to say than to actually do it. I'm attaching a trivial
> diff for it, but there are some issues. Your example has to be written
> as
>
> filter dnsbl proc-exec {
> filter-dnsbl '-m' domain1 domain2
> domain3 domain4
> }
>
> because otherwise a bare -m will lead to a syntax error. Same story for
> the usage of keywords inside the braces.
>
well, adding support -m without escaping seems not that hacky, I not sure
that I have broke as side effect, but as far as I see tohing.
Anyway, keywords is different story, yeah.
And your patch works as excepted.
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v
retrieving revision 1.299
diff -u -p -r1.299 parse.y
--- parse.y 19 Feb 2024 21:00:19 -0000 1.299
+++ parse.y 19 Oct 2024 23:50:57 -0000
@@ -191,6 +191,7 @@ typedef struct {
%token <v.string> STRING
%token <v.number> NUMBER
%type <v.table> table
+%type <v.string> numberstr cmdline cmdline_l
%type <v.number> size negation
%type <v.table> tables tablenew tableref
%%
@@ -295,6 +296,29 @@ tableval_list : string_list { }
| keyval_list { }
;
+numberstr:
+STRING
+| NUMBER {
+ if (asprintf(&$$, "%lld", (long long)$1) == -1)
+ fatalx("asprintf");
+}
+;
+
+cmdline_l:
+numberstr optnl { $$ = $1; }
+| cmdline_l numberstr optnl {
+ if (asprintf(&$$, "%s %s", $1, $2) == -1)
+ fatalx("asprint");
+ free($1);
+ free($2);
+}
+;
+
+cmdline:
+STRING
+| '{' optnl cmdline_l '}' { $$ = $3; }
+;
+
bounce:
BOUNCE WARN_INTERVAL {
memset(conf->sc_bounce_warn, 0, sizeof conf->sc_bounce_warn);
@@ -1911,7 +1935,7 @@ FILTER STRING PROC STRING {
filter_config = NULL;
}
|
-FILTER STRING PROC_EXEC STRING {
+FILTER STRING PROC_EXEC cmdline {
if (dict_get(conf->sc_filters_dict, $2)) {
yyerror("filter already exists with that name: %s", $2);
free($2);
@@ -2889,7 +2913,7 @@ top:
yyerror("string too long");
return (findeol());
}
- if (isalnum(c) || c == '_') {
+ if (isalnum(c) || c == '-' || c == '_') {
*p++ = c;
continue;
}
@@ -2983,8 +3007,6 @@ nodigits:
while (p > buf + 1)
lungetc((unsigned char)*--p);
c = (unsigned char)*--p;
- if (c == '-')
- return (c);
}
}
@@ -3001,7 +3023,7 @@ nodigits:
x != '!' && x != '=' && x != '#' && \
x != ','))
- if (isalnum(c) || c == ':' || c == '_') {
+ if (isalnum(c) || c == ':' || c == '-' || c == '_') {
do {
*p++ = c;
if ((size_t)(p-buf) >= sizeof(buf)) {
--
wbr, Kirill
smtpd: allow braces for `listen' options