From: reyk Date: Fri, 25 Jul 2014 15:47:11 +0000 (+0000) Subject: Add and document 'root' configuration option for the docroot. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6feb7b3fe1ba0f4d8d8e80d78d5cad9baba8dac4;p=openbsd Add and document 'root' configuration option for the docroot. --- diff --git a/usr.sbin/httpd/httpd.conf.5 b/usr.sbin/httpd/httpd.conf.5 index afef0823695..cbd10048f29 100644 --- a/usr.sbin/httpd/httpd.conf.5 +++ b/usr.sbin/httpd/httpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: httpd.conf.5,v 1.5 2014/07/22 19:03:21 jmc Exp $ +.\" $OpenBSD: httpd.conf.5,v 1.6 2014/07/25 15:47:11 reyk Exp $ .\" .\" Copyright (c) 2014 Reyk Floeter .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 22 2014 $ +.Dd $Mdocdate: July 25 2014 $ .Dt HTTPD.CONF 5 .Os .Sh NAME @@ -115,6 +115,16 @@ The following general table options are available: .Bl -tag -width Ds .It Ic listen on Ar address Ic port Ar number Set the listen address and port. +.It Ic root Ar directory +Set the document root of the server. +The +.Ar directory +is a pathname within the +.Xr chroot 2 +root directory of +.Nm httpd . +If not specified, it defaults to +.Pa /htdocs . .El .Sh TYPES Configure the supported media types. diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y index cd473a74b91..bd172b46d45 100644 --- a/usr.sbin/httpd/parse.y +++ b/usr.sbin/httpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.4 2014/07/25 12:42:05 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.5 2014/07/25 15:47:11 reyk Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter @@ -126,7 +126,7 @@ typedef struct { %} -%token ALL PORT LISTEN PREFORK SERVER ERROR INCLUDE LOG VERBOSE ON TYPES +%token ALL PORT LISTEN PREFORK ROOT SERVER ERROR LOG VERBOSE ON TYPES %token UPDATES INCLUDE %token STRING %token NUMBER @@ -266,6 +266,16 @@ serveroptsl : LISTEN ON STRING port { s->srv_conf.port = h->port.val[0]; host_free(&al); } + | ROOT STRING { + if (strlcpy(srv->srv_conf.docroot, $2, + sizeof(srv->srv_conf.docroot)) >= + sizeof(srv->srv_conf.docroot)) { + yyerror("document root too long"); + free($2); + YYERROR; + } + free($2); + } ; types : TYPES '{' optnl mediaopts_l '}' @@ -401,6 +411,7 @@ lookup(char *s) { "on", ON }, { "port", PORT }, { "prefork", PREFORK }, + { "root", ROOT }, { "server", SERVER }, { "types", TYPES }, { "updates", UPDATES }