Skip to content

Commit

Permalink
Change AuthWrapperQuiet to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Viterkim committed Jun 17, 2022
1 parent f959e4b commit daa5a04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/authwrapper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}
6 changes: 4 additions & 2 deletions cmd/authwrapper/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Config struct {
SSHCaAuthorizedKeysPath string
SSHSigningServerAddress string
SSHAgentSocket string
AuthWrapperQuiet string
AuthWrapperQuiet bool
}

var principalsFlag = flag.String("principals", "", "requested principals")
Expand All @@ -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,
Expand All @@ -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")
Expand Down
10 changes: 9 additions & 1 deletion cmd/authwrapper/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit daa5a04

Please sign in to comment.