-/* $OpenBSD: config.c,v 1.9 2014/07/31 13:28:15 reyk Exp $ */
+/* $OpenBSD: config.c,v 1.10 2014/07/31 14:18:38 reyk Exp $ */
/*
* Copyright (c) 2011 - 2014 Reyk Floeter <reyk@openbsd.org>
if ((srv_conf->flags & f) == 0)
srv_conf->flags |= srv->srv_conf.flags & f;
+ f = SRVFLAG_PATH|SRVFLAG_FCGI;
+ if ((srv_conf->flags & f) == SRVFLAG_FCGI) {
+ (void)strlcpy(srv_conf->path,
+ HTTPD_FCGI_SOCKET,
+ sizeof(srv_conf->path));
+ srv_conf->flags |= SRVFLAG_PATH;
+ }
+
f = SRVFLAG_PATH;
if ((srv_conf->flags & f) == 0) {
(void)strlcpy(srv_conf->path,
-.\" $OpenBSD: httpd.conf.5,v 1.11 2014/07/31 09:34:57 reyk Exp $
+.\" $OpenBSD: httpd.conf.5,v 1.12 2014/07/31 14:18:38 reyk Exp $
.\"
.\" Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
.\"
Disable the directory index.
.Nm httpd
will neither display nor generate a directory index.
-.It Oo Ic no Oc Ic fastcgi
+.It Oo Ic no Oc Ic fastcgi Op Ar socket
Enable FastCGI instead of serving files.
+The
+.Ar socket
+is a local path name within the
+.Xr chroot 2
+root directory of
+.Nm httpd
+and defaults to
+.Pa /run/slowcgi.sock .
.It Ic listen on Ar address Ic port Ar number
Set the listen address and port.
.It Ic location Ar path { ... }
-/* $OpenBSD: httpd.h,v 1.22 2014/07/31 13:28:15 reyk Exp $ */
+/* $OpenBSD: httpd.h,v 1.23 2014/07/31 14:18:38 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
#define HTTPD_SERVERNAME "OpenBSD httpd"
#define HTTPD_DOCROOT "/htdocs"
#define HTTPD_INDEX "index.html"
+#define HTTPD_FCGI_SOCKET "/run/slowcgi.sock"
#define FD_RESERVE 5
#define SERVER_MAX_CLIENTS 1024
-/* $OpenBSD: parse.y,v 1.12 2014/07/31 13:28:15 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.13 2014/07/31 14:18:38 reyk Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
%}
%token ALL AUTO DIRECTORY FCGI INDEX LISTEN LOCATION LOG NO ON PORT
-%token PREFORK ROOT SERVER TYPES UPDATES VERBOSE
+%token PREFORK ROOT SERVER SOCKET TYPES UPDATES VERBOSE
%token ERROR INCLUDE
%token <v.string> STRING
%token <v.number> NUMBER
host_free(&al);
}
| ROOT STRING {
+ if (srv->srv_conf.flags & SRVFLAG_FCGI) {
+ yyerror("root conflicts with fastcgi");
+ free($2);
+ YYERROR;
+ }
if (strlcpy(srv->srv_conf.path, $2,
sizeof(srv->srv_conf.path)) >=
sizeof(srv->srv_conf.path)) {
}
| 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;
- }
+ | fastcgi
| LOCATION STRING {
struct server *s;
}
;
+fastcgi : 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;
+ }
+ | FCGI {
+ srv->srv_conf.flags &= ~SRVFLAG_NO_FCGI;
+ srv->srv_conf.flags |= SRVFLAG_FCGI;
+ } '{' fcgiflags_l '}'
+ | FCGI {
+ srv->srv_conf.flags &= ~SRVFLAG_NO_FCGI;
+ srv->srv_conf.flags |= SRVFLAG_FCGI;
+ } fcgiflags
+ ;
+
+fcgiflags_l : fcgiflags comma fcgiflags_l
+ | fcgiflags
+ ;
+
+fcgiflags : SOCKET STRING {
+ if (strlcpy(srv->srv_conf.path, $2,
+ sizeof(srv->srv_conf.path)) >=
+ sizeof(srv->srv_conf.path)) {
+ yyerror("fastcgi socket too long");
+ free($2);
+ YYERROR;
+ }
+ free($2);
+ srv->srv_conf.flags |= SRVFLAG_PATH;
+ }
+ ;
+
dirflags_l : dirflags comma dirflags_l
| dirflags
;
{ "prefork", PREFORK },
{ "root", ROOT },
{ "server", SERVER },
+ { "socket", SOCKET },
{ "types", TYPES },
{ "updates", UPDATES }
};
-/* $OpenBSD: server_fcgi.c,v 1.1 2014/07/31 09:23:53 florian Exp $ */
+/* $OpenBSD: server_fcgi.c,v 1.2 2014/07/31 14:18:38 reyk Exp $ */
/*
* Copyright (c) 2014 Florian Obser <florian@openbsd.org>
bzero(&sun, sizeof(sun));
sun.sun_family = AF_UNIX;
- len = strlcpy(sun.sun_path, "/run/slowcgi.sock", sizeof(sun.sun_path));
+ len = strlcpy(sun.sun_path, srv_conf->path, sizeof(sun.sun_path));
if (len >= sizeof(sun.sun_path)) {
errstr = "socket path to long";
goto fail;