diff --git a/cmd/authwrapper/main.go b/cmd/authwrapper/main.go index dcf3473..7ec3fbf 100644 --- a/cmd/authwrapper/main.go +++ b/cmd/authwrapper/main.go @@ -59,7 +59,7 @@ func main() { log.Fatalf("Failed to list sshAgent keys: %v", err) } - if config.AuthWrapperQuiet == "" { + if config.AuthWrapperQuiet == false { fmt.Fprintf(os.Stderr, "Loaded keys:\n") for _, key := range keyList { @@ -72,7 +72,7 @@ func main() { log.Fatalf("runCommandWithSSHAgent: %v", err) } - if config.AuthWrapperQuiet == "" { + if config.AuthWrapperQuiet == false { fmt.Fprintf(os.Stderr, "exit code: %v\n", exitCode) } } diff --git a/cmd/authwrapper/setup.go b/cmd/authwrapper/setup.go index 254db17..b6f761d 100644 --- a/cmd/authwrapper/setup.go +++ b/cmd/authwrapper/setup.go @@ -30,7 +30,7 @@ type Config struct { SSHCaAuthorizedKeysPath string SSHSigningServerAddress string SSHAgentSocket string - AuthWrapperQuiet string + AuthWrapperQuiet bool } var principalsFlag = flag.String("principals", "", "requested principals") @@ -39,6 +39,8 @@ func parseEnvironment() (*Config, error) { flag.Parse() args := flag.Args() + _, isAuthWrapperQuiet := os.LookupEnv("AUTH_WRAPPER_QUIET") + config := &Config{ Command: os.Getenv("WRAP_COMMAND"), Args: args, @@ -52,7 +54,7 @@ func parseEnvironment() (*Config, error) { SSHCaAuthorizedKeysPath: os.Getenv("SSH_CA_AUTHORIZED_KEYS_PATH"), SSHSigningServerAddress: os.Getenv("SSH_SIGNING_SERVER_LISTEN_ADDRESS"), SSHAgentSocket: os.Getenv("SSH_AUTH_SOCK"), - AuthWrapperQuiet: os.Getenv("AUTH_WRAPPER_QUIET"), + AuthWrapperQuiet: isAuthWrapperQuiet, } os.Unsetenv("WRAP_COMMAND") os.Unsetenv("SSH_KEY_PATH") diff --git a/cmd/authwrapper/utils.go b/cmd/authwrapper/utils.go index 5965bd6..0693a8b 100644 --- a/cmd/authwrapper/utils.go +++ b/cmd/authwrapper/utils.go @@ -29,7 +29,15 @@ func runCommandWithSSHAgent(agent agent.ExtendedAgent, command string, args []st if err != nil { return 255, fmt.Errorf("Failed to start ssh agent server: %v", err) } - os.Setenv("SSH_AUTH_SOCK", sshAuthSock) + + // Hide this behind quiet until the Go standard library has support for the new "agentc" extension in Open-SSH + config, err := parseEnvironment() + if err != nil { + log.Fatalf(": %v", err) + } + if config.AuthWrapperQuiet == false { + os.Setenv("SSH_AUTH_SOCK", sshAuthSock) + } // Do string replacement for SSH_AUTH_SOCK for i, arg := range args {