Skip to content

Commit 8274fd9

Browse files
authored
Merge pull request #291 from padelsbach/wp-debian-patch-check
Fix is_openssl_patched
2 parents 655b63d + 54b142c commit 8274fd9

File tree

6 files changed

+77
-98
lines changed

6 files changed

+77
-98
lines changed

.github/scripts/x11vnc/test_x11vnc.sh

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
#!/bin/bash
22

3+
# Usage: ./test_x11vnc.sh [log_file]
4+
# If no log file is provided, defaults to "x11vnc_test.log"
5+
6+
# Set default log file
7+
LOG_FILE="${1:-x11vnc_test.log}"
8+
9+
# Show usage if help is requested
10+
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
11+
echo "Usage: $0 [log_file]"
12+
echo " log_file: Path to the log file (default: x11vnc_test.log)"
13+
echo " -h, --help: Show this help message"
14+
exit 0
15+
fi
16+
317
SCRIPTS_DIR="$GITHUB_WORKSPACE/.github/scripts/x11vnc"
418

519
killall x11vnc > /dev/null 2> /dev/null
@@ -11,9 +25,9 @@ X11VNC_TEST_FAIL=0
1125
# CA / cert generation
1226

1327

14-
echo -e "\n\nTesting -sslGenCA\n" > x11vnc_test.log
28+
echo -e "\n\nTesting -sslGenCA\n" > "$LOG_FILE"
1529

16-
$SCRIPTS_DIR/x11vnc_sslgenca.exp >> x11vnc_test.log 2>> x11vnc_test.log
30+
$SCRIPTS_DIR/x11vnc_sslgenca.exp >> "$LOG_FILE" 2>> "$LOG_FILE"
1731

1832
if [ $? -eq 0 ] && [ -f "ca-dir/CA/cacert.pem" ] && [ -f "ca-dir/CA/private/cakey.pem" ]
1933
then
@@ -24,9 +38,9 @@ else
2438
fi
2539

2640

27-
echo -e "\n\nTesting -sslGenCert client\n" >> x11vnc_test.log
41+
echo -e "\n\nTesting -sslGenCert client\n" >> "$LOG_FILE"
2842

29-
$SCRIPTS_DIR/x11vnc_sslgencert_client.exp >> x11vnc_test.log 2>> x11vnc_test.log
43+
$SCRIPTS_DIR/x11vnc_sslgencert_client.exp >> "$LOG_FILE" 2>> "$LOG_FILE"
3044

3145
if [ $? -eq 0 ] && [ -f "ca-dir/clients/wolf.pem" ] && [ -f "ca-dir/clients/wolf.crt" ]
3246
then
@@ -37,9 +51,9 @@ else
3751
fi
3852

3953

40-
echo -e "\n\nTesting -sslGenCert server\n" >> x11vnc_test.log
54+
echo -e "\n\nTesting -sslGenCert server\n" >> "$LOG_FILE"
4155

42-
$SCRIPTS_DIR/x11vnc_sslgencert_server.exp >> x11vnc_test.log 2>> x11vnc_test.log
56+
$SCRIPTS_DIR/x11vnc_sslgencert_server.exp >> "$LOG_FILE" 2>> "$LOG_FILE"
4357

4458
if [ $? -eq 0 ] && [ -f "ca-dir/server-wolf.pem" ] && [ -f "ca-dir/server-wolf.crt" ]
4559
then
@@ -50,13 +64,13 @@ else
5064
fi
5165

5266

53-
echo -e "\n\nTesting -sslCertInfo\n" >> x11vnc_test.log
67+
echo -e "\n\nTesting -sslCertInfo\n" >> "$LOG_FILE"
5468

5569
OPENSSL_CONF='' OPENSSL_MODULES='' timeout 5 x11vnc -sslCertInfo ca-dir/server-wolf.pem > cert_info_ossl.txt
5670
timeout 5 x11vnc -sslCertInfo ca-dir/server-wolf.pem > cert_info.txt
5771

58-
if [ $? -eq 0 ] && diff -y cert_info.txt cert_info_ossl.txt >> x11vnc_test.log 2>> x11vnc_test.log \
59-
&& cat cert_info.txt >> x11vnc_test.log
72+
if [ $? -eq 0 ] && diff -y cert_info.txt cert_info_ossl.txt >> "$LOG_FILE" 2>> "$LOG_FILE" \
73+
&& cat cert_info.txt >> "$LOG_FILE"
6074
then
6175
echo "[ PASSED ] -sslCertInfo"
6276
else
@@ -65,9 +79,9 @@ else
6579
fi
6680

6781

68-
echo -e "\n\nTesting -sslEncKey\n" >> x11vnc_test.log
82+
echo -e "\n\nTesting -sslEncKey\n" >> "$LOG_FILE"
6983

70-
$SCRIPTS_DIR/x11vnc_sslenckey.exp >> x11vnc_test.log 2>> x11vnc_test.log
84+
$SCRIPTS_DIR/x11vnc_sslenckey.exp >> "$LOG_FILE" 2>> "$LOG_FILE"
7185

7286
if [ $? -eq 0 ] && grep -q "BEGIN ENCRYPTED PRIVATE KEY" ca-dir/server-wolf.pem
7387
then
@@ -83,12 +97,12 @@ fi
8397

8498
# Setup Xvfb, which is a purely virtual display, i.e., humans cannot see it
8599
# but it works the same as any other X server
86-
Xvfb :0 -screen 0 100x100x8 2>> x11vnc_test.log &
100+
Xvfb :0 -screen 0 100x100x8 2>> "$LOG_FILE" &
87101
sleep 2
88102

89103

90104
# Testing with SSL will use the TLSNone security type
91-
echo -e "\n\nTesting -ssl handshake, authentication, initialization...\n" >> x11vnc_test.log
105+
echo -e "\n\nTesting -ssl handshake, authentication, initialization...\n" >> "$LOG_FILE"
92106

93107
PORT=`x11vnc -ssl TMP -display :0 -localhost -bg -o server.log`
94108
PORT=`echo "$PORT" | grep -m 1 "PORT=" | sed -e 's/PORT=//'`
@@ -105,13 +119,13 @@ else
105119
X11VNC_TEST_FAIL=1
106120
fi
107121
killall x11vnc > /dev/null 2> /dev/null
108-
cat server.log client.log >> x11vnc_test.log
122+
cat server.log client.log >> "$LOG_FILE"
109123

110124

111125
# Testing with a password changes the security type from TLSNone to TLSVnc
112-
echo -e "\n\nTesting -ssl with a password...\n" >> x11vnc_test.log
126+
echo -e "\n\nTesting -ssl with a password...\n" >> "$LOG_FILE"
113127

114-
x11vnc -storepasswd wolfprov passwd 2>> x11vnc_test.log
128+
x11vnc -storepasswd wolfprov passwd 2>> "$LOG_FILE"
115129

116130
PORT=`x11vnc -ssl TMP -display :0 -localhost -bg -o server.log -rfbauth passwd`
117131
PORT=`echo "$PORT" | grep -m 1 "PORT=" | sed -e 's/PORT=//'`
@@ -128,7 +142,7 @@ else
128142
X11VNC_TEST_FAIL=1
129143
fi
130144
killall x11vnc > /dev/null 2> /dev/null
131-
cat server.log client.log >> x11vnc_test.log
145+
cat server.log client.log >> "$LOG_FILE"
132146

133147

134148
# HTTP HTTPS
@@ -140,9 +154,9 @@ echo "<html><body>Use WolfSSL!</body></html>" > index.html
140154
PORT=`x11vnc -ssl TMP -display :0 -localhost -httpdir . -https 5678 -bg -o server.log`
141155
PORT=`echo "$PORT" | grep -m 1 -Eo "http://localhost:[0-9]+" server.log | sed -e 's/http:\/\/localhost://'`
142156

143-
echo -e "\n\nTesting -https with http...\n" >> x11vnc_test.log
157+
echo -e "\n\nTesting -https with http...\n" >> "$LOG_FILE"
144158

145-
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "http://localhost:$PORT/index.html" >> x11vnc_test.log
159+
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "http://localhost:$PORT/index.html" >> "$LOG_FILE"
146160
then
147161
echo "[ PASSED ] -https with an http request"
148162
else
@@ -151,23 +165,20 @@ else
151165
fi
152166

153167

154-
echo -e "\n\nTesting -https with https...\n" >> x11vnc_test.log
168+
echo -e "\n\nTesting -https with https...\n" >> "$LOG_FILE"
155169

156-
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "https://localhost:5678/index.html" >> x11vnc_test.log
170+
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "https://localhost:5678/index.html" >> "$LOG_FILE"
157171
then
158172
echo "[ PASSED ] -https with an https request"
159173
else
160174
echo "[ FAILED ] -https with an https request"
161175
X11VNC_TEST_FAIL=1
162176
fi
163177

164-
killall x11vnc > /dev/null 2> /dev/null
165-
killall Xvfb > /dev/null 2> /dev/null
166-
cat server.log >> x11vnc_test.log
167-
168-
$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $X11VNC_TEST_FAIL "$WOLFPROV_FORCE_FAIL_STR" x11vnc
169-
X11VNC_TEST_FAIL=$?
170-
171-
if [[ $X11VNC_TEST_FAIL -eq 1 ]]; then cat x11vnc_test.log; fi
178+
killall x11vnc > /dev/null 2> /dev/null || true
179+
killall Xvfb > /dev/null 2> /dev/null || true
180+
cat server.log >> "$LOG_FILE"
172181

182+
printf "\n\nX11VNC_TEST_FAIL: $X11VNC_TEST_FAIL\n\n"
173183
exit $X11VNC_TEST_FAIL
184+

.github/workflows/build-wolfprovider.yml

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -70,52 +70,13 @@ jobs:
7070
git remote add upstream https://github.com/wolfSSL/wolfProvider.git || true
7171
git fetch upstream --tags --no-recurse-submodules
7272
73-
- name: Restore wolfSSL packages
74-
uses: actions/cache@v4
75-
id: wolfssl_cache
76-
with:
77-
path: |
78-
${{ env.WOLFSSL_PACKAGES_PATH }}/*.deb
79-
${{ env.WOLFSSL_PACKAGES_PATH }}/*.dsc
80-
${{ env.WOLFSSL_PACKAGES_PATH }}/*.tar.gz
81-
key: wolfssl-debian-packages-${{ inputs.wolfssl_ref }}
82-
83-
- name: Install wolfSSL packages from cache
84-
if: steps.wolfssl_cache.outputs.cache-hit == 'true'
85-
run: |
86-
printf "Installing wolfSSL packages from cache:\n"
87-
ls -la ${{ env.WOLFSSL_PACKAGES_PATH }}
88-
apt install --reinstall -y ${{ env.WOLFSSL_PACKAGES_PATH }}/*wolfssl*.deb
89-
73+
# Build wolfSSL packages and install
74+
# Note we do not use the cache currently. This is a future optimization.
9075
# TODO: roll this step into utils-wolfssl.sh
9176
- name: Build wolfSSL packages and install
92-
# if: steps.wolfssl_cache.outputs.cache-hit != 'true'
9377
run: |
9478
$GITHUB_WORKSPACE/debian/install-wolfssl.sh --tag ${{ inputs.wolfssl_ref }} ${{ env.WOLFSSL_PACKAGES_PATH }}
9579
96-
# Check for cached OpenSSL packages
97-
# WARNING: for Debian, openssl_ref is ignored since we build from Debian baseline
98-
- name: Checking OpenSSL packages in cache
99-
uses: actions/cache@v4
100-
id: openssl_cache
101-
continue-on-error: true
102-
with:
103-
path: |
104-
${{ env.OPENSSL_PACKAGES_PATH }}
105-
key: openssl-debian-packages-${{ inputs.openssl_ref }}${{ inputs.replace_default && '-replace-default' || '' }}
106-
lookup-only: false
107-
108-
# Install OpenSSL packages from cache if available
109-
- name: Install OpenSSL packages from cache
110-
if: ${{ steps.openssl_cache.outputs.cache-hit == 'true' }}
111-
run: |
112-
printf "Installing OpenSSL packages from cache:\n"
113-
ls -la ${{ env.OPENSSL_PACKAGES_PATH }}
114-
apt install --reinstall -y \
115-
${{ env.OPENSSL_PACKAGES_PATH }}/openssl_*.deb \
116-
${{ env.OPENSSL_PACKAGES_PATH }}/libssl3_*.deb \
117-
${{ env.OPENSSL_PACKAGES_PATH }}/libssl-dev_*.deb
118-
11980
- name: Build wolfProvider
12081
run: |
12182
WOLFSSL_TAG=${{ inputs.wolfssl_ref }} OPENSSL_TAG=${{ inputs.openssl_ref }} \
@@ -138,7 +99,7 @@ jobs:
13899
ls -la ${{ env.WOLFSSL_PACKAGES_PATH }}
139100
ls -la ${{ env.OPENSSL_PACKAGES_PATH }}
140101
141-
- name: Save to cache
102+
- name: Save all packages to cache for use by other workflows
142103
uses: actions/cache/save@v4
143104
continue-on-error: true
144105
with:
@@ -166,15 +127,3 @@ jobs:
166127
${{ env.WOLFPROV_PACKAGES_PATH }}/*.dsc
167128
${{ env.WOLFPROV_PACKAGES_PATH }}/*.tar.gz
168129
retention-days: 1
169-
170-
# TODO: upload wolfSSL artifacts, after building
171-
# - name: Upload wolfSSL artifacts
172-
# uses: actions/upload-artifact@v4
173-
# with:
174-
# name: wolfssl-debian-packages-${{ inputs.wolfssl_ref }}
175-
# path: |
176-
# ${{ env.WOLFPROV_PACKAGES_PATH }}/*wolfssl*.deb
177-
# ${{ env.WOLFPROV_PACKAGES_PATH }}/*wolfssl*.dsc
178-
# ${{ env.WOLFPROV_PACKAGES_PATH }}/*wolfssl*.tar.gz
179-
# retention-days: 1
180-

.github/workflows/x11vnc.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,22 @@ jobs:
122122
run: |
123123
export ${{ matrix.force_fail }}
124124
export WOLFPROV_FORCE_FAIL_STR="${{ matrix.force_fail }}"
125-
$GITHUB_WORKSPACE/.github/scripts/x11vnc/test_x11vnc.sh
125+
export X11VNC_TEST_LOG=/tmp/x11vnc-test.log
126+
export X11VNC_TEST_STATUS=0
127+
if ! $GITHUB_WORKSPACE/.github/scripts/x11vnc/test_x11vnc.sh $X11VNC_TEST_LOG; then
128+
X11VNC_TEST_STATUS=1
129+
fi
130+
131+
if $GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $X11VNC_TEST_STATUS "$WOLFPROV_FORCE_FAIL_STR" x11vnc; then
132+
X11VNC_TEST_STATUS=0
133+
else
134+
X11VNC_TEST_STATUS=1
135+
fi
136+
137+
- name: Show x11vnc test log on failure
138+
run: |
139+
if [ $X11VNC_TEST_STATUS -ne 0 ]; then
140+
cat $X11VNC_TEST_LOG
141+
fi
142+
exit $X11VNC_TEST_STATUS
143+

.github/workflows/xmlsec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: xmlsec Tests
33
# START OF COMMON SECTION
44
on:
55
push:
6-
branches: [ '**' ] # 'master', 'main', 'release/**' ]
6+
branches: [ 'master', 'main', 'release/**' ]
77
pull_request:
88
branches: [ '*' ]
99

scripts/utils-openssl.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,20 @@ clone_openssl() {
121121
}
122122

123123
is_openssl_patched() {
124-
if [ ! -f "${OPENSSL_SOURCE_DIR}/crypto/provider_predefined.c" ]; then
124+
# Return 0 if patched, 1 if not
125+
local dir="${OPENSSL_SOURCE_DIR:?OPENSSL_SOURCE_DIR not set}"
126+
local file="${dir%/}/crypto/provider_predefined.c"
127+
128+
# File must exist to be patched
129+
[[ -f "$file" ]] || return 1
130+
131+
# Any time we see libwolfprov, we're patched
132+
if grep -q 'libwolfprov' -- "$file"; then
125133
return 0
126134
fi
127135

128-
# Check if $OPENSSL_SOURCE_DIR is a git repository
129-
if [ -d ${OPENSSL_SOURCE_DIR}/.git ]; then
130-
pushd ${OPENSSL_SOURCE_DIR} &> /dev/null
131-
patch_applied=$(git diff --quiet "crypto/provider_predefined.c" 2>/dev/null && echo 1 || echo 0)
132-
popd &> /dev/null
133-
else
134-
# Not a git repo, may have been downloaded separately (from Debian sources)
135-
patch_applied=$(grep -q "libwolfprov" "${OPENSSL_SOURCE_DIR}/crypto/provider_predefined.c" && echo 1 || echo 0)
136-
fi
137-
return $patch_applied
136+
# Not patched
137+
return 1
138138
}
139139

140140
check_openssl_replace_default_mismatch() {

src/wp_wolfprov.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,9 @@ int wolfssl_provider_init(const OSSL_CORE_HANDLE* handle,
12421242
if (ok) {
12431243
if (wolfSSL_Debugging_ON() != 0) {
12441244
WOLFPROV_MSG(WP_LOG_PROVIDER,
1245-
"WARNING: wolfProvider built with debug but underlying wolfSSL is not!"
1246-
"Building wolfSSl with debug is highly recommended, proceeding...");
1245+
"WARNING: wolfProvider built with debug but underlying wolfSSL is not!");
1246+
WOLFPROV_MSG(WP_LOG_PROVIDER,
1247+
"\tBuilding wolfSSl with debug is highly recommended, proceeding...");
12471248
}
12481249
else {
12491250
wolfSSL_SetLoggingPrefix("wolfSSL");

0 commit comments

Comments
 (0)