From 7e185f29528389a30009b0fd95734f8e7ed20f5e Mon Sep 17 00:00:00 2001 From: Sn0wCrack <442287+Sn0wCrack@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:48:15 +1000 Subject: [PATCH] fix: get ssh agent details via regex instead doesn't seem like eval persists the environment variables --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 33a261e..7478775 100644 --- a/index.js +++ b/index.js @@ -21,11 +21,17 @@ async function ssh() { fs.mkdirSync(sshHomeDir) } - await $`eval \`ssh-agent\`` + const sshAgentOutput = await $`ssh-agent` - const sshAgentSocket = await $`echo \$SSH_AUTH_SOCKET` + const sshAgentSocket = sshAgentOutput + .stdout + .match(/SSH_AUTH_SOCK=(?.*); export SSH_AUTH_SOCK;/) + ?.groups['path'] ?? null; - const sshAgentProcessId = await $`echo \$SSH_AGENT_PID` + const sshAgentProcessId = sshAgentOutput + .stdout + .match(/SSH_AGENT_PID=(?\d+); export SSH_AGENT_PID;/) + ?.groups['pid'] ?? null; if (!sshAgentSocket || !sshAgentProcessId) { throw new Error('Failed to start ssh-agent')