Update fido2-manage.sh

This commit is contained in:
Token2
2026-01-08 19:59:15 +01:00
committed by GitHub
parent fdbf170801
commit b2504f97f5

View File

@@ -1,6 +1,5 @@
#!/bin/bash
FIDO2_TOKEN_CMD="/usr/local/bin/fido2-token2"
list=false
@@ -51,8 +50,6 @@ while [[ "$#" -gt 0 ]]; do
shift
done
show_help() {
cat << EOF
FIDO2 Token Management Tool
@@ -102,13 +99,11 @@ Examples:
EOF
}
# Display help if -help parameter is provided
if $help; then
show_help
exit 0
fi
# Check if no arguments are specified, then show help
if ! $list && ! $info && [[ -z $device ]] && ! $fingerprint && ! $storage && ! $residentKeys && [[ -z $domain ]] && ! $delete && [[ -z $credential ]] && ! $changePIN && ! $setMinimumPIN && ! $setPIN && ! $reset && ! $uvs && ! $uvd && ! $help; then
show_help
exit 1
@@ -124,9 +119,7 @@ if $list; then
device_count=1
echo "$command_output" | while read -r line; do
if [[ $line =~ ^([^:]+) ]]; then
echo "Device [$device_count] : $(echo "${line}" | grep -oP '(?<=\()(.+)(?=\))')"
device_count=$((device_count + 1))
fi
done
@@ -191,6 +184,10 @@ if [[ -n $device ]]; then
if [[ -n $setMinimumPIN ]]; then
show_message "Setting minimum PIN length to $setMinimumPIN on device $device"
"$FIDO2_TOKEN_CMD" -S -l "$setMinimumPIN" "$device_string"
if [ $? -ne 0 ]; then
show_message "Error: Failed to set minimum PIN length." "Error"
exit 1
fi
exit 0
fi
@@ -206,24 +203,20 @@ if [[ -n $device ]]; then
exit 0
fi
# Fingerprint enrollment
if $fingerprint; then
echo "Enrolling fingerprints (for bio models only)"
if $fingerprint; then
echo "Enrolling fingerprints (for bio models only)"
$FIDO2_TOKEN_CMD -S -e "$device_string" $([[ -n $pin ]] && echo "-w $pin")
exit 0
fi
# Main logic
if $storage; then
fi
if $storage; then
$FIDO2_TOKEN_CMD -I -c "$device_string" $([[ -n $pin ]] && echo "-w $pin")
exit 0
elif $residentKeys; then
elif $residentKeys; then
if [[ -n $domain ]]; then
domain_command="$FIDO2_TOKEN_CMD -L -k \"$domain\" \"$device_string\" $([[ -n $pin ]] && echo "-w $pin")"
domain_output=$(eval $domain_command)
# Process the output line by line
echo "$domain_output" | while read -r line; do
key_id=$(echo "$line" | awk '{print $1}')
credential_id=$(echo "$line" | awk '{print $2}')
@@ -234,7 +227,6 @@ elif $residentKeys; then
user_field=""
fi
# Determine if user_field is an email
if [[ "$user_field" == *"@"* ]]; then
email=$user_field
user=""
@@ -249,8 +241,7 @@ elif $residentKeys; then
$FIDO2_TOKEN_CMD -L -r "$device_string" $(if [[ -n $pin ]]; then echo "-w $pin"; fi)
fi
exit 0
fi
fi
if $info; then
command_output=$($FIDO2_TOKEN_CMD -I "$device_string")