@@ -84,42 +84,35 @@ check_wolfssl_options() {
8484}
8585
8686ensure_wolfssl () {
87+ local src
88+
8789 # 1. Explicit WOLFSSL_PATH from environment
8890 if [ -n " $WOLFSSL_PATH " ] && check_wolfssl_options " $WOLFSSL_PATH " ; then
8991 echo " wolfSSL: using $WOLFSSL_PATH "
9092 return 0
9193 fi
9294
9395 # 2. Reuse prior /tmp build
94- local src=" /tmp/wolfssl-fwtpm"
96+ src=" /tmp/wolfssl-fwtpm"
9597 if [ -d " $src " ] && check_wolfssl_options " $src " ; then
9698 WOLFSSL_PATH=" $src "
9799 echo " wolfSSL: using $WOLFSSL_PATH "
98100 return 0
99101 fi
100102
101- # 3. Clone and build to /tmp (no sudo)
102- echo " Building wolfSSL to $src "
103- if [ ! -d " $src /.git" ]; then
104- rm -rf " $src "
105- git clone --depth 1 https://github.com/wolfssl/wolfssl.git " $src " \
106- > /tmp/wolfssl-fwtpm-clone.log 2>&1 || return 1
107- fi
108- if ! check_wolfssl_options " $src " ; then
109- (cd " $src " && \
110- ./autogen.sh > /dev/null 2>&1 && \
111- ./configure \
112- --enable-wolftpm --enable-pkcallbacks --enable-keygen \
113- CFLAGS=" -DWC_RSA_NO_PADDING" \
114- > /tmp/wolfssl-fwtpm-configure.log 2>&1 && \
115- make > /tmp/wolfssl-fwtpm-build.log 2>&1 ) || {
116- echo " wolfSSL build failed -- see /tmp/wolfssl-fwtpm-*.log"
117- return 1
118- }
119- fi
120- WOLFSSL_PATH=" $src "
121- echo " wolfSSL: built at $WOLFSSL_PATH "
122- return 0
103+ # 3. Check system install paths
104+ for src in /usr/local /usr /opt/homebrew /opt/local; do
105+ if check_wolfssl_options " $src " ; then
106+ WOLFSSL_PATH=" $src "
107+ echo " wolfSSL: using system install at $WOLFSSL_PATH "
108+ return 0
109+ fi
110+ done
111+
112+ echo " wolfSSL not available with required options."
113+ echo " Set WOLFSSL_PATH or install wolfSSL system-wide."
114+ echo " Skipping TLS-dependent tests."
115+ return 1
123116}
124117
125118# --- Cleanup ---
@@ -260,9 +253,16 @@ if [ $IS_FWTPM_MODE -eq 1 ]; then
260253 rm -f " $BUILD_DIR " /certs/tpm-* -cert.pem " $BUILD_DIR " /certs/tpm-* -cert.csr
261254 rm -f " $BUILD_DIR " /certs/server-* -cert.pem " $BUILD_DIR " /certs/client-* -cert.pem
262255
263- # Kill any orphaned servers from prior crashed runs (intentional pre-flight)
264- killall fwtpm_server 2> /dev/null || true
265- sleep 0.3
256+ # Clean up any stale PID files from prior crashed runs
257+ for stale_pid_file in /tmp/fwtpm_check_* .pid; do
258+ [ -f " $stale_pid_file " ] || continue
259+ stale_pid=" $( cat " $stale_pid_file " 2> /dev/null) "
260+ if [ -n " $stale_pid " ] && kill -0 " $stale_pid " 2> /dev/null; then
261+ kill " $stale_pid " 2> /dev/null
262+ sleep 0.3
263+ fi
264+ rm -f " $stale_pid_file "
265+ done
266266
267267 if [ $HAS_GETENV -eq 1 ] && [ $IS_SWTPM_MODE -eq 1 ]; then
268268 FWTPM_PORT=$( pick_available_port)
0 commit comments