mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
pkg/module: include SSH_AUTH_SOCK in go get env (#1184)
* pkg/module: include SSH_AUTH_SOCK in go get env When running locally, it's convenient to use a user's ssh-agent. For that to work, we need to propagate SSH_AUTH_SOCK. * pkg/module: Verify existence for SSH_AUTH_SOCK SSH_AUTH_SOCK is expected to indicate a unix socket on the local filesystem. If it isn't a unix socket (after symlink resolution) we can ignore it. (although ssh will ignore it as well)
This commit is contained in:
committed by
Aaron Schlesinger
parent
b5a91e8be8
commit
a7aee5b235
@@ -185,6 +185,15 @@ func PrepareEnv(gopath string) []string {
|
||||
gitSSHCmd,
|
||||
}
|
||||
|
||||
if sshAuthSockVal, hasSSHAuthSock := os.LookupEnv("SSH_AUTH_SOCK"); hasSSHAuthSock {
|
||||
// Verify that the ssh agent unix socket exists and is a unix socket.
|
||||
st, err := os.Stat(sshAuthSockVal)
|
||||
if err == nil && st.Mode()&os.ModeSocket != 0 {
|
||||
sshAuthSock := fmt.Sprintf("SSH_AUTH_SOCK=%s", sshAuthSockVal)
|
||||
cmdEnv = append(cmdEnv, sshAuthSock)
|
||||
}
|
||||
}
|
||||
|
||||
// add Windows specific ENV VARS
|
||||
if runtime.GOOS == "windows" {
|
||||
cmdEnv = append(cmdEnv, fmt.Sprintf("USERPROFILE=%s", os.Getenv("USERPROFILE")))
|
||||
|
||||
Reference in New Issue
Block a user