-
Notifications
You must be signed in to change notification settings - Fork 211
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
Sanitize the environment before spawning #182
Conversation
The |
maybe executing the command |
Or something like? env_backup = ENV.to_hash
ENV['FOO'] = 'foo'
response = `command`
ENV.replace(env_backup) |
@njam your solution is inherently unsafe: you modify the |
@carlossg I added a 1.8.7 code path using your suggestion, but puppet can't be found this way. I assume because we aren't actually using a system installed puppet, but the puppet gem configured as a developer dependency. As an additional note: your suggestion only works on Unix. I have to get this working on Windows too! I have been reading up on process execution in Ruby, and to be honest, I find it a big mess: What I'm after at the moment is a call that also works on Unix & Windows, where I can explicitly specify the environment. Any suggestion? |
IIUC my solution works for you in windows but not in the travis environment? |
@njam The Librarian abstraction you mentioned uses the same unsafe technique in their JRuby and 1.8.x code path unfortunately. |
The https://travis-ci.org/ringods/librarian-puppet/jobs/20271651 I'm getting more and more lost... |
@carlossg I have left the 1.8.7 situation as it is, and only sanitized the environment for >=1.9. This should fix it for the majority of the users. Will you accept my changes this way? |
Thanks! Looks good, can you squash the commits into one and update the changelog? |
Never "squashed" commits. Any pointer how I can do that? |
http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html from your branch you can do a |
GEM_PATH from the parent process to the child process. Not sanitizing on 1.8.7 as the popen3 call doesn't accept an env argument on pre-1.9.
Commits squashed. I came from a green build and now I get failures... Any idea what could cause the timeouts? |
Sanitize the environment before spawning
Thanks, I need to rethink the timeouts in Travis, it's not very stable |
Secure coding guidelines advice to sanitize the environment before spawning child processes.
In this case, having a
GEM_PATH
defined in the parent process has influence on the execution of the spawnedpuppet
process:When unsetting the
GEM_PATH
, it works flawlessly: