]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* modules/generators/mod_cgid.c (cgid_handler): Bail immediately with
authorJoe Orton <jorton@apache.org>
Tue, 23 Jun 2020 16:39:25 +0000 (16:39 +0000)
committerJoe Orton <jorton@apache.org>
Tue, 23 Jun 2020 16:39:25 +0000 (16:39 +0000)
  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

docs/log-message-tags/next-number
modules/generators/mod_cgid.c

index 28c21c8c973abdcd0a97315f3a37a966bafee3ad..9787de6a88cf078089ef01216fb04842081e726a 100644 (file)
@@ -1 +1 @@
-10245
+10247
index 0c50e0487c0b3afd163bf1ea45289f71b25a79c1..3cde6992159e6f4ca477c0aedae0b1ebb68b924f 100644 (file)
@@ -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