Skip to content
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

nix-shell: clean up the tmpDir and escape variables #3325

Merged
merged 1 commit into from Feb 19, 2020
Merged

nix-shell: clean up the tmpDir and escape variables #3325

merged 1 commit into from Feb 19, 2020

Conversation

xzfc
Copy link
Contributor

@xzfc xzfc commented Jan 17, 2020

The problem fixed: each nix-shell invocation creates a new temporary directory (/tmp/nix-shell-*) and never cleans up.

And while I'm here, shellescape all variables inlined into the rcfile. See what might happen without escaping:

$ export TZ="';echo pwned'"
$ nix-shell -p hello --run hello
pwned
Hello, world!

Comment on lines +441 to +430
"trap _nix_shell_clean_tmpdir EXIT; "
"exitHooks+=(_nix_shell_clean_tmpdir); "
"failureHooks+=(_nix_shell_clean_tmpdir); ":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdenv setup overrides the trap with exitHandler function which calls exitHook or failureHook. I've put the trap at line 441 as a fallback.

@xzfc xzfc requested a review from edolstra January 17, 2020 07:00
The problem fixed: each nix-shell invocation creates a new temporary
directory (`/tmp/nix-shell-*`) and never cleans up.

And while I'm here, shellescape all variables inlined into the rcfile.
See what might happen without escaping:

    $ export TZ="';echo pwned'"
    $ nix-shell -p hello --run hello
    pwned
    Hello, world!
@edolstra edolstra merged commit 2e953b5 into NixOS:master Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants