Re: httpd 2/3: rename "root strip" to "request strip"

2018-05-29 Thread Reyk Floeter
On Wed, May 30, 2018 at 12:32:12AM +0200, Reyk Floeter wrote:
> Hi,
> 
> this diff applies on top of the previous one.
> 
> Rename "root strip" to "request strip"
> 
> The root strip option name was semantically incorrect as it does not
> strip the root but the request path.  This is a grammar change and it
> also needs a heads up and a change in other documentation (such as
> acme-client(1)).
> 

This is the related documentation diff for the tree.  Sorry for the
inconvenience, but it is better for the correctness of the grammar.

Reyk

Index: etc/examples/httpd.conf
===
RCS file: /cvs/src/etc/examples/httpd.conf,v
retrieving revision 1.19
diff -u -p -u -p -r1.19 httpd.conf
--- etc/examples/httpd.conf 11 Apr 2018 15:51:50 -  1.19
+++ etc/examples/httpd.conf 29 May 2018 22:44:24 -
@@ -4,7 +4,7 @@ server "example.com" {
listen on * port 80
location "/.well-known/acme-challenge/*" {
root "/acme"
-   root strip 2
+   request strip 2
}
location * {
block return 302 "https://$HTTP_HOST$REQUEST_URI";
@@ -22,6 +22,6 @@ server "example.com" {
}
location "/.well-known/acme-challenge/*" {
root "/acme"
-   root strip 2
+   request strip 2
}
 }
Index: usr.sbin/acme-client/acme-client.1
===
RCS file: /cvs/src/usr.sbin/acme-client/acme-client.1,v
retrieving revision 1.23
diff -u -p -u -p -r1.23 acme-client.1
--- usr.sbin/acme-client/acme-client.1  17 Oct 2017 22:47:58 -  1.23
+++ usr.sbin/acme-client/acme-client.1  29 May 2018 22:44:24 -
@@ -83,7 +83,7 @@ which will properly map response challen
 .Bd -literal -offset indent
 location "/.well-known/acme-challenge/*" {
root "/acme"
-   root strip 2
+   request strip 2
 }
 .Ed
 .Sh FILES
Index: usr.sbin/acme-client/acme-client.conf.5
===
RCS file: /cvs/src/usr.sbin/acme-client/acme-client.conf.5,v
retrieving revision 1.11
diff -u -p -u -p -r1.11 acme-client.conf.5
--- usr.sbin/acme-client/acme-client.conf.5 27 Nov 2017 01:58:52 -  
1.11
+++ usr.sbin/acme-client/acme-client.conf.5 29 May 2018 22:44:24 -
@@ -169,7 +169,7 @@ server "example.com" {
 tls key "/etc/ssl/private/example.com.key"
 location "/.well-known/acme-challenge/*" {
 root "/acme"
-root strip 2
+request strip 2
 }
 root "/htdocs"
 }
Index: regress/usr.sbin/acme-client/httpd.conf
===
RCS file: /cvs/src/regress/usr.sbin/acme-client/httpd.conf,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 httpd.conf
--- regress/usr.sbin/acme-client/httpd.conf 25 Jun 2017 21:33:23 -  
1.1
+++ regress/usr.sbin/acme-client/httpd.conf 29 May 2018 22:44:24 -
@@ -3,6 +3,6 @@ server "default" {
listen on "*" port 80
location "/.well-known/acme-challenge/*" {
root "/acme"
-   root strip 2
+   request strip 2
}
 }



httpd 2/3: rename "root strip" to "request strip"

2018-05-29 Thread Reyk Floeter
Hi,

this diff applies on top of the previous one.

Rename "root strip" to "request strip"

The root strip option name was semantically incorrect as it does not
strip the root but the request path.  This is a grammar change and it
also needs a heads up and a change in other documentation (such as
acme-client(1)).

OK?

Reyk

diff --git usr.sbin/httpd/httpd.conf.5 usr.sbin/httpd/httpd.conf.5
index 9c7efbc..2a71c8d 100644
--- usr.sbin/httpd/httpd.conf.5
+++ usr.sbin/httpd/httpd.conf.5
@@ -458,12 +458,18 @@ instead of the log files.
 Disable any previous
 .Ic block
 in a location.
-.It Ic root Ar option
-Configure the document root and options for the request path.
+.It Ic request Ar option
+Configure the options for the request path.
 Valid options are:
 .Bl -tag -width Ds
-.It Ar directory
-Set the document root of the server.
+.It Ic strip Ar number
+Strip
+.Ar number
+path components from the beginning of the request path before looking
+up the stripped-down path at the document root.
+.El
+.It Ic root Ar directory
+Configure the document root of the server.
 The
 .Ar directory
 is a pathname within the
diff --git usr.sbin/httpd/parse.y usr.sbin/httpd/parse.y
index 2cdfab5..5766e96 100644
--- usr.sbin/httpd/parse.y
+++ usr.sbin/httpd/parse.y
@@ -486,6 +486,7 @@ serveroptsl : LISTEN ON STRING opttls port  {
YYERROR;
}
}
+   | request
| root
| directory
| logformat
@@ -804,7 +805,17 @@ rootflags  : STRING{
free($1);
srv->srv_conf.flags |= SRVFLAG_ROOT;
}
-   | STRIP NUMBER  {
+   ;
+
+request: REQUEST requestflags
+   | REQUEST '{' optnl requestflags_l '}'
+   ;
+
+requestflags_l : requestflags optcommanl requestflags_l
+   | requestflags optnl
+   ;
+
+requestflags   : STRIP NUMBER  {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid strip number");
YYERROR;