-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
First hook arg is overwritten with cmd #1663
Comments
This is expected. The specification requires that hook |
@cyphar If this behaviour is expected, it is clearly confusing to some and the swallowing of arguments can lead to some rather difficult to debug issues (state/model mismatch for the developer). Perhaps an optional, but on by default, warning is warranted if usages such as these are detected? |
Maybe, though I disagree it's confusing (since it matches how C acts) and generally I don't like adding warnings for valid usecases. Here's the section of the spec if you're interested -- as you can see the spec matches POSIX's (As an aside -- holy shit! Fellow Sydney-siders! 😸) |
@cyphar Well, yes, it may be how C acts, but this isn't C. Invalid invocations shouldn't be representable -- but if they are and the system can detect that, I think it should complain. Obviously, I think the system should have some sort of a "yes, I meant to do that" so you don't spam people taking advantage of the execv semantics but is that really the usual use case or is it likely to be a mistake? If it's more likely to be a mistake, then I would argue for a foot-gun guard. |
Actually, instead of a warning, perhaps I should argue that we're not actually following the specification -- the argv value is passed through unchanged there. Here we're overwriting argv[0] with our own value, discarding what is set by the developer. Perhaps this might work: Instead, of |
Well, yes, but the OCI specification refers to POSIX -- so while it isn't C, the POSIX C semantics are how
Ah, you're right. I agree this is a bug, but in my mind the fix would be to pass the |
If runc is modified to match the spec and not modify args in any way, then existing configs where the hooks config resembles the following will break. This format currently works and is how oci-runtime-tool currently generates the config file.
What benifits does having control over the first arg bring? To me this feels like an implmentation detail of the programming language that probably shouldn't be exposed at this layer. I am not required to use I am however fine with it matching spec, I would not have been so confused with what was happening if it matched spec. Busybox supports |
Looking into old opened runc issues, I noticed opencontainers#1663 is there without any resolution, and wrote this simple test checking if we mangle hook's argv[0] in any way. Apparently we're good, but the test actually makes sense to have. Signed-off-by: Kir Kolyshkin <[email protected]>
I don't see that this is broken. Yes, ability to specify Also, the busybox argument is kinda moot, as it also accepts the form where argv[0] is "/some/path/to/busybox" and argv[1] is an applet name. So, it could be used just fine without an ability to set argv[0]. Anyway, I guess this can be closed. |
Looking into old opened runc issues, I noticed opencontainers#1663 is there without any resolution, and wrote this simple test checking if we mangle hook's argv[0] in any way. Apparently we're good, but the test actually makes sense to have. Signed-off-by: Kir Kolyshkin <[email protected]>
Looking into old opened runc issues, I noticed opencontainers#1663 is there without any resolution, and wrote this simple test checking if we mangle hook's argv[0] in any way. Apparently we're good, but the test actually makes sense to have. Signed-off-by: Kir Kolyshkin <[email protected]>
Setup
oci-runtime-tool: 0.3.0
runc: 1.0.0-rc4 and fb6ec65
Problem
When attempting to run a hook command with 1 or more arguments the first
arg
argument is discarded and replaced with the contents ofpath
.Given the following:
the hook recives argv of ["/test.py"]
Given:
The hook recives an argv of ["/test.py", "pre"]
Expectation
To me, I would expect that given the first example above, that the hook's argv looks like ["/test.py", "pre"], and the second one ["/test.py", "anything", "pre"]
Using q
pip install q
for lazy logging, the following will dump the argv to/tmp/q
, and then promptly exit.The text was updated successfully, but these errors were encountered: