sync from c9s

switch to using anonymous shm by default
  Resolves: RHEL-50029
This commit is contained in:
Joe Orton 2024-07-22 13:45:13 +01:00
parent a30e53a5c7
commit a3f1cf806f
9 changed files with 307 additions and 65 deletions

View File

@ -1,8 +0,0 @@
--- mod_fcgid-2.3.4/build/fixconf.sed 2009-10-07 04:16:08.000000000 +0100
+++ mod_fcgid-2.3.4/build/fixconf.sed 2009-10-12 09:50:14.570448865 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/sed -f
+#!/bin/sed -f
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with

View File

@ -0,0 +1,13 @@
diff --git a/modules/fcgid/fcgid_conf.h b/modules/fcgid/fcgid_conf.h
index 47d68bb..44da00e 100644
--- a/modules/fcgid/fcgid_conf.h
+++ b/modules/fcgid/fcgid_conf.h
@@ -139,7 +139,7 @@ typedef struct {
*/
#define INITENV_KEY_LEN 64
#define INITENV_VAL_LEN 256
-#define INITENV_CNT 64
+#define INITENV_CNT 1024
typedef struct {
char initenv_key[INITENV_CNT][INITENV_KEY_LEN];
char initenv_val[INITENV_CNT][INITENV_VAL_LEN];

View File

@ -0,0 +1,16 @@
# ./pullrev.sh 1847623
http://svn.apache.org/viewvc?view=revision&revision=1847623
https://bugzilla.redhat.com/show_bug.cgi?id=1651310
--- mod_fcgid-2.3.9/modules/fcgid/fcgid_conf.h
+++ mod_fcgid-2.3.9/modules/fcgid/fcgid_conf.h
@@ -138,7 +138,7 @@
* to limit shared memory use
*/
#define INITENV_KEY_LEN 64
-#define INITENV_VAL_LEN 128
+#define INITENV_VAL_LEN 256
#define INITENV_CNT 64
typedef struct {
char initenv_key[INITENV_CNT][INITENV_KEY_LEN];

View File

@ -0,0 +1,119 @@
# ./pullrev.sh 1847624
http://svn.apache.org/viewvc?view=revision&revision=1847624
https://bugzilla.redhat.com/show_bug.cgi?id=1654200
--- mod_fcgid-2.3.9/modules/fcgid/fcgid_proc_unix.c
+++ mod_fcgid-2.3.9/modules/fcgid/fcgid_proc_unix.c
@@ -762,14 +762,18 @@
struct iovec vec[FCGID_VEC_COUNT];
int nvec = 0;
apr_bucket *e;
+ apr_bucket_brigade *tmpbb = apr_brigade_create(output_brigade->p,
+ output_brigade->bucket_alloc);
- for (e = APR_BRIGADE_FIRST(output_brigade);
- e != APR_BRIGADE_SENTINEL(output_brigade);
- e = APR_BUCKET_NEXT(e)) {
+ while (!APR_BRIGADE_EMPTY(output_brigade))
+ {
+ e = APR_BRIGADE_FIRST(output_brigade);
+
apr_size_t len;
const char* base;
if (APR_BUCKET_IS_METADATA(e)) {
+ apr_bucket_delete(e);
continue;
}
@@ -780,6 +784,9 @@
return rv;
}
+ APR_BUCKET_REMOVE(e);
+ APR_BRIGADE_INSERT_TAIL(tmpbb, e);
+
vec[nvec].iov_len = len;
vec[nvec].iov_base = (char*) base;
if (nvec == (FCGID_VEC_COUNT - 1)) {
@@ -789,6 +796,7 @@
FCGID_VEC_COUNT)) != APR_SUCCESS)
return rv;
nvec = 0;
+ apr_brigade_cleanup(tmpbb);
}
else
nvec++;
@@ -800,6 +808,7 @@
return rv;
}
+ apr_brigade_destroy(tmpbb);
return APR_SUCCESS;
}
--- mod_fcgid-2.3.9/modules/fcgid/fcgid_proc_win.c
+++ mod_fcgid-2.3.9/modules/fcgid/fcgid_proc_win.c
@@ -380,19 +380,22 @@
apr_bucket *bucket_request;
apr_status_t rv;
DWORD transferred;
+ apr_bucket_brigade *tmpbb = apr_brigade_create(birgade_send->p,
+ birgade_send->bucket_alloc);
handle_info = (fcgid_namedpipe_handle *) ipc_handle->ipc_handle_info;
- for (bucket_request = APR_BRIGADE_FIRST(birgade_send);
- bucket_request != APR_BRIGADE_SENTINEL(birgade_send);
- bucket_request = APR_BUCKET_NEXT(bucket_request))
- {
+ while (!APR_BRIGADE_EMPTY(birgade_send)) {
const char *write_buf;
apr_size_t write_buf_len;
apr_size_t has_write;
- if (APR_BUCKET_IS_METADATA(bucket_request))
+ bucket_request = APR_BRIGADE_FIRST(birgade_send);
+
+ if (APR_BUCKET_IS_METADATA(bucket_request)) {
+ apr_bucket_delete(bucket_request);
continue;
+ }
if ((rv = apr_bucket_read(bucket_request, &write_buf, &write_buf_len,
APR_BLOCK_READ)) != APR_SUCCESS) {
@@ -401,6 +404,9 @@
return rv;
}
+ APR_BUCKET_REMOVE(bucket_request);
+ APR_BRIGADE_INSERT_TAIL(tmpbb, bucket_request);
+
/* Write the buffer to fastcgi server */
has_write = 0;
while (has_write < write_buf_len) {
@@ -411,6 +417,7 @@
write_buf_len - has_write,
&byteswrite, &handle_info->overlap_write)) {
has_write += byteswrite;
+ apr_brigade_cleanup(tmpbb);
continue;
} else if ((rv = GetLastError()) != ERROR_IO_PENDING) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING,
@@ -437,6 +444,7 @@
return APR_ESPIPE;
}
has_write += transferred;
+ apr_brigade_cleanup(tmpbb);
continue;
} else {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0,
@@ -448,6 +456,7 @@
}
}
+ apr_brigade_destroy(tmpbb);
return APR_SUCCESS;
}

View File

@ -0,0 +1,40 @@
# ./pullrev.sh 1848311
http://svn.apache.org/viewvc?view=revision&revision=1848311
https://bugzilla.redhat.com/show_bug.cgi?id=1655035
--- mod_fcgid-2.3.9/modules/fcgid/config.m4
+++ mod_fcgid-2.3.9/modules/fcgid/config.m4
@@ -43,6 +43,11 @@
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_HEADERS(sys/mutex.h)
AC_CHECK_HEADERS(sys/shm.h)
+ if test "x$enable_fcgid" = "xshared"; then
+ # The only symbol which needs to be exported is the module
+ # structure, so ask libtool to hide everything else:
+ APR_ADDTO(MOD_FCGID_LDADD, [-export-symbols-regex fcgid_module])
+ fi
])
dnl # end of module specific part
--- mod_fcgid-2.3.9/modules/fcgid/Makefile.apxs
+++ mod_fcgid-2.3.9/modules/fcgid/Makefile.apxs
@@ -16,6 +16,7 @@
builddir=.
srcdir=.
+MOD_FCGID_LDADD = -export-symbols-regex fcgid_module
CLEAN_TARGETS = *.loT
include $(exp_installbuilddir)/special.mk
--- mod_fcgid-2.3.9/modules/fcgid/modules.mk.apxs
+++ mod_fcgid-2.3.9/modules/fcgid/modules.mk.apxs
@@ -17,7 +17,7 @@
# this is used/needed by the APACHE2 build system
#
mod_fcgid.la: mod_fcgid.slo fcgid_bridge.slo fcgid_conf.slo fcgid_pm_main.slo fcgid_protocol.slo fcgid_spawn_ctl.slo fcgid_proctbl_unix.slo fcgid_pm_unix.slo fcgid_proc_unix.slo fcgid_bucket.slo fcgid_filter.slo fcgid_mutex_unix.slo
- $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_fcgid.lo fcgid_bridge.lo fcgid_conf.lo fcgid_pm_main.lo fcgid_protocol.lo fcgid_spawn_ctl.lo fcgid_proctbl_unix.lo fcgid_pm_unix.lo fcgid_proc_unix.lo fcgid_bucket.lo fcgid_filter.lo fcgid_mutex_unix.lo
+ $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_fcgid.lo fcgid_bridge.lo fcgid_conf.lo fcgid_pm_main.lo fcgid_protocol.lo fcgid_spawn_ctl.lo fcgid_proctbl_unix.lo fcgid_pm_unix.lo fcgid_proc_unix.lo fcgid_bucket.lo fcgid_filter.lo fcgid_mutex_unix.lo $(MOD_FCGID_LDADD)
DISTCLEAN_TARGETS = modules.mk
static =
shared = mod_fcgid.la

View File

@ -0,0 +1,40 @@
# ./pullrev.sh 1919454
http://svn.apache.org/viewvc?view=revision&revision=1919454
https://issues.redhat.com/browse/RHEL-50029
only in patch2:
--- mod_fcgid-2.3.9/modules/fcgid/fcgid_proctbl_unix.c
+++ mod_fcgid-2.3.9/modules/fcgid/fcgid_proctbl_unix.c
@@ -136,18 +136,23 @@
fcgid_server_conf *sconf = ap_get_module_config(main_server->module_config,
&fcgid_module);
- /* Remove share memory first */
+ /* Use anonymous SHM segment by default, fall back to name-based. */
+ if ((rv = apr_shm_create(&g_sharemem, shmem_size, NULL,
+ main_server->process->pconf)) != APR_SUCCESS) {
+ /* Remove any existing segment first, ignore errors. */
apr_shm_remove(sconf->shmname_path, main_server->process->pconf);
- /* Create share memory */
- if ((rv = apr_shm_create(&g_sharemem, shmem_size, sconf->shmname_path,
- main_server->process->pconf)) != APR_SUCCESS)
- {
+ rv = apr_shm_create(&g_sharemem, shmem_size, sconf->shmname_path,
+ main_server->process->pconf);
+ if (rv) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
- "mod_fcgid: Can't create shared memory for size %" APR_SIZE_T_FMT " bytes",
- shmem_size);
- exit(1);
+ "mod_fcgid: Can't create shared memory either "
+ "anonymous or at %s, for size %" APR_SIZE_T_FMT " bytes",
+ sconf->shmname_path, shmem_size);
+ return rv;
}
+ }
+
_global_memory = apr_shm_baseaddr_get(g_sharemem);
/* Create global mutex */

View File

@ -1,49 +0,0 @@
diff --git a/modules/fcgid/fcgid_proc_unix.c b/modules/fcgid/fcgid_proc_unix.c
index 218f3f7..8b69a89 100644
--- a/modules/fcgid/fcgid_proc_unix.c
+++ b/modules/fcgid/fcgid_proc_unix.c
@@ -762,14 +762,15 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
struct iovec vec[FCGID_VEC_COUNT];
int nvec = 0;
apr_bucket *e;
+ apr_bucket_brigade* tmpbb = apr_brigade_create(output_brigade->p,output_brigade->bucket_alloc);
- for (e = APR_BRIGADE_FIRST(output_brigade);
- e != APR_BRIGADE_SENTINEL(output_brigade);
- e = APR_BUCKET_NEXT(e)) {
+ while (!APR_BRIGADE_EMPTY(output_brigade)) {
+ e = APR_BRIGADE_FIRST(output_brigade);
apr_size_t len;
const char* base;
if (APR_BUCKET_IS_METADATA(e)) {
+ apr_bucket_delete(e);
continue;
}
@@ -780,6 +781,9 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
return rv;
}
+ APR_BUCKET_REMOVE(e);
+ APR_BRIGADE_INSERT_TAIL(tmpbb, e);
+
vec[nvec].iov_len = len;
vec[nvec].iov_base = (char*) base;
if (nvec == (FCGID_VEC_COUNT - 1)) {
@@ -789,6 +793,7 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
FCGID_VEC_COUNT)) != APR_SUCCESS)
return rv;
nvec = 0;
+ apr_brigade_cleanup(tmpbb);
}
else
nvec++;
@@ -800,6 +805,7 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
return rv;
}
+ apr_brigade_destroy(tmpbb);
return APR_SUCCESS;
}

View File

@ -1,6 +1,6 @@
Name: mod_fcgid
Version: 2.3.9
Release: 33%{?dist}
Release: 34%{?dist}
Summary: FastCGI interface module for Apache 2
License: Apache-2.0
URL: http://httpd.apache.org/mod_fcgid/
@ -9,9 +9,12 @@ Source2: mod_fcgid-2.1-README.RPM
Source3: mod_fcgid-2.1-README.SELinux
Source4: mod_fcgid-tmpfs.conf
Source5: fcgid24.conf
Patch0: mod_fcgid-2.3.4-fixconf-shellbang.patch
Patch1: mod_fcgid-2.3.9-segfault-upload.patch
Patch2: mod_fcgid-2.3.9-r1848298.patch
Patch0: mod_fcgid-2.3.9-r1847623.patch
Patch1: mod_fcgid-2.3.9-1024-env-vars.patch
Patch2: mod_fcgid-2.3.9-r1847624.patch
Patch3: mod_fcgid-2.3.9-r1848298.patch
Patch4: mod_fcgid-2.3.9-r1848311.patch
Patch5: mod_fcgid-2.3.9-r1919454.patch
BuildRequires: coreutils
BuildRequires: gcc
BuildRequires: httpd-devel >= 2.4
@ -35,7 +38,8 @@ the number of fastcgi servers, and kicking out corrupt fastcgi servers as soon
as possible.
%prep
%setup -q
%autosetup -p1 -S gendiff
cp -p %{SOURCE2} README.RPM
cp -p %{SOURCE3} README.SELinux
cp -p %{SOURCE5} fcgid24.conf
@ -45,9 +49,6 @@ cp -p %{SOURCE5} fcgid24.conf
%patch0 -p1
%endif
%patch1 -p1 -b .segfault_upload
%patch2 -p1 -b .r1848298
%build
APXS=%{_httpd_apxs} ./configure.apxs
make
@ -80,6 +81,11 @@ install -p -m 644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/mod_fcgid.conf
%dir %attr(0775,root,apache) /run/mod_fcgid/
%changelog
* Mon Jul 22 2024 Joe Orton <jorton@redhat.com> - 2.3.9-34
- sync from c9s
- switch to using anonymous shm by default
Resolves: RHEL-50029
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 2.3.9-33
- Bump release for June 2024 mass rebuild

65
pullrev.sh Executable file
View File

@ -0,0 +1,65 @@
#!/bin/sh -e
if [ $# -lt 1 ]; then
echo "What?"
exit 1
fi
repo="https://svn.apache.org/repos/asf/httpd/mod_fcgid/trunk"
#repo="https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x"
ver=2.3.9
prefix="mod_fcgid-${ver}"
suffix="${SUFFIX:-r$1${2:++}}"
fn="${prefix}-${suffix}.patch"
vcurl="http://svn.apache.org/viewvc?view=revision&revision="
if test -f ${fn}; then
mv -v -f ${fn} ${fn}\~
echo "# $0 $*" > ${fn}
sed '1{/#.*pullrev/d;};/^--- /,$d' < ${fn}\~ >> ${fn}
else
echo "# $0 $*" > ${fn}
fi
new=0
for r in $*; do
case $r in
http*) url=$r ;;
*) url=${vcurl}${r} ;;
esac
if ! grep -q "^${url}" ${fn}; then
echo "${url}"
new=1
fi
done >> ${fn}
[ $new -eq 0 ] || echo >> ${fn}
prev=/dev/null
for r in $*; do
echo "+ fetching ${r}"
this=`mktemp /tmp/pullrevXXXXXX`
case $r in
http*) curl -s "$r" | filterdiff --strip=3 ;;
*) svn diff -c ${r} ${repo} ;;
esac | filterdiff --remove-timestamps --clean \
-x 'CHANGES' -x 'changes-entries/*.txt' -x '*/next-number' -x 'STATUS' -x '*.xml' \
--addprefix="${prefix}/" > ${this}
next=`mktemp /tmp/pullrevXXXXXX`
if ! combinediff -w ${prev} ${this} > ${next}; then
echo "Failed combining previous ${prev} with ${this}";
exit 1
fi
rm -f "${this}"
[ "${prev}" = "/dev/null" ] || rm -f "${prev}"
prev=${next}
done
cat ${prev} >> ${fn}
vi "${fn}"
echo "+ git add ${fn}"
git add "${fn}"
echo "+ spec template:"
echo "PatchN: ${fn}"
echo "%patchN -p1 -b .${suffix}"