303
return c.Password, nil
304
}
306
>
if timeout == 0 {
307
timeout = defaultPasswordCommandTimeout
308
}
309
>
ctx, cancel := context.WithTimeout(context.Background(), timeout)
persistence.go
310
>
defer cancel()
311
>
cmd := exec.CommandContext(ctx, c.PasswordCommand.Command, c.PasswordCommand.Args...) //nolint:gosec
312
>
// WaitDelay caps how long we block on the stdout pipe after the process is killed.
313
>
// Without it, a subprocess that inherits the pipe could keep it open indefinitely.
314
>
cmd.WaitDelay = passwordCommandWaitDelay
315
>
var stderr bytes.Buffer
316
>
cmd.Stderr = &stderr
317
>
out, err := cmd.Output()
318
>
if err != nil {
319
return "", fmt.Errorf("passwordCommand %q %v failed: %w (stderr: %s)",
320
c.PasswordCommand.Command, c.PasswordCommand.Args, err, stderr.String())