-.\" $OpenBSD: slowcgi.8,v 1.16 2021/09/02 14:14:44 jmc Exp $
+.\" $OpenBSD: slowcgi.8,v 1.17 2022/08/06 17:11:36 op Exp $
.\"
.\" Copyright (c) 2013 Florian Obser <florian@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 2 2021 $
+.Dd $Mdocdate: August 6 2022 $
.Dt SLOWCGI 8
.Os
.Sh NAME
.Op Fl dv
.Op Fl p Ar path
.Op Fl s Ar socket
+.Op Fl t Ar timeout
.Op Fl U Ar user
.Op Fl u Ar user
.Sh DESCRIPTION
.It Fl s Ar socket
Create and bind to alternative local socket at
.Ar socket .
+.It Fl t Ar timeout
+Terminate the request after
+.Ar timeout
+seconds instead of the default 120 seconds.
+The CGI script is left to run but its standard input, output and error
+will be closed.
.It Fl U Ar user
Change the owner of
.Pa /var/www/run/slowcgi.sock
-/* $OpenBSD: slowcgi.c,v 1.62 2021/09/02 14:14:44 jmc Exp $ */
+/* $OpenBSD: slowcgi.c,v 1.63 2022/08/06 17:11:36 op Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
* Copyright (c) 2013 Florian Obser <florian@openbsd.org>
#include <unistd.h>
#define TIMEOUT_DEFAULT 120
+#define TIMEOUT_MAX (86400 * 365)
#define SLOWCGI_USER "www"
#define FCGI_CONTENT_SIZE 65535
{
extern char *__progname;
fprintf(stderr,
- "usage: %s [-dv] [-p path] [-s socket] [-U user] [-u user]\n",
- __progname);
+ "usage: %s [-dv] [-p path] [-s socket] [-t timeout] [-U user] "
+ " [-u user]\n", __progname);
exit(1);
}
const char *chrootpath = NULL;
const char *sock_user = SLOWCGI_USER;
const char *slowcgi_user = SLOWCGI_USER;
+ const char *errstr;
/*
* Ensure we have fds 0-2 open so that we have no fd overlaps
}
}
- while ((c = getopt(argc, argv, "dp:s:U:u:v")) != -1) {
+ while ((c = getopt(argc, argv, "dp:s:t:U:u:v")) != -1) {
switch (c) {
case 'd':
debug++;
case 's':
fcgi_socket = optarg;
break;
+ case 't':
+ timeout.tv_sec = strtonum(optarg, 1, TIMEOUT_MAX,
+ &errstr);
+ if (errstr != NULL)
+ errx(1, "timeout is %s: %s", errstr, optarg);
+ break;
case 'U':
sock_user = optarg;
break;