change output reorganisation of calls

This commit is contained in:
Jakobus Schürz 2023-02-18 21:20:18 +01:00
parent 94c9a30871
commit 155d82a228

View file

@ -109,21 +109,9 @@ while :; do
esac esac
done done
SCRIPTENTRY
[ -z "${SSH_IDENTITIES_DIR+x}" ] && { SSH_IDENTITIES_DIR="${SSH_IDENTITIES_DEFAULT_DIR-${HOME}/.ssh/identities}"; export SSH_IDENTITIES_DIR; }
[ -z "${SSH_AGENTS_DIR+x}" ] && { SSH_AGENTS_DIR=${SSH_AGENTS_DEFAULT_DIR-~/.ssh/agents}; export SSH_AGENTS_DIR; }
[ -z "${SSH_AGENT_SOCKETS_DIR+x}" ] && { SSH_AGENT_SOCKETS_DIR=${SSH_AGENT_SOCKETS_DEFAULT_DIR-~/.ssh/agents}; export SSH_AGENT_SOCKETS_DIR; }
[ -z "${SSH_AGENT_OPTIONS+x}" ] && { SSH_AGENT_OPTIONS=${SSH_AGENT_DEFAULT_OPTIONS--t 7200 }; export SSH_AGENT_OPTIONS; }
logtrace " SSH_AGENTS_DIR: $SSH_AGENTS_DIR"
logtrace "SSH_AGENT_SOCKETS_DIR: $SSH_AGENT_SOCKETS_DIR"
logtrace " SSH_IDENTITIES_DIR: $SSH_IDENTITIES_DIR"
[ -z "${SSH_AGENTS_DIR-x}" ] || mkdir -vp "$SSH_AGENTS_DIR"
[ -z "${SSH_AGENT_SOCKETS_DIR-x}" ] || mkdir -vp "$SSH_AGENT_SOCKETS_DIR"
[ -z "${SSH_IDENTITIES_DIR-x}" ] || mkdir -vp "$SSH_IDENTITIES_DIR"
agent_start_or_restart () { agent_start_or_restart () {
logtrace "agent_start_or_restart"
# 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
@ -220,6 +208,7 @@ $(ssh_runinagent $agentfile ssh-add -l)"
agent_load_identity_keys () { agent_load_identity_keys () {
logtrace "agent_load_identity_keys"
# 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
@ -276,9 +265,9 @@ agent_load_identity_keys () {
# load tokens # load tokens
for pubkey in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}/id_*|grep "pub$\|public$"|grep -v "cert.pub"); do for pubkey in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}/id_*|grep "pub$\|public$"|grep -v "cert.pub"); do
if $( ls ${pubkey%.pub} 1>/dev/null 2>&1);then if $( ls ${pubkey%.pub} 1>/dev/null 2>&1);then
echo "pubkey with privkey: $pubkey" logdebug "pubkey with privkey: $pubkey"
else else
echo "pubkey without privkey: $pubkey" logdebug "pubkey without privkey: $pubkey"
pubkeysonly+=($pubkey) pubkeysonly+=($pubkey)
fi fi
if [ -e "${pubkey%.pub}-cert.pub" ]; then if [ -e "${pubkey%.pub}-cert.pub" ]; then
@ -309,9 +298,9 @@ agent_load_identity_keys () {
logtrace "fingerprints: ${fingerprints[*]}" logtrace "fingerprints: ${fingerprints[*]}"
logtrace "tokenfingerprints count: ${#tokenfingerprints[@]}" logtrace "tokenfingerprints count: ${#tokenfingerprints[@]}"
if [ ${#tokenfingerprints[@]} -gt 1 ]; then # if [ ${#tokenfingerprints[@]} -gt 1 ]; then
logerr "Found ${#tokenfingerprints[@]} in p11-kit-proxy! Check if only one token is plugged into your computer" # logerr "Found ${#tokenfingerprints[@]} in p11-kit-proxy! Check if only one token is plugged into your computer"
else # else
tokenfingerprint=${tokenfingerprints[0]} tokenfingerprint=${tokenfingerprints[0]}
logtrace "tokenfingerprint: ${tokenfingerprint}" logtrace "tokenfingerprint: ${tokenfingerprint}"
if [[ "${fingerprints[@]}" =~ "$tokenfingerprint" ]]; then if [[ "${fingerprints[@]}" =~ "$tokenfingerprint" ]]; then
@ -330,7 +319,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 # 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)"
@ -383,6 +372,19 @@ ssh_runinagent () {
} }
SCRIPTENTRY
[ -z "${SSH_IDENTITIES_DIR+x}" ] && { SSH_IDENTITIES_DIR="${SSH_IDENTITIES_DEFAULT_DIR-${HOME}/.ssh/identities}"; export SSH_IDENTITIES_DIR; }
[ -z "${SSH_AGENTS_DIR+x}" ] && { SSH_AGENTS_DIR=${SSH_AGENTS_DEFAULT_DIR-~/.ssh/agents}; export SSH_AGENTS_DIR; }
[ -z "${SSH_AGENT_SOCKETS_DIR+x}" ] && { SSH_AGENT_SOCKETS_DIR=${SSH_AGENT_SOCKETS_DEFAULT_DIR-~/.ssh/agents}; export SSH_AGENT_SOCKETS_DIR; }
[ -z "${SSH_AGENT_OPTIONS+x}" ] && { SSH_AGENT_OPTIONS=${SSH_AGENT_DEFAULT_OPTIONS--t 7200 }; export SSH_AGENT_OPTIONS; }
logtrace " SSH_AGENTS_DIR: $SSH_AGENTS_DIR"
logtrace "SSH_AGENT_SOCKETS_DIR: $SSH_AGENT_SOCKETS_DIR"
logtrace " SSH_IDENTITIES_DIR: $SSH_IDENTITIES_DIR"
[ -z "${SSH_AGENTS_DIR-x}" ] || mkdir -vp "$SSH_AGENTS_DIR"
[ -z "${SSH_AGENT_SOCKETS_DIR-x}" ] || mkdir -vp "$SSH_AGENT_SOCKETS_DIR"
[ -z "${SSH_IDENTITIES_DIR-x}" ] || mkdir -vp "$SSH_IDENTITIES_DIR"
if [[ $SSH_TTY || $X2GO_SESSION ]] ; then if [[ $SSH_TTY || $X2GO_SESSION ]] ; then
logdebug "Shell running with forwarded ssh-agent. Please add local token manually" logdebug "Shell running with forwarded ssh-agent. Please add local token manually"
check_token check_token
@ -393,5 +395,6 @@ else
! $createonly && agent_load_identity_keys $ssh_identity ! $createonly && agent_load_identity_keys $ssh_identity
res=0 res=0
fi fi
SCRIPTEXIT SCRIPTEXIT
exit $res exit $res