79: fix small security race r=Mic92 a=zimbatm



Co-authored-by: zimbatm <zimbatm@zimbatm.com>
This commit is contained in:
bors[bot] 2023-03-29 18:05:43 +00:00 committed by GitHub
commit ac1eaaf67b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,9 +21,11 @@ sshOpts+=(-o StrictHostKeyChecking=no)
if [[ -n ${SSH_KEY+x} && ${SSH_KEY} != "-" ]]; then
sshPrivateKeyFile="$workDir/ssh_key"
trap 'rm "$sshPrivateKeyFile"' EXIT
echo "$SSH_KEY" >"$sshPrivateKeyFile"
chmod 0700 "$sshPrivateKeyFile"
# Create the file with 0700 - umask calculation: 777 - 700 = 077
(
umask 077
echo "$SSH_KEY" >"$sshPrivateKeyFile"
)
unset SSH_AUTH_SOCK # don't use system agent if key was supplied
sshOpts+=(-o "IdentityFile=${sshPrivateKeyFile}")
fi