-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forward spiffe-helper's stdin to the 'cmd' invoked in daemon_mode #245
Conversation
7a275c4
to
a696295
Compare
a696295
to
2142636
Compare
I'm increasingly leaning toward dropping the idea of using That way there's no need to try to make Given that, I simplified this PR to include only forwarding I will raise an issue for improving support for If someone does want to further improve support for using
Something like this could use code like this to cause
... though I recommend using a
|
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 <&-`. Signed-off-by: Craig Ringer <[email protected]>
2142636
to
34374bd
Compare
PR simplified and un-marked draft. Follow-up PRs can address the safety of argument splitting, and supporting one-shot execution with exit-code forwarding. |
Presently it's difficult to use
spiffe-helper
to wrap another command, because:(See related: #243, #244)
This PR makes one step toward making it more practical to use the helper as a wrapper command, by forwarding
stdin
to thecmd
invoked.Other improvements are needed to make wrapper use reliable, including
cmd
one-shot and exit with thecmd
's exit code when the cmd exits; andspiffe-helper -c some_config.hcl -- my_cmd "my argument" "here"
too.(WIP for these changes can be seen in this commit: a696295, and notes in this comment: #245 (comment))
WARNING This PR introduces a corner case behaviour change.
If
spiffe-helper
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
would have previously echoed one line for each of
a
,b
,c
, andd
. Now, ifspiffe-helper
'scmd
configured insome_config.hcl
consumes stdin if it's attached, it'll instead produce no output (and the unexpectedly connectedstdin
may confuse thecmd
.)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 invokingspiffe-helper
, e.g. in bash runspiffe-helper <&-
.