print error, when more than one token is plugged in

This commit is contained in:
Jakobus Schürz 2022-10-21 17:09:07 +02:00
parent 535c1f28d2
commit 3de3e33333

View file

@ -250,7 +250,7 @@ agent_load_identity_keys () {
fingerprints=( $(ssh_runinagent $agentfile "ssh-add -l|awk '{print \$2}'") ) fingerprints=( $(ssh_runinagent $agentfile "ssh-add -l|awk '{print \$2}'") )
logdebug "fingerprints from loaded keys before action:" logdebug "fingerprints from loaded keys before action:"
for f in ${fingerprints[*]};do for f in ${fingerprints[@]};do
logdebug "$f" logdebug "$f"
done done
if ! $tokenonly ; then if ! $tokenonly ; then
@ -303,11 +303,18 @@ agent_load_identity_keys () {
#[ "$(readlink - f $key)" == "$P11M" ] || key="$P11M" #[ "$(readlink - f $key)" == "$P11M" ] || key="$P11M"
[ "$(readlink -f $key)" != "$P11M" -a "${P11M:-x}" != "x" ] && key="$P11M" [ "$(readlink -f $key)" != "$P11M" -a "${P11M:-x}" != "x" ] && key="$P11M"
logdebug "P11M2: ${P11M:-not set} - key: $key" logdebug "P11M2: ${P11M:-not set} - key: $key"
echo "P11M: ${P11M:-not set} - key: $key" logdebug "P11M: ${P11M:-not set} - key: $key"
tokenfingerprint="$(ssh-keygen -l -D $key|tr -s ' '|awk '{print $2}')" tokenfingerprints=($(ssh-keygen -l -D $key|tr -s ' '|awk '{print $2}'))
if [[ ${fingerprints[*]} =~ "$tokenfingerprint" ]]; then logtrace "fingerprints: ${fingerprints[*]}"
logtrace "tokenfingerprints count: ${#tokenfingerprints[@]}"
if [ ${#tokenfingerprints[@]} -gt 1 ]; then
logerr "Found ${#tokenfingerprints[@]} in p11-kit-proxy! Check if only one token is plugged into your computer"
else
tokenfingerprint=${tokenfingerprints[0]}
logtrace "tokenfingerprint: ${tokenfingerprint}"
if [[ "${fingerprints[@]}" =~ "$tokenfingerprint" ]]; then
logdebug "token: $key ($tokenfingerprint) is loaded" logdebug "token: $key ($tokenfingerprint) is loaded"
check_pubkeysonly check_pubkeysonly
if $readd || $remove ; then if $readd || $remove ; then
@ -323,6 +330,7 @@ agent_load_identity_keys () {
logdebug "$(ssh_runinagent $agentfile ssh-add -v ${SSH_ADD_OPTIONS} -e ${key} 2>&1)" logdebug "$(ssh_runinagent $agentfile ssh-add -v ${SSH_ADD_OPTIONS} -e ${key} 2>&1)"
$remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${key} 2>&1)" $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${key} 2>&1)"
fi fi
fi
done done
fi fi
loginfo "currently loaded keys after action: $(ssh_runinagent $agentfile ssh-add -l|wc -l)" loginfo "currently loaded keys after action: $(ssh_runinagent $agentfile ssh-add -l|wc -l)"