Repository navigation
Conversation
Signed-off-by: Arshil Ahmed <194646586+arshil42@users.noreply.github.com>
Unikraft splits its kernel command line into arguments with a parser that separates them at whitespace and treats quotes and backslashes as special characters. urunc joined the environment variables and the command arguments with spaces as they were, so a value with a space was split, quotes were removed, and an unmatched single quote kept the guest from starting. Put every value that contains whitespace, a quote or a backslash in single quotes, inside which the parser keeps every character as it is, and write each single quote in it as '\''. Other values do not change. On hyperlight-unikraft the command is passed as one --guest-exec option, so it stays as it was there. Fixes: urunc-dev#1103 Signed-off-by: Arshil Ahmed <194646586+arshil42@users.noreply.github.com>
👷 Deploy request for urunc pending review.Visit the deploys page to approve it
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Unikraft splits its kernel command line into arguments with
uk_argnparse(lib/ukargparse/argparse.c), which separates arguments at whitespace and treats',"and\as special characters. urunc joined the environment variables (env.vars=[ ... ]) and the command arguments with spaces as they were, so, as shown in #1103:URUNC=hello worldreached the guest asURUNC=hello;URUNC={"level":"info"}reached it asURUNC={level:info};URUNC=don'tleft an unmatched quote, and the guest did not start;-g "daemon off;"reached it as-g,daemon,off;.This puts every value that contains whitespace, a quote or a backslash in single quotes. Inside single quotes
uk_argnparsekeeps every character as it is, including"and\. A single quote in the value ends the quoted part, is added as\'(outside quotes a backslash makes the next character literal) and starts a new quoted part, sodon'tbecomes'don'\''t'. Values without such characters are not changed, so existing command lines stay the same.uk_argnparseis the same from 0.14.0 to 0.21.0, so this works for the versions before 0.16.1 too.On
hyperlight-unikraft, the command is passed as the value of one--guest-execoption instead of on the kernel command line, so it is left as it was there.What this does not change, as discussed in #1103: a
]at the end of an environment variable still ends theenv.varslist (a Unikraft rule), and empty arguments are still dropped byuk_argnparse.The first commit adds me to
.github/contributors.yaml. It is the same commit as in #1210, so the two PRs merge cleanly in either order.Related issues
How was this tested?
On Ubuntu (WSL2, x86_64), in a fresh clone of the branch:
pkg/unikontainers/unikernels/unikraft_args_test.go:TestQuoteUnikraftArgcovers plain values, spaces, tabs, double quotes (the JSON value from the issue), a single quote (don't) and a backslash;TestUnikraftCommandStringQuotesEnvAndArgschecks the full command line for the env value and the-g "daemon off;"arguments from the issue;TestUnikraftHyperlightCommandIsNotQuotedchecks that--guest-execis unchanged.uk_argnparsesource linked above, case by case.go test ./pkg/unikontainers/unikernels/ ./pkg/unikontainers/hypervisors/passes.golangci-lint runwith v2.15.0 (the version used bymake lint) over the whole repository: 0 issues..github/linters: no issues.I could not run the e2e tests: this machine has no KVM or containerd setup.
LLM usage
Claude Opus 5.5 (
claude-opus-5-5, through Claude Code) was used to read the Unikraft parser, write the change and the tests, and draft this description. I reviewed the changes and ran the tests above before opening the PR.Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).