The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #6723

Puppet::Util::Execution withenv method not resetting environment

Added by Max Martin about 3 years ago. Updated about 3 years ago.

Status:ClosedStart date:03/15/2011
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:exec
Target version:2.6.7
Affected Puppet version: Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

The withenv method in lib/puppet/util/execution is supposed to reset the environment to the state it was in before it was called, but it appears that it may not be doing this. A spec test written using this method was able to pollute the environment’s PATH variable for all of the tests that ran after it. As is, there are no tests for this method. Tests should be added to check its behavior, and if it isn’t correctly resetting the environment, it should be changed so that it does. Below is the test that caused the change to PATH:

it "should warn if you're overriding path in environment" do    
     @provider.resource[:path] = ['/bogus/bin']
     @provider.resource[:environment] = ['PATH=/something/else']

       File.stubs(:exists?).returns(false)
       File.stubs(:exists?).with("foo").returns(true)
       File.stubs(:executable?).with("foo").returns(true)

       Puppet::Util.expects(:execute).with(['foo'], {:uid => nil, :gid => nil, :combine => true, :failonfail => false})
       @provider.run("foo")

      @logs.map {|l| "#{l.level}: #{l.message}" }.should == ["warning: Overriding environment setting 'PATH' with '/something/else'"]
    end

Related issues

Related to Puppet - Feature #4884: An exec provider that executes unfiltered bash code. Closed 09/30/2010
Related to Puppet - Bug #17603: Puppet execute has unexpected semantics Accepted

History

#1 Updated by Max Martin about 3 years ago

  • Category set to exec
  • Status changed from Unreviewed to Accepted

#2 Updated by Max Martin about 3 years ago

  • Status changed from Accepted to Merged - Pending Release

Reviewed with Matt Robinson & Daniel Pittman, pushed to 2.6.next in commit:4c9bd43bc2f5fde9d86196e8689dced929d39aad

#3 Updated by James Turnbull about 3 years ago

  • Status changed from Merged - Pending Release to Closed
  • Target version set to 2.6.7

Also available in: Atom PDF