Skip to content

Commit fc5bc89

Browse files
committed
[civetweb] download from GIT instead of bundle and define proper CMake target, and bump from 1.16+ to latest master
and define proper CMake target [ci] explicit enable in alma10clang-ninja even if it was getting on implicitly fixes for SSL disable SSL dynamic loading fix openssl include fix builtin ssl name rename builtin name and copy-paste additional variables from xrootd to civetweb avoid cache vars [net] document civetweb builtin mechanism and version link [civetweb] add patches after 1.16 that solve several CVE detect if websockets component is part of systemwide civetweb [cmake] do not error out if build dir is git dir from willcern Create civetweb-marker.diff xdom socket missing in ubu packages see root-project/root-ci-images#116 (comment) enable builtin civetweb on mac and windows since no system version
1 parent 1e9e7d3 commit fc5bc89

31 files changed

Lines changed: 367 additions & 29005 deletions

.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CMAKE_C_COMPILER=clang
22
CMAKE_CXX_COMPILER=clang++
33
CMAKE_GENERATOR=Ninja
4+
builtin_civetweb=ON
45
builtin_fftw3=ON
56
builtin_freetype=ON
67
builtin_ftgl=ON

.github/workflows/root-ci-config/buildconfig/mac-beta.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CMAKE_CXX_STANDARD=23
22
builtin_cfitsio=ON
3+
builtin_civetweb=ON
34
builtin_fftw3=ON
45
builtin_freetype=ON
56
builtin_ftgl=ON

.github/workflows/root-ci-config/buildconfig/mac14.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ROOT_CTEST_CUSTOM_FLAGS="-E ^tutorial-"
22
asimage_tiff=OFF
33
builtin_cfitsio=ON
4+
builtin_civetweb=ON
45
builtin_fftw3=ON
56
builtin_freetype=ON
67
builtin_ftgl=ON

.github/workflows/root-ci-config/buildconfig/mac15.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
builtin_cfitsio=ON
2+
builtin_civetweb=ON
23
builtin_fftw3=ON
34
builtin_freetype=ON
45
builtin_ftgl=ON

.github/workflows/root-ci-config/buildconfig/mac26.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CMAKE_CXX_STANDARD=23
22
builtin_cfitsio=ON
3+
builtin_civetweb=ON
34
builtin_fftw3=ON
45
builtin_freetype=ON
56
builtin_ftgl=ON

.github/workflows/root-ci-config/buildconfig/windows10.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
asimage_tiff=OFF
22
builtin_cfitsio=ON
3+
builtin_civetweb=ON
34
builtin_freetype=ON
45
builtin_ftgl=ON
56
builtin_gif=ON

builtins/civetweb/1385.patch

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 79077517e3d4ee648f47af12215dc1cf10e230a5 Mon Sep 17 00:00:00 2001
2+
From: "V.Shkriabets" <vshcryabets@gmail.com>
3+
Date: Wed, 22 Apr 2026 16:14:18 +0300
4+
Subject: [PATCH] Fixed old variable names
5+
6+
---
7+
src/civetweb.c | 14 +++++++-------
8+
1 file changed, 7 insertions(+), 7 deletions(-)
9+
10+
diff --git a/src/civetweb.c b/src/civetweb.c
11+
index f6a60e214..006fa7a2b 100644
12+
--- a/src/civetweb.c
13+
+++ b/src/civetweb.c
14+
@@ -19201,15 +19201,15 @@ get_request(struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err)
15+
conn->accept_gzip = 1;
16+
}
17+
#endif
18+
- h_chunk = get_header(conn->request_info.http_headers,
19+
+ h_chunk = get_header(conn->request_info.http_headers,
20+
conn->request_info.num_headers,
21+
"Transfer-Encoding");
22+
- h_len = get_header(conn->request_info.http_headers,
23+
+ h_len = get_header(conn->request_info.http_headers,
24+
conn->request_info.num_headers,
25+
"Content-Length");
26+
- if (h_chunk != NULL)
27+
- && mg_strcasecmp(cl, "identity")) {
28+
- if ((0!=mg_strcasecmp(cl, "chunked")) || (h_len!=NULL)) {
29+
+ if ((h_chunk != NULL)
30+
+ && mg_strcasecmp(h_chunk, "identity")) {
31+
+ if ((0!=mg_strcasecmp(h_chunk, "chunked")) || (h_len!=NULL)) {
32+
mg_snprintf(conn,
33+
NULL, /* No truncation check for ebuf */
34+
ebuf,
35+
@@ -19224,8 +19224,8 @@ get_request(struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err)
36+
} else if (h_len != NULL) {
37+
/* Request has content length set */
38+
char *endptr = NULL;
39+
- conn->content_len = strtoll(cl, &endptr, 10);
40+
- if ((endptr == cl) || (conn->content_len < 0)) {
41+
+ conn->content_len = strtoll(h_len, &endptr, 10);
42+
+ if ((endptr == h_len) || (conn->content_len < 0)) {
43+
mg_snprintf(conn,
44+
NULL, /* No truncation check for ebuf */
45+
ebuf,

builtins/civetweb/1389.patch

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From b8f93aafd3229fff5acea786b74b573202b169f3 Mon Sep 17 00:00:00 2001
2+
From: ferdymercury <ferdymercury@users.noreply.github.com>
3+
Date: Mon, 27 Apr 2026 12:13:45 +0200
4+
Subject: [PATCH] Only include deprecated header when really necessary
5+
6+
deprecated ENGINE API is only used #if !defined(OPENSSL_API_1_1) && !defined(OPENSSL_API_3_0)
7+
---
8+
src/civetweb.c | 5 ++++-
9+
1 file changed, 4 insertions(+), 1 deletion(-)
10+
11+
diff --git a/src/civetweb.c b/src/civetweb.c
12+
index f6a60e214..ecbd1a8a4 100644
13+
--- a/src/civetweb.c
14+
+++ b/src/civetweb.c
15+
@@ -1797,7 +1797,10 @@ typedef struct SSL_CTX SSL_CTX;
16+
#include <openssl/conf.h>
17+
#include <openssl/crypto.h>
18+
#include <openssl/dh.h>
19+
-#include <openssl/engine.h>
20+
+
21+
+#if defined(OPENSSL_API_1_0)
22+
+#include <openssl/engine.h> // deprecated later on
23+
+#endif
24+
#include <openssl/err.h>
25+
#include <openssl/opensslv.h>
26+
#include <openssl/pem.h>

builtins/civetweb/CMakeLists.txt

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.
2+
# All rights reserved.
3+
#
4+
# For the licensing terms see $ROOTSYS/LICENSE.
5+
# For the list of contributors see $ROOTSYS/README/CREDITS.
6+
7+
# **PLEASE UPDATE ALSO THE FOLLOWING LINE WHEN UPDATING THE VERSION**
8+
# 10 Apr 2023, https://github.com/civetweb/civetweb/releases/tag/v1.16
9+
set(ROOT_CIVETWEB_VERSION 1.16) # with some patches, so almost 1.17
10+
# set(ROOT_CIVETWEB_HASH "f0e471c1bf4e7804a6cfb41ea9d13e7d623b2bcc7bc1e2a4dd54951a24d60285")
11+
set(ROOT_CIVETWEB_PREFIX ${CMAKE_BINARY_DIR}/builtins/CIVETWEB-prefix)
12+
set(ROOT_CIVETWEB_LIBRARY ${ROOT_CIVETWEB_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}civetweb${CMAKE_STATIC_LIBRARY_SUFFIX})
13+
14+
if (NOT DEFINED GIT_EXECUTABLE)
15+
set(GIT_EXECUTABLE "git")
16+
endif()
17+
# check if the patch has already been applied
18+
if(NOT EXISTS "${ROOT_CIVETWEB_PREFIX}/src/BUILTIN_CIVETWEB/._patched")
19+
set(ROOT_CIVETWEB_PATCH_COMMAND PATCH_COMMAND ${GIT_EXECUTABLE} init COMMAND ${GIT_EXECUTABLE} apply
20+
${CMAKE_CURRENT_SOURCE_DIR}/1385.patch # https://github.com/civetweb/civetweb/pull/1385
21+
${CMAKE_CURRENT_SOURCE_DIR}/1389.patch # https://github.com/civetweb/civetweb/pull/1389
22+
${CMAKE_CURRENT_SOURCE_DIR}/civetweb-marker.diff)
23+
endif()
24+
25+
include(ExternalProject)
26+
27+
# Clear cache variables set by find_package(CIVETWEB)
28+
# to ensure that we use the builtin version
29+
foreach(var CIVETWEB_LIBRARIES CIVETWEB_LIBRARY CIVETWEB_LIBRARY_DEBUG CIVETWEB_LIBRARY_RELEASE CIVETWEB_FOUND CIVETWEB_VERSION CIVETWEB_INCLUDE_DIR CIVETWEB_LIBRARY CIVETWEB_LIBRARIES)
30+
unset(${var})
31+
unset(${var} CACHE)
32+
endforeach()
33+
34+
if(WIN32 AND NOT CMAKE_GENERATOR MATCHES Ninja)
35+
if(winrtdebug)
36+
set(ROOT_CIVETWEB_BUILD_COMMAND_FLAGS "--config Debug")
37+
else()
38+
set(ROOT_CIVETWEB_BUILD_COMMAND_FLAGS "--config $<IF:$<CONFIG:Debug,RelWithDebInfo>,RelWithDebInfo,Release>")
39+
endif()
40+
endif()
41+
42+
if(ssl)
43+
if(OPENSSL_VERSION)
44+
string(REPLACE "." ";" lst ${OPENSSL_VERSION})
45+
list(GET lst 0 ssl_major)
46+
list(GET lst 1 ssl_minor)
47+
else()
48+
MESSAGE(SEND_ERROR "No openSSL version defined.")
49+
endif()
50+
51+
if((${ssl_major} EQUAL "1") AND (${ssl_minor} EQUAL "1"))
52+
MESSAGE(STATUS "Use SSL API VERSION 1.1 for civetweb")
53+
set(ROOT_SSL_API "-DCIVETWEB_SSL_OPENSSL_API_1_1=ON" "-DCIVETWEB_SSL_OPENSSL_API_3_0=OFF" "-DCIVETWEB_SSL_OPENSSL_API_1_0=OFF" "-DCIVETWEB_ENABLE_SSL=ON")
54+
elseif((${ssl_major} EQUAL "3"))
55+
MESSAGE(STATUS "Use SSL API VERSION 3.${ssl_minor} for civetweb")
56+
set(ROOT_SSL_API "-DCIVETWEB_SSL_OPENSSL_API_3_0=ON" "-DCIVETWEB_SSL_OPENSSL_API_1_1=OFF" "-DCIVETWEB_SSL_OPENSSL_API_1_0=OFF" "-DCIVETWEB_ENABLE_SSL=ON")
57+
elseif((${ssl_major} EQUAL "1") AND (${ssl_minor} EQUAL "0"))
58+
MESSAGE(STATUS "Use SSL API VERSION 1.0 for civetweb")
59+
set(ROOT_SSL_API "-DCIVETWEB_SSL_OPENSSL_API_1_0=ON" "-DCIVETWEB_SSL_OPENSSL_API_3_0=OFF" "-DCIVETWEB_SSL_OPENSSL_API_1_1=OFF" "-DCIVETWEB_ENABLE_SSL=ON")
60+
else()
61+
MESSAGE(WARNING "Not able to recognize SSL version ${OPENSSL_VERSION}, disable SSL")
62+
set(ROOT_SSL_API "-DCIVETWEB_ENABLE_SSL=OFF")
63+
endif()
64+
else()
65+
set(ROOT_SSL_API "-DCIVETWEB_ENABLE_SSL=OFF")
66+
endif()
67+
set(ROOT_C_FLAGS ${CMAKE_C_FLAGS})
68+
if (CMAKE_OSX_SYSROOT)
69+
set(ROOT_C_FLAGS "${ROOT_C_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
70+
endif()
71+
if(NOT MSVC) # on Windows, one would need to add a patch to #include <afunix.h> and WSAStartup ifdefs...
72+
set(ROOT_X_DOM_SOCKET "-DCIVETWEB_ENABLE_X_DOM_SOCKET=ON")
73+
endif()
74+
75+
# If zlib is not builtin, the string will be empty, nothing special to be
76+
# done: we rely on libpng CMake to find zlib.
77+
# If zlib is builtin, we need to direct the builtin libpng to it.
78+
# For that, the libpng recommended way (see their CMakeLists)
79+
# is to use the CMake ZLIB_ROOT variable, which has nothing to do with ROOT
80+
# despite the name: it's a standard CMake convention to direct the search of
81+
# the find macro.
82+
# Therefore we set it to the prefix path of the builtin zlib in ROOT's
83+
# build directory.
84+
if(builtin_zlib)
85+
set(ZLIB_ROOT_OPTION "-DZLIB_ROOT=${ROOT_ZLIB_PREFIX}")
86+
endif()
87+
88+
ExternalProject_Add(BUILTIN_CIVETWEB
89+
PREFIX ${ROOT_CIVETWEB_PREFIX}
90+
# URL ${lcgpackages}/civetweb-${ROOT_CIVETWEB_VERSION}.tar.gz
91+
# URL https://github.com/civetweb/civetweb/archive/refs/tags/v${ROOT_CIVETWEB_VERSION}.tar.gz # TODO move to LCG
92+
# URL_HASH SHA256=${ROOT_CIVETWEB_HASH}
93+
# TODO: once 1.17 released, review _EXTERNAL_CIVETWEB workaround and bump SearchInstalledSoftware find_package to 1.17 plus remove builtin_ force-enable workaround with fail-on-missing
94+
# and potentially install libcivetweb-dev in root-ci-images and change RootBuildOptions default builtin_civetweb to OFF, if random crashes seen by linev are gone
95+
GIT_REPOSITORY https://github.com/civetweb/civetweb.git
96+
GIT_TAG 588860e30721bf5453b0440c390865a8e85dcae5 # v1.17.0 not yet released, v1.16.0 has missing CVE fixes
97+
${ROOT_CIVETWEB_PATCH_COMMAND}
98+
UPDATE_COMMAND ""
99+
LOG_DOWNLOAD TRUE
100+
LOG_CONFIGURE FALSE
101+
LOG_BUILD FALSE
102+
LOG_PATCH FALSE
103+
LOG_INSTALL FALSE
104+
LOG_OUTPUT_ON_FAILURE FALSE
105+
USES_TERMINAL_DOWNLOAD true
106+
USES_TERMINAL_UPDATE true
107+
USES_TERMINAL_BUILD true
108+
USES_TERMINAL_INSTALL true
109+
USES_TERMINAL_TEST true
110+
INSTALL_DIR ${ROOT_CIVETWEB_PREFIX}
111+
CMAKE_ARGS -G ${CMAKE_GENERATOR}
112+
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
113+
-DCMAKE_INSTALL_LIBDIR:PATH=<INSTALL_DIR>/lib
114+
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
115+
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
116+
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
117+
-DCMAKE_C_FLAGS=${ROOT_C_FLAGS}
118+
-DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS}
119+
-DBUILD_SHARED_LIBS:BOOL=FALSE
120+
-DBUILD_TESTING=FALSE
121+
-DCIVETWEB_BUILD_TESTING=FALSE
122+
-DCIVETWEB_ENABLE_ASAN=OFF # If set to ON, you need to set below link_library interface to UBSAN libs
123+
-DCIVETWEB_ENABLE_CXX=ON
124+
${ROOT_SSL_API}
125+
-DCIVETWEB_ENABLE_SSL_DYNAMIC_LOADING=OFF # If set to ON, you need to set below link_library interface to CMAKE_DL_LIBS
126+
-DCIVETWEB_ENABLE_WEBSOCKETS=ON
127+
${ROOT_X_DOM_SOCKET}
128+
-DCIVETWEB_ENABLE_ZLIB=ON
129+
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE
130+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
131+
-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
132+
-DOPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
133+
-DOPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY}
134+
-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
135+
#-DCMAKE_PREFIX_PATH:STRING=${OPENSSL_PREFIX}
136+
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
137+
#-DOPENSSL_FOUND=TRUE
138+
#-DOpenSSL_FOUND=TRUE
139+
#-DOpenSSL_ROOT=${OPENSSL_ROOT} #For CMake <3.27
140+
#-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
141+
#-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
142+
# -DCMAKE_INSTALL_RPATH:STRING=${rpath_origin}
143+
-DZLIB_LIBRARY=${ZLIB_LIBRARIES}
144+
-DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS}
145+
${ZLIB_ROOT_OPTION}
146+
BUILD_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_CIVETWEB_BUILD_COMMAND_FLAGS}
147+
INSTALL_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_CIVETWEB_BUILD_COMMAND_FLAGS} --target install
148+
BUILD_BYPRODUCTS
149+
${ROOT_CIVETWEB_LIBRARY}
150+
TIMEOUT 600
151+
)
152+
153+
file(MAKE_DIRECTORY ${ROOT_CIVETWEB_PREFIX}/include)
154+
add_library(civetweb::civetweb IMPORTED STATIC GLOBAL)
155+
add_dependencies(civetweb::civetweb BUILTIN_CIVETWEB)
156+
if(builtin_openssl)
157+
add_dependencies(BUILTIN_CIVETWEB BUILTIN_OPENSSL)
158+
endif()
159+
if(builtin_zlib)
160+
add_dependencies(BUILTIN_CIVETWEB BUILTIN_ZLIB)
161+
endif()
162+
set_target_properties(civetweb::civetweb PROPERTIES
163+
IMPORTED_LOCATION ${ROOT_CIVETWEB_LIBRARY}
164+
INTERFACE_INCLUDE_DIRECTORIES ${ROOT_CIVETWEB_PREFIX}/include)
165+
target_compile_definitions(civetweb::civetweb INTERFACE CIVETWEB_LIBRARY_STATIC) # needed for Win32 since public flag is not correctly propagated to parent scope (BUILD_SHARED_LIBS works fine for building but when installing, flag info is lost)
166+
if (ssl)
167+
target_link_libraries(civetweb::civetweb INTERFACE OpenSSL::SSL ZLIB::ZLIB)
168+
endif()
169+
170+
# Set the canonical output of find_package according to
171+
# https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names
172+
set(civetweb_INCLUDE_DIRS ${ROOT_CIVETWEB_PREFIX}/include PARENT_SCOPE)
173+
set(civetweb_LIBRARIES ${ROOT_CIVETWEB_LIBRARY} PARENT_SCOPE)
174+
set(civetweb_FOUND TRUE PARENT_SCOPE)
175+
set(civetweb_VERSION ${ROOT_CIVETWEB_VERSION} PARENT_SCOPE)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--- /dev/null 2026-03-12 08:23:04
2+
+++ ._patched 2026-04-28 08:20:11
3+
@@ -0,0 +1,1 @@
4+
+civetweb has been patched

0 commit comments

Comments
 (0)