aboutsummaryrefslogtreecommitdiffstats
path: root/slowcgi.c
diff options
context:
space:
mode:
authorop2022-08-06 17:11:36 +0000
committerWolfgang Müller2023-10-12 12:08:43 +0200
commit0917ae22bc82c991d38a66222846c31ee0d6692d (patch)
tree7eaaf4b66e493aa8acc43cadf20d99fe8567343c /slowcgi.c
parent0be49518a018ea21d92535f2813c70419e16bbfa (diff)
downloadslowcgi-0917ae22bc82c991d38a66222846c31ee0d6692d.tar.gz
add a -t flag to change the request timeout
original diff from Alfred Morgan (alfred [at] 54 dot org) ok florian@ and manpage tweaks by me.
Diffstat (limited to '')
-rw-r--r--slowcgi.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/slowcgi.c b/slowcgi.c
index 9999ac8..fc0e596 100644
--- a/slowcgi.c
+++ b/slowcgi.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -48,6 +48,14 @@
size_t strlcpy(char *, const char *, size_t);
#endif
+#ifdef strtonum
+#define HAVE_STRTONUM
+#else
+long long
+strtonum(const char *numstr, long long minval, long long maxval,
+ const char **errstrp);
+#endif
+
#ifndef __packed
#define __packed __attribute__((packed))
#endif
@@ -57,6 +65,7 @@ size_t strlcpy(char *, const char *, size_t);
#endif
#define TIMEOUT_DEFAULT 120
+#define TIMEOUT_MAX (86400 * 365)
#define SLOWCGI_USER "www"
#define FCGI_CONTENT_SIZE 65535
@@ -269,8 +278,8 @@ usage(void)
{
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);
}
@@ -292,6 +301,7 @@ main(int argc, char *argv[])
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
@@ -310,7 +320,7 @@ main(int argc, char *argv[])
}
}
- 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++;
@@ -321,6 +331,12 @@ main(int argc, char *argv[])
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;