summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-18 18:15:43 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-18 18:15:43 +0000
commit7b34e25d1cb4c70568ed05e01556a12994b19dbf (patch)
treea7bdbcc9c2883f805a9c84a518a1b1513a0fc09a /lib/puppet
parentead49c673e352166d87f47cbbea2086d4c1fc2f7 (diff)
downloadpuppet-7b34e25d1cb4c70568ed05e01556a12994b19dbf.tar.gz
puppet-7b34e25d1cb4c70568ed05e01556a12994b19dbf.tar.xz
puppet-7b34e25d1cb4c70568ed05e01556a12994b19dbf.zip
Another round of bug-fixes in preparation for 0.20.0
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1813 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/provider.rb8
-rwxr-xr-xlib/puppet/provider/parsedfile.rb3
-rw-r--r--lib/puppet/reports/store.rb4
-rw-r--r--lib/puppet/suidmanager.rb62
4 files changed, 41 insertions, 36 deletions
diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb
index e0f465159..5185b172b 100644
--- a/lib/puppet/provider.rb
+++ b/lib/puppet/provider.rb
@@ -149,7 +149,7 @@ class Puppet::Provider
found = values.find do |v|
result == v.to_s.downcase.intern
end
- debug "Not suitable: %s not in %s" [check, values]
+ debug "Not suitable: %s not in %s" % [check, values]
return false unless found
else
return false
@@ -162,7 +162,11 @@ class Puppet::Provider
def self.to_s
unless defined? @str
- @str = "%s provider %s" % [@model.name, self.name]
+ if self.model
+ @str = "%s provider %s" % [@model.name, self.name]
+ else
+ @str = "unattached provider %s" % [self.name]
+ end
end
end
diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb
index f690c03a4..35267c673 100755
--- a/lib/puppet/provider/parsedfile.rb
+++ b/lib/puppet/provider/parsedfile.rb
@@ -122,8 +122,9 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
def hash
@instances = allinstances()
+ namevar = @model.class.namevar
if @instances and h = @instances.find do |o|
- o.is_a? Hash and o[:name] == @model[:name]
+ o.is_a? Hash and o[namevar] == @model[namevar]
end
@me = h
else
diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb
index 82eebff39..a2ab797e1 100644
--- a/lib/puppet/reports/store.rb
+++ b/lib/puppet/reports/store.rb
@@ -19,8 +19,8 @@ Puppet::Server::Report.newreport(:store, :useyaml => true) do
config.setdefaults("reportclient-#{client}",
"clientdir-#{client}" => { :default => dir,
:mode => 0750,
- :owner => "$user",
- :group => "$group"
+ :owner => Puppet[:user],
+ :group => Puppet[:group]
}
)
diff --git a/lib/puppet/suidmanager.rb b/lib/puppet/suidmanager.rb
index 4f94ddde2..6e9f58867 100644
--- a/lib/puppet/suidmanager.rb
+++ b/lib/puppet/suidmanager.rb
@@ -28,37 +28,6 @@ module Puppet
module_function method
end
- def run_and_capture(command, new_uid=self.euid, new_gid=self.egid)
- output = nil
-
- asuser(new_uid, new_gid) do
- # capture both stdout and stderr unless we are on ruby < 1.8.4
- # NOTE: this would be much better facilitated with a specialized popen()
- # (see the test suite for more details.)
- if (Facter['rubyversion'].value <=> "1.8.4") < 0
- Puppet::Util::Warnings.warnonce "Cannot capture STDERR when running as another user on Ruby < 1.8.4"
- output = %x{#{command}}
- else
- output = %x{#{command} 2>&1}
- end
- end
-
- [output, $?.dup]
- end
-
- module_function :run_and_capture
-
- def system(command, new_uid=self.euid, new_gid=self.egid)
- status = nil
- asuser(new_uid, new_gid) do
- Kernel.system(command)
- status = $?.dup
- end
- status
- end
-
- module_function :system
-
def asuser(new_euid=nil, new_egid=nil)
# Unless we're root, don't do a damn thing.
unless Process.uid == 0
@@ -91,6 +60,37 @@ module Puppet
end
module_function :asuser
+
+ def run_and_capture(command, new_uid=nil, new_gid=nil)
+ output = nil
+
+ asuser(new_uid, new_gid) do
+ # capture both stdout and stderr unless we are on ruby < 1.8.4
+ # NOTE: this would be much better facilitated with a specialized popen()
+ # (see the test suite for more details.)
+ if (Facter['rubyversion'].value <=> "1.8.4") < 0
+ Puppet::Util::Warnings.warnonce "Cannot capture STDERR when running as another user on Ruby < 1.8.4"
+ output = %x{#{command}}
+ else
+ output = %x{#{command} 2>&1}
+ end
+ end
+
+ [output, $?.dup]
+ end
+
+ module_function :run_and_capture
+
+ def system(command, new_uid=nil, new_gid=nil)
+ status = nil
+ asuser(new_uid, new_gid) do
+ Kernel.system(command)
+ status = $?.dup
+ end
+ status
+ end
+
+ module_function :system
end
end