Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spiffe-helper was attaching stdout and stderr to the child process launched by 'cmd' but was not attaching stdin. Attach stdin too, so it's possible to pass a pipeline of data to `spiffe-helper` for `cmd` to consume. It can then be used in pipeline or as a co-process to communicate with a `cmd` that requires spiffe-helper to manage certificates. This presents a corner case behaviour change for callers of spiffe-helper. If it is invoked in a context where consuming stdin will have an effect on the caller, and it runs a 'cmd' that can optionally consume from stdin but ignores it if stdin is closed, then this change will cause spiffe-helper invocations to consume from stdin that would otherwise go to the caller. E.g. this contrived bash code echo -n $'a\nb\nc\nd\n' | { spiffe-helper -config some_config.hcl & ; spiffe_helper_pid=$! ; while read -r SOME_VAR ; do echo "Got SOME_VAR: ${SOME_VAR}" ; done } would have previously echoed one line for each of a b c and d. Now, if `spiffe-helper`'s `cmd` configured in `some_config.hcl` consumes stdin if it's attached, it'll instead produce no output (and the unexpectedly connected `stdin` may confuse the `cmd`.) This is an unlikely corner case so this change is being made unconditionally, not gated behind a feature flag or configuration option. If anyone is actually affected by this, they can close the `stdin` file descriptor they pass when invoking `spiffe-helper`, e.g. in bash run `spiffe-helper <&-`.
- Loading branch information