On 2022-06-09 01:36 -07, Alfred Morgan <[email protected]> wrote:
> I think this got missed on misc@ when I posted on 5/24. I'm now
> reposting here in tech@ with the [PATCH] subject tag.
>
> Index: usr.sbin/slowcgi/slowcgi.8
> ===================================================================
> RCS file: /cvs/src/usr.sbin/slowcgi/slowcgi.8,v
> retrieving revision 1.16
> diff -u -p -r1.16 slowcgi.8
> --- usr.sbin/slowcgi/slowcgi.8 2 Sep 2021 14:14:44 -0000 1.16
> +++ usr.sbin/slowcgi/slowcgi.8 25 May 2022 04:30:18 -0000
> @@ -76,6 +76,10 @@ effectively disables the chroot.
> .It Fl s Ar socket
> Create and bind to alternative local socket at
> .Ar socket .
> +.It Fl t Ar timeout
> +Terminate the CGI script after
> +.Ar timeout
> +seconds instead of the default 120 seconds.
Scripts are not terminated, we intentionally let them running. The
connection to upstream (e.g. httpd) is closed so the client gets a 500
error. But the script keeps running. We were worried that scripts are
not prepared when they suddenly get terminated. Maybe that worry is
unfounded. Anyway, the man page needs better wording.
> .It Fl U Ar user
> Change the owner of
> .Pa /var/www/run/slowcgi.sock
> Index: usr.sbin/slowcgi/slowcgi.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/slowcgi/slowcgi.c,v
> retrieving revision 1.62
> diff -u -p -r1.62 slowcgi.c
> --- usr.sbin/slowcgi/slowcgi.c 2 Sep 2021 14:14:44 -0000 1.62
> +++ usr.sbin/slowcgi/slowcgi.c 25 May 2022 04:30:18 -0000
> @@ -252,7 +252,7 @@ usage(void)
> {
> extern char *__progname;
> fprintf(stderr,
> - "usage: %s [-dv] [-p path] [-s socket] [-U user] [-u user]\n",
> + "usage: %s [-dv] [-p path] [-s socket] [-t timeout] [-U user] [-u
> user]\n",
> __progname);
> exit(1);
> }
> @@ -275,6 +275,7 @@ main(int argc, char *argv[])
> const char *chrootpath = NULL;
> const char *sock_user = SLOWCGI_USER;
> const char *slowcgi_user = SLOWCGI_USER;
> + char *p;
>
> /*
> * Ensure we have fds 0-2 open so that we have no fd overlaps
> @@ -293,7 +294,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++;
> @@ -304,6 +305,11 @@ main(int argc, char *argv[])
> case 's':
> fcgi_socket = optarg;
> break;
> + case 't':
> + timeout.tv_sec = strtoll(optarg, &p, 10);
> + if (*p)
> + errx(1, "illegal timeout -- %s", optarg);
> + break;
please use strtonum(3) and use the idiom from the man page example.
Also as sthen pointed out your MUA mangled the diff.
> case 'U':
> sock_user = optarg;
> break;
>
--
I'm not entirely sure you are real.