Skip to content

Commit

Permalink
tests/softhsm: Search library near softhsm2-util
Browse files Browse the repository at this point in the history
On macOS, libsofthsm2.so might be installed in
/usr/local/lib/libsofthsm2.so, /opt/local/lib/libsofthsm2.so, somewhere
in /usr/local/Cellar/softhsm, or on Apple Silicon in
/opt/homebrew/lib/libsofths2.so.

Simplify searching for it by using $PATH, which we know must already
contain softhsm2-util, and then attempt to identify the library relative
to that.

Signed-off-by: Clemens Lang <cllang@redhat.com>
  • Loading branch information
neverpanic authored and simo5 committed Feb 3, 2023
1 parent 037f268 commit 9eb9bb8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/setup-softhsm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,21 @@ find_softhsm() {
}

title SECTION "Searching for SoftHSM PKCS#11 library"
# Attempt to guess the path to libsofthsm2.so relative to that. This fixes
# auto-detection on platforms such as macOS with MacPorts (and potentially
# Homebrew).
#
# This should never be empty, since we checked for the presence of
# softhsm2-util above and use it below.

# Strip bin/softhsm2-util
softhsm_prefix=$(dirname "$(dirname "$(type -p softhsm2-util)")")

find_softhsm \
"$softhsm_prefix/lib64/softhsm/libsofthsm2.so" \
"$softhsm_prefix/lib/softhsm/libsofthsm2.so" \
"$softhsm_prefix/lib64/pkcs11/libsofthsm2.so" \
"$softhsm_prefix/lib/pkcs11/libsofthsm2.so" \
/usr/local/lib/softhsm/libsofthsm2.so \
/usr/lib64/pkcs11/libsofthsm2.so \
/usr/lib/pkcs11/libsofthsm2.so \
Expand Down

0 comments on commit 9eb9bb8

Please sign in to comment.