From: Stefan Sperling Subject: gotwebd request logging To: gameoftrees@openbsd.org Date: Thu, 5 Dec 2024 19:25:30 +0100 Make gotwebd log requests at -v verbosity. ok? M gotwebd/gotweb.c | 36+ 0- 1 file changed, 36 insertions(+), 0 deletions(-) commit - 2180e60f1be3368525310f44260dab7eeaa7912a commit + d3abf8cdfa36f35529245a90a832321533ee21c7 blob - 6b604d8770a647fa45b6f3996abc29622426583b blob + 3f70bd7c5da6dfaa38c12d043c1cb2619c2bf8ca --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "got_error.h" #include "got_object.h" @@ -179,6 +180,41 @@ gotweb_process_request(struct request *c) goto err; } + /* Log the request. */ + if (gotwebd_env->gotwebd_verbose > 0) { + char *server_name = NULL; + char *querystring = NULL; + char *document_uri = NULL; + + if (c->server_name[0]) { + if (stravis(&server_name, c->server_name, VIS_SAFE) == -1) { + log_warn("stravis"); + server_name = NULL; + } + } + if (c->querystring[0]) { + if (stravis(&querystring, c->querystring, VIS_SAFE) == -1) { + log_warn("stravis"); + querystring = NULL; + } + } + if (c->document_uri[0]) { + if (stravis(&document_uri, c->document_uri, VIS_SAFE) == -1) { + log_warn("stravis"); + document_uri = NULL; + } + } + + log_info("processing request: server='%s' query='%s' " + "document_uri='%s'\n", + server_name ? server_name : "", + querystring ? querystring : "", + document_uri ? document_uri : ""); + free(server_name); + free(querystring); + free(document_uri); + } + /* * certain actions require a commit id in the querystring. this stops * bad actors from exploiting this by manually manipulating the