From 5e6ebf2888ce12584ed74b77cc408a7b0da3b66e Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Wed, 6 Aug 2014 21:08:48 +0000 Subject: Write STDERR from the CGI to the web server error log as intended. OK florian@ --- usr.sbin/httpd/server_fcgi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'usr.sbin') diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c index 3d16a6c7793..eaa7590872f 100644 --- a/usr.sbin/httpd/server_fcgi.c +++ b/usr.sbin/httpd/server_fcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_fcgi.c,v 1.26 2014/08/06 20:56:23 florian Exp $ */ +/* $OpenBSD: server_fcgi.c,v 1.27 2014/08/06 21:08:47 reyk Exp $ */ /* * Copyright (c) 2014 Florian Obser @@ -440,6 +440,7 @@ server_fcgi_read(struct bufferevent *bev, void *arg) struct client *clt = (struct client *) arg; struct fcgi_record_header *h; size_t len; + char *ptr; do { len = bufferevent_read(bev, &buf, clt->clt_fcgi_toread); @@ -476,6 +477,16 @@ server_fcgi_read(struct bufferevent *bev, void *arg) /* fallthrough if content_len == 0 */ case FCGI_READ_CONTENT: + if (clt->clt_fcgi_type == FCGI_STDERR && len) { + if ((ptr = get_string( + EVBUFFER_DATA(clt->clt_srvevb), + EVBUFFER_LENGTH(clt->clt_srvevb))) + != NULL) { + server_sendlog(clt->clt_srv_conf, + IMSG_LOG_ERROR, "%s", ptr); + free(ptr); + } + } if (clt->clt_fcgi_type == FCGI_STDOUT && EVBUFFER_LENGTH(clt->clt_srvevb) > 0) { if (++clt->clt_chunk == 1) -- cgit v1.2.3