better tokenhandling

This commit is contained in:
Jakobus Schürz 2023-06-15 11:15:05 +02:00 committed by Jakobus Schürz
parent 210a838a31
commit 977f8c87c9

View file

@ -63,11 +63,21 @@ check_token(){
# Write public keys of all in agent stored keys to a temporary file
local tmppubkey="$(mktemp -p ${XDG_RUNTIME_DIR} pubkey.XXXXXX.pub)"
logtrace "tmppubkey: $tmppubkey"
ssh-add -L > $tmppubkey || return $?
logdebug "C"
tmpIFS="${IFS}"
IFS=$'\n'
for tmppk in $(ssh-add -L)
do
printf "%s" "$tmppk" |tee "${tmppubkey}" || return $?
#echo "${tmppk}" > $tmppubkey || return $?
#ssh-add -L > $tmppubkey || return $?
# Check if public-keys in tmppubkey are working. They are not working, if you removed and add back hardware-token.
loginfo "$(ssh-add -T ${tmppubkey}|| { ssh-add -e $PKCS11_MODULE; ssh-add -s $PKCS11_MODULE; } )"
logdebug "$(rm "${tmppubkey}")"
logdebug "$(ssh-add -l )"
done
logdebug "$(rm "${tmppubkey}")"
IFS=$tmpIFS
unset tmpIFS
[ $DISPLAY_ORIG ] && logtrace "reset DISPLAY=$DISPLAY_ORIG"
[ $DISPLAY_ORIG ] && export DISPLAY=$DISPLAY_ORIG