diff options
author | Timo Weingärtner <timo@tiwe.de> | 2013-06-18 11:40:19 +0200 |
---|---|---|
committer | Timo Weingärtner <timo@tiwe.de> | 2013-06-18 11:40:19 +0200 |
commit | 453e8a66e8ed850d9a7559c8269942969bad62c9 (patch) | |
tree | 75e8bf770e2ef1b6d206f00d4ca7322e92e23894 | |
parent | 3693a5a901b237a0271c67bfd92b6fc4d87aa4f9 (diff) | |
download | ssh-agent-filter-453e8a66e8ed850d9a7559c8269942969bad62c9.tar.gz |
afssh: use temporary directory for socket
-rwxr-xr-x | afssh | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -23,7 +23,7 @@ set -e declare -a agent_filter_args while true; do - if [[ $1 = "--" ]]; then + if [ "$1" = "--" ]; then shift break else @@ -32,7 +32,20 @@ while true; do fi done -eval $(${BASH_SOURCE%/*}/ssh-agent-filter "${agent_filter_args[@]}" || echo exit $?) -trap 'kill "$SSH_AGENT_PID"' EXIT +# safeguard to not kill the real ssh-agent +unset SSH_AGENT_PID + +trap 'kill "$SSH_AGENT_PID"; rm -r "$TEMPDIR"' EXIT +TEMPDIR=$(mktemp -d) + +if [ -x "${BASH_SOURCE%/*}/ssh-agent-filter" ]; then + SAF=$(readlink -f "${BASH_SOURCE%/*}/ssh-agent-filter") +else + SAF=$(which ssh-agent-filter) +fi + +eval $(cd "$TEMPDIR"; "$SAF" "${agent_filter_args[@]}" || echo exit $?) + +ssh-add -l ssh -A "$@" |