From 5a6b1e1937bcb6022e074e539f183158f443a337 Mon Sep 17 00:00:00 2001 From: Andreas Paul Date: Wed, 19 Jul 2023 15:44:36 +0200 Subject: [PATCH 1/2] skip SSH key when https:// git URL is used --- git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.go b/git.go index 595e206..72a5c5c 100644 --- a/git.go +++ b/git.go @@ -100,7 +100,7 @@ func doMirrorOrUpdate(gitModule GitModule, workDir string, retryCount int) bool isInModulesCacheDir := strings.HasPrefix(workDir, config.ModulesCacheDir) explicitlyLoadSSHKey := true - if len(gitModule.privateKey) == 0 || strings.Contains(gitModule.git, "github.com") || gitModule.useSSHAgent { + if len(gitModule.privateKey) == 0 || strings.Contains(gitModule.git, "github.com") || gitModule.useSSHAgent || strings.HasPrefix(gitModule.git, "https://") { if gitModule.useSSHAgent || len(gitModule.privateKey) == 0 { explicitlyLoadSSHKey = false } else if isControlRepo { From 81cbc339f942c6026737dfdaf49451a51a560e5a Mon Sep 17 00:00:00 2001 From: Andreas Paul Date: Wed, 19 Jul 2023 15:45:09 +0200 Subject: [PATCH 2/2] disable proxy environment variables if NO_PROXY is set --- helper.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/helper.go b/helper.go index 712e643..dd1d032 100644 --- a/helper.go +++ b/helper.go @@ -194,9 +194,18 @@ func executeCommand(command string, commandDir string, timeout int, allowFail bo execCommand.Dir = commandDir } if disableHttpProxy { - Debugf("found matching NO_PROXY URL, trying to disable http_proxy for " + command) - execCommand.Env = append(os.Environ(), "http_proxy=") - execCommand.Env = append(os.Environ(), "https_proxy=") + Debugf("found matching NO_PROXY URL, trying to disable http_proxy and https_proxy env variables for " + command) + // execCommand.Env = append(os.Environ(), "http_proxy=") + // execCommand.Env = append(os.Environ(), "https_proxy=") + os.Unsetenv("http_proxy") + os.Unsetenv("https_proxy") + os.Unsetenv("HTTP_PROXY") + os.Unsetenv("HTTPS_PROXY") + execCommand.Env = os.Environ() + Debugf("exec OS env:" + strings.Join(execCommand.Env, ",") + " for command " + command) + } else { + execCommand.Env = os.Environ() + Debugf("exec OS env:" + strings.Join(execCommand.Env, ",") + " for command " + command) } out, err := execCommand.CombinedOutput() duration := time.Since(before).Seconds()