Skip to content

Commit 51b658a

Browse files
committed
OpenSSL config load fixes
- fix to _really_ disable OpenSSL automatic config loading in curl and libcurl. original commit with same intention, but wrong macro name: fb80105 curl commit implementing this feature: curl/curl@6684653 - fix OpenSSL build to use the non-world-writable prefix `C:/Windows/System32/OpenSSL/` for config/certificate/engine/etc paths hard-coded into OpenSSL binaries. The build uses a minor patch to OpenSSL's ./Configure script to make it recognize a Windows absolute path as an absolute one. The default path `/usr/local` may result in privilege escalation. Note that above OpenSSL patch is NOT confirmed or endorsed by upstream at this time. However, due to the weight of the issue, it was decided to make this exception from curl-for-win's local-patching policy.
1 parent 830c0de commit 51b658a

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

_dl.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export OSSLSIGNCODE_HASH=f9a8cdb38b9c309326764ebc937cba1523a3a751a7ab05df3ecc99d
2828
# NOTE: Set _REV to empty after bumping CURL_VER_, and
2929
# set it to 1 then increment by 1 each time bumping a dependency
3030
# version or pushing a CI rebuild for the master branch.
31-
export _REV='1'
31+
export _REV='2'
3232

3333
[ -z "${_REV}" ] || _REV="_${_REV}"
3434

curl.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -ex
22

3-
# Copyright 2014-2018 Viktor Szakats <https://vszakats.net/>
3+
# Copyright 2014-2019 Viktor Szakats <https://vszakats.net/>
44
# See LICENSE.md
55

66
export _NAM
@@ -49,7 +49,7 @@ _cpu="$2"
4949
# public libcurl functions being marked as 'exported'. It's useful to
5050
# avoid the chance of libcurl functions getting exported from final
5151
# binaries when linked against static libcurl lib.
52-
export CURL_CFLAG_EXTRAS='-DCURL_STATICLIB -fno-ident -DCURL_DISABLE_SSL_AUTO_LOAD_CONFIG'
52+
export CURL_CFLAG_EXTRAS='-DCURL_STATICLIB -fno-ident'
5353
[ "${_cpu}" = '32' ] && CURL_CFLAG_EXTRAS="${CURL_CFLAG_EXTRAS} -fno-asynchronous-unwind-tables"
5454
export CURL_LDFLAG_EXTRAS='-static-libgcc -Wl,--nxcompat -Wl,--dynamicbase'
5555
export CURL_LDFLAG_EXTRAS_EXE
@@ -91,6 +91,7 @@ _cpu="$2"
9191

9292
[ -d ../openssl ] && export OPENSSL_PATH=../../openssl
9393
if [ -n "${OPENSSL_PATH}" ]; then
94+
CURL_CFLAG_EXTRAS="${CURL_CFLAG_EXTRAS} -DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG"
9495
options="${options}-ssl"
9596
export OPENSSL_INCLUDE="${OPENSSL_PATH}/include"
9697
export OPENSSL_LIBPATH="${OPENSSL_PATH}"

libssh2_cmake.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -ex
22

3-
# Copyright 2014-2018 Viktor Szakats <https://vszakats.net/>
3+
# Copyright 2014-2019 Viktor Szakats <https://vszakats.net/>
44
# See LICENSE.md
55

66
export _NAM
@@ -68,10 +68,10 @@ _cpu="$2"
6868
options="${options} -DZLIB_INCLUDE_DIR:PATH=$(pwd)/../zlib/pkg/usr/local/include"
6969
options="${options} -DZLIB_LIBRARY:FILEPATH=$(pwd)/../zlib/pkg/usr/local/lib/libz.a"
7070
options="${options} -DCRYPTO_BACKEND=OpenSSL"
71-
options="${options} -DOPENSSL_ROOT_DIR=$(pwd)/../openssl/pkg/usr/local/"
72-
options="${options} -DOPENSSL_INCLUDE_DIR=$(pwd)/../openssl/pkg/usr/local/include"
73-
options="${options} -DOPENSSL_LIBRARIES=$(pwd)/../openssl/pkg/usr/local/lib"
74-
options="${options} -DOPENSSL_CRYPTO_LIBRARY=$(pwd)/../openssl/pkg/usr/local/lib"
71+
options="${options} -DOPENSSL_ROOT_DIR=$(pwd)/../openssl/pkg/C:/Windows/System32/OpenSSL/"
72+
options="${options} -DOPENSSL_INCLUDE_DIR=$(pwd)/../openssl/pkg/C:/Windows/System32/OpenSSL/include"
73+
options="${options} -DOPENSSL_LIBRARIES=$(pwd)/../openssl/pkg/C:/Windows/System32/OpenSSL/lib"
74+
options="${options} -DOPENSSL_CRYPTO_LIBRARY=$(pwd)/../openssl/pkg/C:/Windows/System32/OpenSSL/lib"
7575
options="${options} -DCMAKE_RC_COMPILER=${_CCPREFIX}windres"
7676
options="${options} -DCMAKE_INSTALL_MESSAGE=NEVER"
7777
options="${options} -DCMAKE_INSTALL_PREFIX=/usr/local"

openssl.sh

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -ex
22

3-
# Copyright 2014-2018 Viktor Szakats <https://vszakats.net/>
3+
# Copyright 2014-2019 Viktor Szakats <https://vszakats.net/>
44
# See LICENSE.md
55

66
export _NAM
@@ -62,22 +62,35 @@ _cpu="$2"
6262
# AR=, NM=, RANLIB=
6363
unset CC
6464

65+
# Patch OpenSSL ./Configure to make it accept Windows-style absolute
66+
# paths as --prefix. Without the patch it misidentifies all such
67+
# absolute paths as relative ones and aborts.
68+
sed 's|die "Directory given with --prefix|print "Directory given with --prefix|g' \
69+
< ./Configure > ./Configure-patched
70+
chmod +x ./Configure-patched
71+
72+
# Space or backslash not allowed. Needs to be a folder restricted
73+
# to Administrators across majority of Windows installations, versions
74+
# and configurations.
75+
_prefix='C:/Windows/System32/OpenSSL'
76+
6577
# shellcheck disable=SC2086
66-
./Configure ${options} shared \
78+
./Configure-patched ${options} shared \
6779
"--cross-compile-prefix=${_CCPREFIX}" \
6880
-fno-ident \
6981
-Wl,--nxcompat -Wl,--dynamicbase \
7082
no-unit-test \
7183
no-idea \
7284
no-tests \
7385
no-makedepend \
74-
'--prefix=/usr/local'
86+
"--prefix=${_prefix}"
7587
SOURCE_DATE_EPOCH=${unixts} TZ=UTC make
7688
# Install it so that it can be detected by CMake
77-
make install "DESTDIR=$(pwd)/pkg" > /dev/null # 2>&1
89+
# (ending slash required)
90+
make install "DESTDIR=$(pwd)/pkg/" > /dev/null # 2>&1
7891

7992
# DESTDIR= + --prefix=
80-
_pkg='pkg/usr/local'
93+
_pkg="pkg/${_prefix}"
8194

8295
# Make steps for determinism
8396

0 commit comments

Comments
 (0)