From 8d7f8f670819748ed4427fca2af5945222fdec53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Mon, 3 Jul 2023 09:46:04 +0200 Subject: [PATCH] improve output --- bin/startagent | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/startagent b/bin/startagent index 300ed59..0cebec5 100755 --- a/bin/startagent +++ b/bin/startagent @@ -175,13 +175,14 @@ agent_start_or_restart () { logdebug "former agent is not running -> start it" logdebug "SSH_AGENT_OPTIONS: $SSH_AGENT_OPTIONS" [ -e $agentsocket ] && { logdebug -n "remove socketfile: $( rm -v "$agentsocket" )"; } + [ -e $agentfile ] && { logdebug -n "remove agentfile: $( rm -v "$agentfile" )"; } logtrace "$(ssh-agent -a $agentsocket ${SSH_AGENT_OPTIONS} > $agentfile )" logdebug "agent started" ;; esac else logdebug "agent did not exist -> create it" - logtrace "ssh-agent -a $agentsocket \> $agentfile" + logtrace "ssh-agent -a $agentsocket $SSH_AGENT_OPTIONS \> $agentfile" logtrace "$(ssh-agent -a $agentsocket $SSH_AGENT_OPTIONS > $agentfile )" logdebug "agent started" fi @@ -190,11 +191,11 @@ agent_start_or_restart () { #logdebug "ssh-agent for identity »$ssh_identity«: $agentfile" $createonly && logtrace "current loaded keys after action: $(ssh_runinagent $agentfile ssh-add -l)" - echo $agentfile + loginfo agentfile: $agentfile + printf "%s" "$agentfile" ret=0 else logwarning "ssh-identity »$ssh_identity« is not configured. Please create $identitydir and add keys" - printf "%s" "$agentfile" ret=2 fi else @@ -280,7 +281,7 @@ agent_load_identity_keys () { # load tokens 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 - logdebug "pubkey with privkey: $pubkey" + logdebug "pubkey with privkey: ${pubkey} | ${pubkey%.pub}" else logdebug "pubkey without privkey: $pubkey" pubkeysonly+=($pubkey) @@ -309,7 +310,7 @@ agent_load_identity_keys () { export P11M=$PKCS11_MODULE logdebug "PKCS11_MODULE: ${PKCS11_MODULE:-not set} - key: $key" grep -q "PKCS11_MODULE" "${agentfile}" >/dev/null 2>&1 && sed -i -e '/PKCS11_MODULE/d' "${agentfile}" - echo "PKCS11_MODULE=$(readlink -f $key)" | tee -a "${agentfile}" >&2 + printf "%s\n" "PKCS11_MODULE=$(readlink -f $key)" | tee -a "${agentfile}" >&2 tokenfingerprints=($(ssh-keygen -l -D $key|tr -s ' '|awk '{print $2}')) @@ -388,7 +389,6 @@ ssh_runinagent () { ret=99 fi - loginfo "SSH_AUTH_SOCK: ${SSH_AUTH_SOCK}" return $ret }