From: Joe Orton Date: Tue, 23 Jun 2020 16:39:25 +0000 (+0000) Subject: * modules/generators/mod_cgid.c (cgid_handler): Bail immediately with X-Git-Tag: 2.5.0-alpha2-ci-test-only~1341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=279af56a53bc0e72cd74351ccb536a4f72e8b8a0;p=thirdparty%2Fapache%2Fhttpd.git * modules/generators/mod_cgid.c (cgid_handler): Bail immediately with a 503 response on errors when talking to the daemon. Check the pid returned is not zero. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879119 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/log-message-tags/next-number b/docs/log-message-tags/next-number index 28c21c8c973..9787de6a88c 100644 --- a/docs/log-message-tags/next-number +++ b/docs/log-message-tags/next-number @@ -1 +1 @@ -10245 +10247 diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index 0c50e0487c0..3cde6992159 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -1629,8 +1629,8 @@ static int cgid_handler(request_rec *r) rv = send_req(sd, errpipe_out, r, argv0, env, CGI_REQ); if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01268) - "write to cgi daemon process"); + return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, rv, APLOGNO(10245) + "could not send request to cgi daemon"); } /* The write-end of the pipe is only used by the server, so close @@ -1642,13 +1642,15 @@ static int cgid_handler(request_rec *r) info->r = r; rv = get_cgi_pid(r, conf, &(info->pid)); - if (APR_SUCCESS == rv){ + /* Don't accept zero as a pid here, calling kill(0, SIGTERM) etc + * later is unpleasant. */ + if (rv == APR_SUCCESS && info->pid) { apr_pool_cleanup_register(r->pool, info, - cleanup_script, - apr_pool_cleanup_null); + cleanup_script, apr_pool_cleanup_null); } else { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "error determining cgi PID"); + return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, rv, APLOGNO(10246) + "failed reading PID from cgi daemon"); } /* We are putting the socket discriptor into an apr_file_t so that we can