Rename the "docroot" variable to "path" because it will be used for
authorreyk <reyk@openbsd.org>
Thu, 31 Jul 2014 13:28:15 +0000 (13:28 +0000)
committerreyk <reyk@openbsd.org>
Thu, 31 Jul 2014 13:28:15 +0000 (13:28 +0000)
either files or the fastcgi socket (and there's no need to use a union yet).

usr.sbin/httpd/config.c
usr.sbin/httpd/httpd.h
usr.sbin/httpd/parse.y
usr.sbin/httpd/server_file.c

index cc8060f..6130a0b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: config.c,v 1.8 2014/07/31 09:34:57 reyk Exp $ */
+/*     $OpenBSD: config.c,v 1.9 2014/07/31 13:28:15 reyk Exp $ */
 
 /*
  * Copyright (c) 2011 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -238,11 +238,11 @@ config_getserver_config(struct httpd *env, struct server *srv,
                if ((srv_conf->flags & f) == 0)
                        srv_conf->flags |= srv->srv_conf.flags & f;
 
-               f = SRVFLAG_DOCROOT;
+               f = SRVFLAG_PATH;
                if ((srv_conf->flags & f) == 0) {
-                       (void)strlcpy(srv_conf->docroot,
-                           srv->srv_conf.docroot,
-                           sizeof(srv_conf->docroot));
+                       (void)strlcpy(srv_conf->path,
+                           srv->srv_conf.path,
+                           sizeof(srv_conf->path));
                }
 
                f = SRVFLAG_FCGI|SRVFLAG_NO_FCGI;
index 66c047c..ae4b2b4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: httpd.h,v 1.21 2014/07/31 09:34:57 reyk Exp $ */
+/*     $OpenBSD: httpd.h,v 1.22 2014/07/31 13:28:15 reyk Exp $ */
 
 /*
  * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -277,14 +277,14 @@ SPLAY_HEAD(client_tree, client);
 #define SRVFLAG_NO_INDEX       0x02
 #define SRVFLAG_AUTO_INDEX     0x04
 #define SRVFLAG_NO_AUTO_INDEX  0x08
-#define SRVFLAG_DOCROOT                0x10
+#define SRVFLAG_PATH           0x10
 #define SRVFLAG_LOCATION       0x20
 #define SRVFLAG_FCGI           0x40
 #define SRVFLAG_NO_FCGI                0x80
 
 #define SRVFLAG_BITS                                           \
        "\10\01INDEX\02NO_INDEX\03AUTO_INDEX\04NO_AUTO_INDEX"   \
-       "\05LOCATION\06FCGI\07NO_FCGI"
+       "\05PATH\06LOCATION\07FCGI\10NO_FCGI"
 
 #define TCPFLAG_NODELAY                0x01
 #define TCPFLAG_NNODELAY       0x02
@@ -303,9 +303,9 @@ SPLAY_HEAD(client_tree, client);
 struct server_config {
        u_int32_t                id;
        char                     name[MAXHOSTNAMELEN];
-       char                     docroot[MAXPATHLEN];
-       char                     index[NAME_MAX];
        char                     location[NAME_MAX];
+       char                     index[NAME_MAX];
+       char                     path[MAXPATHLEN];
 
        in_port_t                port;
        struct sockaddr_storage  ss;
index 253664b..905c777 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: parse.y,v 1.11 2014/07/31 09:34:57 reyk Exp $ */
+/*     $OpenBSD: parse.y,v 1.12 2014/07/31 13:28:15 reyk Exp $ */
 
 /*
  * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -216,8 +216,8 @@ server              : SERVER STRING         {
                        }
                        free($2);
 
-                       strlcpy(s->srv_conf.docroot, HTTPD_DOCROOT,
-                           sizeof(s->srv_conf.docroot));
+                       strlcpy(s->srv_conf.path, HTTPD_DOCROOT,
+                           sizeof(s->srv_conf.path));
                        strlcpy(s->srv_conf.index, HTTPD_INDEX,
                            sizeof(s->srv_conf.index));
                        s->srv_conf.id = ++last_server_id;
@@ -284,15 +284,15 @@ serveroptsl       : LISTEN ON STRING port {
                        host_free(&al);
                }
                | ROOT STRING           {
-                       if (strlcpy(srv->srv_conf.docroot, $2,
-                           sizeof(srv->srv_conf.docroot)) >=
-                           sizeof(srv->srv_conf.docroot)) {
+                       if (strlcpy(srv->srv_conf.path, $2,
+                           sizeof(srv->srv_conf.path)) >=
+                           sizeof(srv->srv_conf.path)) {
                                yyerror("document root too long");
                                free($2);
                                YYERROR;
                        }
                        free($2);
-                       srv->srv_conf.flags |= SRVFLAG_DOCROOT;
+                       srv->srv_conf.flags |= SRVFLAG_PATH;
                }
                | DIRECTORY dirflags
                | DIRECTORY '{' dirflags_l '}'
index 5101d39..e2887af 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: server_file.c,v 1.19 2014/07/30 07:09:38 reyk Exp $   */
+/*     $OpenBSD: server_file.c,v 1.20 2014/07/31 13:28:15 reyk Exp $   */
 
 /*
  * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -149,7 +149,7 @@ server_file(struct httpd *env, struct client *clt)
 
        /* Request path is already canonicalized */
        if ((size_t)snprintf(path, sizeof(path), "%s%s",
-           srv_conf->docroot, desc->http_path) >= sizeof(path)) {
+           srv_conf->path, desc->http_path) >= sizeof(path)) {
                /* Do not echo the uncanonicalized path */
                server_abort_http(clt, 500, desc->http_path);
                return (-1);
@@ -225,7 +225,7 @@ server_file_index(struct httpd *env, struct client *clt)
 
        /* Request path is already canonicalized */
        if ((size_t)snprintf(path, sizeof(path), "%s%s",
-           srv_conf->docroot, desc->http_path) >= sizeof(path))
+           srv_conf->path, desc->http_path) >= sizeof(path))
                goto fail;
 
        /* Now open the file, should be readable or we have another problem */