This is a trivial fix but seems to crop up more often
than it should.

Signed-off-by: Luke Kanies <[email protected]>
---
 lib/puppet/defaults.rb       |    9 +++++++++
 spec/integration/defaults.rb |    9 +++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index e1b6dc4..e36dd70 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -95,8 +95,17 @@ module Puppet
         :path => {:default => "none",
             :desc => "The shell search path.  Defaults to whatever is inherited
                 from the parent process.",
+            :call_on_define => true, # Call our hook with the default value, 
so we always get the libdir set.
             :hook => proc do |value|
                 ENV["PATH"] = value unless value == "none"
+
+                paths = ENV["PATH"].split(File::PATH_SEPARATOR)
+                %w{/usr/sbin /sbin}.each do |path|
+                    unless paths.include?(path)
+                        ENV["PATH"] += File::PATH_SEPARATOR + path
+                    end
+                end
+                value
             end
         },
         :libdir => {:default => "$vardir/lib",
diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb
index 54b673a..0b2b756 100755
--- a/spec/integration/defaults.rb
+++ b/spec/integration/defaults.rb
@@ -5,6 +5,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
 require 'puppet/defaults'
 
 describe "Puppet defaults" do
+        include Puppet::Util::Execution
     after { Puppet.settings.clear }
 
     describe "when setting the :factpath" do
@@ -44,4 +45,12 @@ describe "Puppet defaults" do
     it "should default to yaml as the catalog format" do
         Puppet.settings[:catalog_format].should == "yaml"
     end
+
+    it "should add /usr/sbin and /sbin to the path if they're not there" do
+        withenv("PATH" => "/usr/bin:/usr/local/bin") do
+            Puppet.settings[:path] = "none" # this causes it to ignore the 
setting
+            ENV["PATH"].split(File::PATH_SEPARATOR).should 
be_include("/usr/sbin")
+            ENV["PATH"].split(File::PATH_SEPARATOR).should be_include("/sbin")
+        end
+    end
 end
-- 
1.6.1


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to