From c0a8181f5d0b4119a94df729cae4e935db547932 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 30 May 2023 10:05:02 +0200 Subject: t/i/docker: always spawn ssh-agent I had some weird errors on my machine where my primary ssh-agent would get killed. No idea why I didn't just spawn a new ssh-agent from the very beginning. --- test/integration/docker/test.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/integration/docker/test.sh b/test/integration/docker/test.sh index 0cd523f..7cb02a0 100755 --- a/test/integration/docker/test.sh +++ b/test/integration/docker/test.sh @@ -99,24 +99,28 @@ remove_ssh_keys() { } kill_ssh_agent() { - [ -n "${SSH_AGENT_PID:+x}" ] || return 0 - dump "killing ssh-agent with PID $SSH_AGENT_PID" - kill "$SSH_AGENT_PID" + [ -n "${this_ssh_agent_pid:+x}" ] || return 0 + dump "killing ssh-agent with PID $this_ssh_agent_pid" + kill "$this_ssh_agent_pid" } spawn_ssh_agent() { - [ -n "${SSH_AGENT_PID:+x}" ] && return 0 if ! command -v ssh-agent > /dev/null 2>&1; then dump "could not find ssh-agent" >&2 return 1 fi + local output output="$( ssh-agent -s )" + eval "$output" + if [ -z "${SSH_AGENT_PID:+x}" ]; then dump "could not start ssh-agent" >&2 return 1 fi + + this_ssh_agent_pid="$SSH_AGENT_PID" } setup_ssh_agent() { @@ -143,7 +147,7 @@ setup_ssh_agent() { echo_password="$( printf -- 'echo %q' "$client_key_password" )" echo "$echo_password" > "$askpass_path" - SSH_ASKPASS="$askpass_path" SSH_ASKPASS_REQUIRE=force DISPLAY= ssh-add "$key" > /dev/null 2>&1 < /dev/null + SSH_ASKPASS="$askpass_path" SSH_ASKPASS_REQUIRE=force DISPLAY= ssh-add "$key" < /dev/null } docker_build() { -- cgit v1.2.3