summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2014-07-31 09:34:58 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2014-07-31 09:34:58 +0000
commit8c1b33a78cf3a28b10a20765091caa036f177778 (patch)
tree80c1ce02a4a131622d9a5d65a11bba3d41574773 /usr.sbin
parentbc45001cf4e743164a676f113a28ae6a97825012 (diff)
Add a configuration variable "fastcgi" to enable it per server or location.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/httpd/config.c6
-rw-r--r--usr.sbin/httpd/httpd.conf.56
-rw-r--r--usr.sbin/httpd/httpd.h7
-rw-r--r--usr.sbin/httpd/parse.y15
-rw-r--r--usr.sbin/httpd/server_http.c17
5 files changed, 34 insertions, 17 deletions
diff --git a/usr.sbin/httpd/config.c b/usr.sbin/httpd/config.c
index 44cd419565f..cc8060f313c 100644
--- a/usr.sbin/httpd/config.c
+++ b/usr.sbin/httpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.7 2014/07/30 13:49:48 reyk Exp $ */
+/* $OpenBSD: config.c,v 1.8 2014/07/31 09:34:57 reyk Exp $ */
/*
* Copyright (c) 2011 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -245,6 +245,10 @@ config_getserver_config(struct httpd *env, struct server *srv,
sizeof(srv_conf->docroot));
}
+ f = SRVFLAG_FCGI|SRVFLAG_NO_FCGI;
+ if ((srv_conf->flags & f) == 0)
+ srv_conf->flags |= srv->srv_conf.flags & f;
+
DPRINTF("%s: %s %d received location \"%s\", parent \"%s\"",
__func__, ps->ps_title[privsep_process], ps->ps_instance,
srv_conf->location, srv->srv_conf.name);
diff --git a/usr.sbin/httpd/httpd.conf.5 b/usr.sbin/httpd/httpd.conf.5
index 9c056da7485..7cd03a8e84d 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.10 2014/07/30 10:05:14 reyk Exp $
+.\" $OpenBSD: httpd.conf.5,v 1.11 2014/07/31 09:34:57 reyk Exp $
.\"
.\" Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
.\"
@@ -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 30 2014 $
+.Dd $Mdocdate: July 31 2014 $
.Dt HTTPD.CONF 5
.Os
.Sh NAME
@@ -128,6 +128,8 @@ If not specified, it defaults to
Disable the directory index.
.Nm httpd
will neither display nor generate a directory index.
+.It Oo Ic no Oc Ic fastcgi
+Enable FastCGI instead of serving files.
.It Ic listen on Ar address Ic port Ar number
Set the listen address and port.
.It Ic location Ar path { ... }
diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h
index 852a93fd596..66c047ca64b 100644
--- a/usr.sbin/httpd/httpd.h
+++ b/usr.sbin/httpd/httpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.h,v 1.20 2014/07/31 09:23:53 florian Exp $ */
+/* $OpenBSD: httpd.h,v 1.21 2014/07/31 09:34:57 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -279,9 +279,12 @@ SPLAY_HEAD(client_tree, client);
#define SRVFLAG_NO_AUTO_INDEX 0x08
#define SRVFLAG_DOCROOT 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"
+ "\10\01INDEX\02NO_INDEX\03AUTO_INDEX\04NO_AUTO_INDEX" \
+ "\05LOCATION\06FCGI\07NO_FCGI"
#define TCPFLAG_NODELAY 0x01
#define TCPFLAG_NNODELAY 0x02
diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y
index 3947f710cd5..253664b98f8 100644
--- a/usr.sbin/httpd/parse.y
+++ b/usr.sbin/httpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.10 2014/07/30 13:49:48 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.11 2014/07/31 09:34:57 reyk Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -126,8 +126,8 @@ typedef struct {
%}
-%token ALL AUTO DIRECTORY INDEX LISTEN LOCATION LOG NO ON PORT PREFORK ROOT
-%token SERVER TYPES UPDATES VERBOSE
+%token ALL AUTO DIRECTORY FCGI INDEX LISTEN LOCATION LOG NO ON PORT
+%token PREFORK ROOT SERVER TYPES UPDATES VERBOSE
%token ERROR INCLUDE
%token <v.string> STRING
%token <v.number> NUMBER
@@ -296,6 +296,14 @@ serveroptsl : LISTEN ON STRING port {
}
| DIRECTORY dirflags
| DIRECTORY '{' dirflags_l '}'
+ | NO FCGI {
+ srv->srv_conf.flags &= ~SRVFLAG_FCGI;
+ srv->srv_conf.flags |= SRVFLAG_NO_FCGI;
+ }
+ | FCGI {
+ srv->srv_conf.flags &= ~SRVFLAG_NO_FCGI;
+ srv->srv_conf.flags |= SRVFLAG_FCGI;
+ }
| LOCATION STRING {
struct server *s;
@@ -535,6 +543,7 @@ lookup(char *s)
{ "all", ALL },
{ "auto", AUTO },
{ "directory", DIRECTORY },
+ { "fastcgi", FCGI },
{ "include", INCLUDE },
{ "index", INDEX },
{ "listen", LISTEN },
diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c
index da60d15ab99..3eff410c891 100644
--- a/usr.sbin/httpd/server_http.c
+++ b/usr.sbin/httpd/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.22 2014/07/31 09:23:53 florian Exp $ */
+/* $OpenBSD: server_http.c,v 1.23 2014/07/31 09:34:57 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -748,18 +748,17 @@ server_response(struct httpd *httpd, struct client *clt)
fnmatch(location->location, desc->http_path,
FNM_CASEFOLD) == 0) {
/* Replace host configuration */
- clt->clt_srv_conf = location;
- srv_conf = NULL;
+ clt->clt_srv_conf = srv_conf = location;
break;
}
}
- if (strlen(desc->http_path) > strlen("/cgi-bin/") &&
- strncmp("/cgi-bin/", desc->http_path, strlen("/cgi-bin/")) == 0) {
- if ((ret = server_fcgi(httpd, clt)) == -1)
- return (-1);
- } else if ((ret = server_file(httpd, clt)) == -1)
- return (-1);
+ if (srv_conf->flags & SRVFLAG_FCGI)
+ ret = server_fcgi(httpd, clt);
+ else
+ ret = server_file(httpd, clt);
+ if (ret == -1)
+ return (ret);
server_reset_http(clt);