-
-
Notifications
You must be signed in to change notification settings - Fork 18k
makeBinaryWrapper: protect wildcards in flags #255208
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
Conversation
|
|
|
|
Should this be a staging PR? I've never done one of those; based on the number of rebuilds OfBorg reports it seems like probably yes? But also this is not really a package and I don't know if staging is for changes like this. |
|
Yes staging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the behaviour of makeWrapper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserves wildcards. I amended the makeWrapper tests to cover this but didn't include that change because I wasn't changing makeWrapper; should I?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's already being tested
| (mkWrapperBinary { name = "test-prefix-noglob"; args = [ "--prefix" "VAR" ":" "./*" ]; }) |
Let's do the same reenableGlob thing in here too
nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh
Lines 66 to 70 in d64d76d
| local reenableGlob=0 | |
| if [[ ! -o noglob ]]; then | |
| reenableGlob=1 | |
| fi | |
| set -o noglob |
Do you think noglob is only necessary in addFlags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done a meticulous review of that entire file for quote hygiene. --add-flags and --append-flags are the only makeWrapper flags documented to accept multiple arguments in one space-separated string, so I would expect the other handlers to quote their values and not need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance that there's something relying on the current behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I certainly hope not, especially since makeWrapper doesn't do the same thing. If you want wildcard expansion when either implementation of makeWrapper is called, you can leave the wildcards unquoted/unescaped and bash will expand them first.
Here's the result of a quick ripgrep:
$ rg -e '--a(ppen|d)d-flags.*\*'
pkgs/development/tools/schemacrawler/default.nix
26: --add-flags "-cp $out/lib/*:$out/config" \
pkgs/development/tools/flyway/default.nix
19: --add-flags "-classpath '$out/share/flyway/lib/*:$out/share/flyway/drivers/*'" \
pkgs/development/libraries/rabbitmq-java-client/default.nix
23: --add-flags "-Djava.awt.headless=true -cp $out/share/java/\* com.rabbitmq.examples.PerfTest"
pkgs/tools/security/cryptomator/default.nix
43: --add-flags "--class-path '$out/share/cryptomator/libs/*'" \
pkgs/applications/networking/instant-messengers/signal-cli/default.nix
23: --add-flags "-classpath '$out/lib/*:${libmatthew_java}/lib/jni'" \
pkgs/applications/office/jameica/default.nix
64: --add-flags "-cp $out/share/java/jameica.jar:$out/share/jameica-${version}/* ${
All of these files use makeWrapper or makeShellWrapper, not makeBinaryWrapper.
a5ad527 to
501ba2c
Compare
501ba2c to
1607fc9
Compare
ncfavier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The makeBinaryWrapper CLI is wrong: it should only take one flag per --add-flags argument, so as to allow whitespace. This is different from the makeWrapper CLI, which expects shell expressions so you can always pass quoted strings.
Nevertheless this change is obviously good.
yes if possible doing that change at the same time as this one will reduce rebuilds |
rebuilds don't matter on staging as the builds are batched, every staging rebuilds everything anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| set -f | |
| # shellcheck disable=SC2086 | |
| before=($1) after=($2) | |
| set +f | |
| set -o noglob | |
| # shellcheck disable=SC2086 | |
| before=($1) after=($2) | |
| set +o noglob |
|
My bad: if both could hit master at the same time it'd be ideal |
1607fc9 to
df8b425
Compare
|
@ofborg build tests.makeBinaryWrapper testing if the ci fail is actual x86_64-darwin ci fails https://logs.ofborg.org/?key=nixos/nixpkgs.255208&attempt_id=60e79d85-f81c-4588-941e-d8ff527ad2da it passed in a another makeBinaryWrapper PR https://github.com/NixOS/nixpkgs/runs/16818083116 |
|
Now it timed out at llvm, I'll just assume the machine the test ran on was flaky. |
Description of changes
The split-on-spaces behavior of
--add-flagsand--append-flagswas also causing wildcards to be interpreted when the wrapper was built. This is a quick fix to prevent that.Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)