I proposed the monster mod_cgi/cgid unification backport for 2.4.x, but
wanted to give a bit more context here rather than in STATUS. PR is
here: https://github.com/apache/httpd/pull/209
1) stderr handling is a significant regression in mod_cgid compared to
mod_cgi so it is worth fixing this IMO (PR 54221)
2) we have shipped this patch in Fedora&RHEL for a few years, so I am
quite confident that the file descriptor passing feature works well *on
Linux*. I have no idea how well it works on non-Linux platforms, hence
keeping it opt-in (./configure --enable-cgid-fdpassing).
3) there should be no behaviour changes to mod_cgi or mod_cgid if the
fdpassing feature is not enabled, except where bug fixes to either were
missing and are provided by the unification of common code.
4) because the bulk of the patch is de-duplication, this is a net
reduction in lines of code shipped despite the new fd-passing code.
diffstat:
.github/workflows/linux.yml |8 -
changes-entries/pr54221.txt |3
modules/generators/cgi_common.h | 639
+
modules/generators/config5.m4 | 11 +
modules/generators/mod_cgi.c| 586
modules/generators/mod_cgid.c | 642
+-
6 files changed, 913 insertions(+), 976 deletions(-)
Since the github PR link is a series of patches, attached the complete
patch here as well in case that's preferred for review.
Regards, Joe
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index ddacd4af19..6d4379d165 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -48,11 +48,11 @@ jobs:
- name: Shared MPMs, all-modules
config: --enable-mods-shared=reallyall --enable-mpms-shared=all
#
-
- - name: Event MPM, all-modules, mod_cgid only
-config: --enable-mods-shared=reallyall --with-mpm=event
--disable-cgi
+ - name: Event MPM, all-modules, mod_cgid fdpassing
+config: --enable-mods-shared=reallyall --with-mpm=event
--disable-cgi --enable-cgid-fdpassing
#
-
- - name: Event MPM, all-modules, no CMSG_DATA
-config: --enable-mods-shared=reallyall --with-mpm=event
ac_cv_have_decl_CMSG_DATA=no
+ - name: Event MPM, all-modules, mod_cgid w/o fdpassing
+config: --enable-mods-shared=reallyall --with-mpm=event
--disable-cgi
#
-
- name: Default, all-modules + install
config: --enable-mods-shared=reallyall
diff --git a/changes-entries/pr54221.txt b/changes-entries/pr54221.txt
new file mode 100644
index 00..62b75ea4dd
--- /dev/null
+++ b/changes-entries/pr54221.txt
@@ -0,0 +1,3 @@
+ *) mod_cgid: Optional support for file descriptor passing, fixing
+ error log handling (configure --enable-cgid-fdpassing) on Unix
+ platforms. PR 54221. [Joe Orton]
diff --git a/modules/generators/cgi_common.h b/modules/generators/cgi_common.h
new file mode 100644
index 00..66f9418f21
--- /dev/null
+++ b/modules/generators/cgi_common.h
@@ -0,0 +1,639 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_buckets.h"
+#include "apr_lib.h"
+#include "apr_poll.h"
+
+#define APR_WANT_STRFUNC
+#define APR_WANT_MEMFUNC
+#include "apr_want.h"
+
+#include "httpd.h"
+#include "util_filter.h"
+#include "util_script.h"
+
+static APR_OPTIONAL_FN_TYPE(ap_ssi_get_tag_and_value) *cgi_pfn_gtv;
+static APR_OPTIONAL_FN_TYPE(ap_ssi_parse_string) *cgi_pfn_ps;
+
+/* These functions provided by mod_cgi.c/mod_cgid.c still. */
+static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
+ char *dbuf, const char *sbuf, apr_bucke