commit 17132eaa7c11854dadce91afd817b4676e716b04 from: Stefan Sperling date: Mon Aug 29 17:25:30 2022 UTC change gotwebd.conf fcgi socket syntax to "listen on 'foo' port 'bar'" ok op@ commit - f0680473a7db1e5941bffdc2ab5f80ddec209122 commit + 17132eaa7c11854dadce91afd817b4676e716b04 blob - 601286fd54eb92e666ed42a52b7d7a851eb91940 blob + d061ce939fdc0aeb984fb2f8da84a80463c6b189 --- gotwebd/parse.y +++ gotwebd/parse.y @@ -154,22 +154,22 @@ boolean : STRING { | NUMBER { $$ = $1; } ; -fcgiport : NUMBER { - if ($1 <= 0 || $1 > (int)USHRT_MAX) { - yyerror("invalid port: %lld", $1); +fcgiport : PORT NUMBER { + if ($2 <= 0 || $2 > (int)USHRT_MAX) { + yyerror("invalid port: %lld", $2); YYERROR; } - $$ = htons($1); + $$ = $2; } - | STRING { + | PORT STRING { int val; - if ((val = getservice($1)) == -1) { - yyerror("invalid port: %s", $1); - free($1); + if ((val = getservice($2)) == -1) { + yyerror("invalid port: %s", $2); + free($2); YYERROR; } - free($1); + free($2); $$ = val; } @@ -191,9 +191,6 @@ main : PREFORK NUMBER { | FCGI_SOCKET boolean { gotwebd->fcgi_socket = $2; } - | FCGI_SOCKET boolean { - gotwebd->fcgi_socket = $2; - } '{' optnl socketopts4 '}' | UNIX_SOCKET boolean { gotwebd->unix_socket = $2; } @@ -331,6 +328,18 @@ serveropts1 : REPOS_PATH STRING { } free($2); } + | LISTEN ON STRING fcgiport { + n = strlcpy(new_srv->fcgi_socket_bind, $3, + sizeof(new_srv->fcgi_socket_bind)); + if (n >= sizeof(new_srv->fcgi_socket_bind)) { + yyerror("%s: fcgi_socket_bind truncated", + __func__); + free($3); + YYERROR; + } + free($3); + new_srv->fcgi_socket_port = $4; + } | MAX_REPOS NUMBER { if ($2 > 0) new_srv->max_repos = $2; @@ -360,9 +369,6 @@ serveropts1 : REPOS_PATH STRING { | FCGI_SOCKET boolean { new_srv->fcgi_socket = $2; } - | FCGI_SOCKET boolean { - new_srv->fcgi_socket = $2; - } '{' optnl socketopts2 '}' | UNIX_SOCKET boolean { new_srv->unix_socket = $2; } @@ -384,56 +390,8 @@ serveropts1 : REPOS_PATH STRING { serveropts2 : serveropts2 serveropts1 nl | serveropts1 optnl - ; - -socketopts1 : LISTEN ON STRING { - n = strlcpy(new_srv->fcgi_socket_bind, $3, - sizeof(new_srv->fcgi_socket_bind)); - if (n >= sizeof(new_srv->fcgi_socket_bind)) { - yyerror("%s: fcgi_socket_bind truncated", - __func__); - free($3); - YYERROR; - } - free($3); - } - | PORT fcgiport { - struct server *srv; - - TAILQ_FOREACH(srv, &gotwebd->servers, entry) { - if (srv->fcgi_socket_port == $2) { - yyerror("port already assigned"); - YYERROR; - } - } - new_srv->fcgi_socket_port = $2; - } ; -socketopts2 : socketopts2 socketopts1 nl - | socketopts1 optnl - ; - -socketopts3 : LISTEN ON STRING { - n = strlcpy(gotwebd->fcgi_socket_bind, $3, - sizeof(gotwebd->fcgi_socket_bind)); - if (n >= sizeof(gotwebd->fcgi_socket_bind)) { - yyerror("%s: fcgi_socket_bind truncated", - __func__); - free($3); - YYERROR; - } - free($3); - } - | PORT fcgiport { - gotwebd->fcgi_socket_port = $2; - } - ; - -socketopts4 : socketopts4 socketopts3 nl - | socketopts3 optnl - ; - nl : '\n' optnl ;