From 7d6e731f4a567c6d21aa4667facb0b5093e11f54 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Mon, 1 Mar 2021 10:59:34 +0000 Subject: [PATCH] Use SSH_AUTH_SOCK in following ssh-add invocations --- dist/index.js | 3 ++- index.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index d4db8a9..f337138 100644 --- a/dist/index.js +++ b/dist/index.js @@ -166,6 +166,7 @@ try { const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(lines[lineNumber]) if (matches && matches.length > 0) { core.exportVariable(matches[1], matches[2]) + process.env[matches[1]] = matches[2]; // use variables for ssh-add below } } @@ -195,7 +196,7 @@ try { if (isWindows) { child_process.execFileSync('ssh-add', [keyFile], { env: { ...process.env, ...{ 'DISPLAY': 'fake', 'SSH_PASS': token, 'SSH_ASKPASS': 'D:\\a\\ssh-agent\\ssh-agent\\askpass.exe' } } }); } else { - child_process.execFileSync('ssh-add', [keyFile], { input: token }); + child_process.execFileSync('ssh-add', [keyFile], { env: process.env, input: token }); } output.toString().split(/\r?\n/).forEach(function(key) { diff --git a/index.js b/index.js index f10b034..e416e01 100644 --- a/index.js +++ b/index.js @@ -49,6 +49,7 @@ try { const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(lines[lineNumber]) if (matches && matches.length > 0) { core.exportVariable(matches[1], matches[2]) + process.env[matches[1]] = matches[2]; // use variables for ssh-add below } } @@ -78,7 +79,7 @@ try { if (isWindows) { child_process.execFileSync('ssh-add', [keyFile], { env: { ...process.env, ...{ 'DISPLAY': 'fake', 'SSH_PASS': token, 'SSH_ASKPASS': 'D:\\a\\ssh-agent\\ssh-agent\\askpass.exe' } } }); } else { - child_process.execFileSync('ssh-add', [keyFile], { input: token }); + child_process.execFileSync('ssh-add', [keyFile], { env: process.env, input: token }); } output.toString().split(/\r?\n/).forEach(function(key) {