fp-verify.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # Fingerprint verification via the Wine sandbox + hacked winusb + vendor driver.
  3. # Usage: fp-verify.sh (touch the sensor when the log says it waits)
  4. # Exit codes: 0 = MATCH (enrolled "Unicorn" record returned), 1 = no match, 2 = error/timeout
  5. set -u
  6. export PATH=/usr/local/bin:/usr/bin:/bin
  7. ROOT=/home/nebulon/projects/fingerprint
  8. SANDBOX=$ROOT/work/synaWudfBioUsb-sandbox
  9. export HOME="${HOME:-/home/nebulon}"
  10. export WINEPREFIX=$ROOT/work/wineprefix-48
  11. export WINEDEBUG=-all
  12. export USB_SCRIPT=$ROOT/work/debug/usb-verify-$(date +%s).txt
  13. export USB_PLAYBACK=""
  14. touch "$USB_SCRIPT"
  15. mkdir -p /tmp/opencode 2>/dev/null
  16. LOG=/tmp/opencode/fp-verify-last.log
  17. cd "$SANDBOX" || exit 2
  18. # self-heal: the device spec the driver reads (sandbox copy + Wine C: drive)
  19. [ -f usb.txt ] || echo "06cb:0081" > usb.txt
  20. USB_TXT="$WINEPREFIX/drive_c/usb.txt"
  21. if [ ! -f "$USB_TXT" ]; then
  22. mkdir -p "$(dirname "$USB_TXT")" 2>/dev/null
  23. echo "06cb:0081" > "$USB_TXT" 2>/dev/null || true
  24. fi
  25. [ "${FP_VERIFY_QUIET:-0}" = "1" ] || echo "Fingerprint: touch the reader (or wait for the password prompt)..."
  26. timeout -k 5 "${FP_VERIFY_TIMEOUT:-90}" \
  27. "$ROOT/work/wine-build/install/bin/wine64" verify.exe > "$LOG" 2>&1
  28. rc=$?
  29. if grep -q "556e69636f726e" "$LOG"; then # hex of "Unicorn"
  30. echo "Fingerprint matched."
  31. exit 0
  32. elif [ "$rc" -eq 124 ] || [ "$rc" -eq 137 ]; then
  33. echo "No fingerprint detected - falling back to password."
  34. exit 2
  35. else
  36. echo "Fingerprint did not match - falling back to password."
  37. exit 1
  38. fi