Fix hardcoded FIDO2_TOKEN_CMD path in fido2-manage.sh

Replaces the hardcoded /usr/local/bin/fido2-token2 with dynamic
detection: checks alongside the script first (dev builds), then
falls back to PATH so any install prefix works correctly.

Fixes #32
This commit is contained in:
Tamir Suliman
2026-06-06 12:46:34 +02:00
parent b0544044da
commit 2f2fb7f761

View File

@@ -1,6 +1,24 @@
#!/bin/bash
FIDO2_TOKEN_CMD="/usr/local/bin/fido2-token2"
# Locate fido2-token2: check next to this script first (dev builds),
# then fall back to PATH (handles any install prefix).
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FIDO2_TOKEN_CMD=""
for candidate in \
"$SCRIPT_DIR/fido2-token2" \
"$SCRIPT_DIR/build/tools/fido2-token2" \
"$SCRIPT_DIR/tools/fido2-token2"
do
if [[ -f "$candidate" ]]; then
FIDO2_TOKEN_CMD="$candidate"
break
fi
done
if [[ -z "$FIDO2_TOKEN_CMD" ]]; then
FIDO2_TOKEN_CMD="$(command -v fido2-token2 2>/dev/null)"
fi
list=false
info=false
@@ -110,6 +128,11 @@ if ! $list && ! $info && [[ -z $device ]] && ! $fingerprint && ! $storage && ! $
exit 1
fi
if [[ -z "$FIDO2_TOKEN_CMD" ]]; then
show_message "fido2-token2 not found. Install it or ensure it is on your PATH." "Error"
exit 1
fi
if $list; then
command_output=$($FIDO2_TOKEN_CMD -L 2>&1)
if [ $? -ne 0 ]; then