Move the docroot into the server block.
authorreyk <reyk@openbsd.org>
Fri, 25 Jul 2014 12:42:05 +0000 (12:42 +0000)
committerreyk <reyk@openbsd.org>
Fri, 25 Jul 2014 12:42:05 +0000 (12:42 +0000)
usr.sbin/httpd/httpd.h
usr.sbin/httpd/parse.y
usr.sbin/httpd/server_file.c

index 4cba2cc..1f259ff 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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;
index be355af..cd473a7 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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;
 
index 980efa4..c713394 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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");