From: Stefan Sperling Subject: Re: gotwebd.conf fcgi port syntax change To: Omar Polo Cc: gameoftrees@openbsd.org Date: Mon, 29 Aug 2022 17:20:05 +0200 On Mon, Aug 29, 2022 at 03:43:46PM +0200, Omar Polo wrote: > > @@ -360,9 +369,6 @@ serveropts1 : REPOS_PATH STRING { | FCGI_SOCKET boolean { > > this hunk is wrong. it says that there are 9 context lines of the old > file and 6 of the new file, but they're 8 and 5 respectively, so > > > new_srv->fcgi_socket = $2; > > } > > - | FCGI_SOCKET boolean { > > - new_srv->fcgi_socket = $2; > > - } '{' optnl socketopts2 '}' > > | UNIX_SOCKET boolean { > > new_srv->unix_socket = $2; > > } > > @@ -386,54 +392,6 @@ serveropts2 : serveropts2 serveropts1 nl > > both got patch and patch(1) fails when finding a line starting with > '@' when they expect one context line still. > > If i manually fix it then the patch applies There was a line-wrap, a context line moved up into the hunk header. Trying again: diff f0680473a7db1e5941bffdc2ab5f80ddec209122 refs/heads/gotwebd-listen-port commit - f0680473a7db1e5941bffdc2ab5f80ddec209122 commit + 9dc531b939237dddb6dfb8b7e28cafe6572dae16 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; } @@ -386,54 +392,6 @@ 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 ; > > % got patch < x > G gotwebd/parse.y > @@ -360,8 +369,5 @@ applied with offset 1 > > fwiw my main branch points to the commit you're using as base for the > patch: > > % got ref -l refs/heads/main > refs/heads/main: f0680473a7db1e5941bffdc2ab5f80ddec209122 > >