From: reyk Date: Fri, 25 Jul 2014 12:42:05 +0000 (+0000) Subject: Move the docroot into the server block. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=228032addcf53e8aae10cbc01e3cd1a05dcd9558;p=openbsd Move the docroot into the server block. --- diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 4cba2cc7d39..1f259ffc10e 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.8 2014/07/24 08:11:27 reyk Exp $ */ +/* $OpenBSD: httpd.h,v 1.9 2014/07/25 12:42:05 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -287,6 +287,7 @@ struct server_config { u_int32_t id; u_int32_t flags; char name[MAXHOSTNAMELEN]; + char docroot[MAXPATHLEN]; in_port_t port; struct sockaddr_storage ss; struct timeval timeout; diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y index be355afeb9f..cd473a74b91 100644 --- a/usr.sbin/httpd/parse.y +++ b/usr.sbin/httpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.3 2014/07/23 22:02:02 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.4 2014/07/25 12:42:05 reyk Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter @@ -215,6 +215,8 @@ server : SERVER STRING { } free($2); + strlcpy(s->srv_conf.docroot, HTTPD_DOCROOT, + sizeof(s->srv_conf.docroot)); s->srv_conf.id = ++last_server_id; s->srv_conf.timeout.tv_sec = SERVER_TIMEOUT; diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index 980efa45f2f..c713394b908 100644 --- a/usr.sbin/httpd/server_file.c +++ b/usr.sbin/httpd/server_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_file.c,v 1.10 2014/07/23 22:20:37 reyk Exp $ */ +/* $OpenBSD: server_file.c,v 1.11 2014/07/25 12:42:05 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -126,7 +126,7 @@ server_file(struct httpd *env, struct client *clt) char path[MAXPATHLEN]; struct stat st; - if (canonicalize_path(HTTPD_DOCROOT, + if (canonicalize_path(srv->srv_conf.docroot, desc->http_path, path, sizeof(path)) == NULL) { /* Do not echo the uncanonicalized path */ server_abort_http(clt, 500, "invalid request path");