make token and check_token the same, change log

This commit is contained in:
Jakobus Schürz 2021-12-03 09:36:38 +01:00
parent 2e7f547a27
commit 9bb0d57134
2 changed files with 10 additions and 6 deletions

View file

@ -75,7 +75,7 @@ EOF
check_token(){ check_token(){
# it's the same as in functions.sh # it's the same as "token" in functions.sh
# defined here also, to work also in environments, where functions.sh couldn't be sourced # defined here also, to work also in environments, where functions.sh couldn't be sourced
[ -z "${P11M:+x}" ] && { P11M=$PKCS11_MODULE; export P11M; } [ -z "${P11M:+x}" ] && { P11M=$PKCS11_MODULE; export P11M; }
@ -92,7 +92,7 @@ check_token(){
# Check if public-keys in tmppubkey are working. They are not working, if you removed and add back hardware-token. # 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 $P11M; ssh-add -s $P11M; } )" loginfo "$(ssh-add -T ${tmppubkey}|| { ssh-add -e $P11M; ssh-add -s $P11M; } )"
logdebug "$(rm "${tmppubkey}")" logdebug "$(rm "${tmppubkey}")"
loginfo "$(ssh-add -l )" logdebug "$(ssh-add -l )"
[ $DISPLAY_ORIG ] && logtrace "reset DISPLAY=$DISPLAY_ORIG" [ $DISPLAY_ORIG ] && logtrace "reset DISPLAY=$DISPLAY_ORIG"
[ $DISPLAY_ORIG ] && export DISPLAY=$DISPLAY_ORIG [ $DISPLAY_ORIG ] && export DISPLAY=$DISPLAY_ORIG

View file

@ -861,17 +861,21 @@ token(){
[ -z "${P11M:+x}" ] && { P11M=$PKCS11_MODULE; export P11M; } [ -z "${P11M:+x}" ] && { P11M=$PKCS11_MODULE; export P11M; }
local tmppubkey="${XDG_RUNTIME_DIR}/token.pub"
# If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work # If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work
# So remember and unset DISPLAY, and set it at the end again, if it was set before # So remember and unset DISPLAY, and set it at the end again, if it was set before
[ $DISPLAY ] && local DISPLAY_ORIG=$DISPLAY [ $DISPLAY ] && local DISPLAY_ORIG=$DISPLAY
[ $DISPLAY ] && unset $DISPLAY [ $DISPLAY ] && logtrace "unset DISPLAY: $DISPLAY"
[ $DISPLAY ] && unset DISPLAY
# Write public keys of all in agent stored keys to a temporary file # 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"
loginfo "$(ssh-add -L > $tmppubkey)" loginfo "$(ssh-add -L > $tmppubkey)"
# Check if public-keys in tmppubkey are working. They are not working, if you removed and add back hardware-token. # 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 $P11M; ssh-add -s $P11M; } )" loginfo "$(ssh-add -T ${tmppubkey}|| { ssh-add -e $P11M; ssh-add -s $P11M; } )"
loginfo "$(ssh-add -l)" logdebug "$(rm "${tmppubkey}")"
logdebug "$(ssh-add -l )"
[ $DISPLAY_ORIG ] && logtrace "reset DISPLAY=$DISPLAY_ORIG"
[ $DISPLAY_ORIG ] && export DISPLAY=$DISPLAY_ORIG [ $DISPLAY_ORIG ] && export DISPLAY=$DISPLAY_ORIG
} }