aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2013-06-18 11:40:19 +0200
committerTimo Weingärtner <timo@tiwe.de>2013-06-18 11:40:19 +0200
commit453e8a66e8ed850d9a7559c8269942969bad62c9 (patch)
tree75e8bf770e2ef1b6d206f00d4ca7322e92e23894
parent3693a5a901b237a0271c67bfd92b6fc4d87aa4f9 (diff)
downloadssh-agent-filter-453e8a66e8ed850d9a7559c8269942969bad62c9.tar.gz
afssh: use temporary directory for socket
-rwxr-xr-xafssh19
1 files changed, 16 insertions, 3 deletions
diff --git a/afssh b/afssh
index 364187b..97a0a25 100755
--- a/afssh
+++ b/afssh
@@ -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 "$@"