From 04ab3ac4460d4988a54df437b392a8ce08214874 Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 2 Sep 2021 13:18:04 +0000 Subject: [PATCH] Stop sending debug logging to syslog (which would then drop it on the floor) all the time. Instead debug logging must be requested with the new -v flag. Problem reported and fix provided by weerd@ --- usr.sbin/slowcgi/slowcgi.8 | 7 +++++-- usr.sbin/slowcgi/slowcgi.c | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/usr.sbin/slowcgi/slowcgi.8 b/usr.sbin/slowcgi/slowcgi.8 index 3d162c93c2c..810984d4897 100644 --- a/usr.sbin/slowcgi/slowcgi.8 +++ b/usr.sbin/slowcgi/slowcgi.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: slowcgi.8,v 1.14 2018/08/13 16:54:50 florian Exp $ +.\" $OpenBSD: slowcgi.8,v 1.15 2021/09/02 13:18:04 florian Exp $ .\" .\" Copyright (c) 2013 Florian Obser .\" @@ -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: August 13 2018 $ +.Dd $Mdocdate: September 2 2021 $ .Dt SLOWCGI 8 .Os .Sh NAME @@ -27,6 +27,7 @@ .Op Fl s Ar socket .Op Fl U Ar user .Op Fl u Ar user +.Op Fl v .Sh DESCRIPTION .Nm is a server which implements the FastCGI Protocol to execute CGI scripts. @@ -90,6 +91,8 @@ instead of default user www and to the home directory of .Ar user . +.It Fl v +Enable more verbose (debug) logging. .El .Sh SEE ALSO .Xr httpd 8 diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c index 56d29d1618d..15cd05c5457 100644 --- a/usr.sbin/slowcgi/slowcgi.c +++ b/usr.sbin/slowcgi/slowcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.60 2021/04/20 07:35:42 claudio Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.61 2021/09/02 13:18:04 florian Exp $ */ /* * Copyright (c) 2013 David Gwynne * Copyright (c) 2013 Florian Obser @@ -260,6 +260,7 @@ usage(void) struct timeval timeout = { TIMEOUT_DEFAULT, 0 }; struct slowcgi_proc slowcgi_proc; int debug = 0; +int verbose = 0; int on = 1; char *fcgi_socket = "/var/www/run/slowcgi.sock"; @@ -292,7 +293,7 @@ main(int argc, char *argv[]) } } - while ((c = getopt(argc, argv, "dp:s:U:u:")) != -1) { + while ((c = getopt(argc, argv, "dp:s:U:u:v")) != -1) { switch (c) { case 'd': debug++; @@ -309,6 +310,9 @@ main(int argc, char *argv[]) case 'u': slowcgi_user = optarg; break; + case 'v': + verbose++; + break; default: usage(); /* NOTREACHED */ @@ -1261,9 +1265,10 @@ syslog_info(const char *fmt, ...) void syslog_debug(const char *fmt, ...) { - va_list ap; - - va_start(ap, fmt); - vsyslog(LOG_DEBUG, fmt, ap); - va_end(ap); + if (verbose > 0) { + va_list ap; + va_start(ap, fmt); + vsyslog(LOG_DEBUG, fmt, ap); + va_end(ap); + } } -- 2.20.1