summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-06-09 17:47:39 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit2396ebac9021eaa4a2983e60902c04cc9e0db0ee (patch)
tree05015dc5d67aca35dd235a6229fb360ecb6b68e9
parent8128311690a25d864087a7aee31b233a459345fd (diff)
downloadpuppet-2396ebac9021eaa4a2983e60902c04cc9e0db0ee.tar.gz
puppet-2396ebac9021eaa4a2983e60902c04cc9e0db0ee.tar.xz
puppet-2396ebac9021eaa4a2983e60902c04cc9e0db0ee.zip
Use the 'root' feature rather than directly checking the uid
Jesse fixed all these but David and others moved them and introduced some more so...
-rw-r--r--lib/puppet/provider/file/posix.rb2
-rw-r--r--lib/puppet/provider/file/win32.rb2
-rwxr-xr-xlib/puppet/type/file/source.rb2
-rwxr-xr-xspec/unit/indirector/ldap.rb2
-rwxr-xr-xspec/unit/type/file/source.rb4
-rwxr-xr-xtest/puppet/defaults.rb2
-rwxr-xr-xtest/ral/providers/group.rb2
-rwxr-xr-xtest/ral/providers/user.rb2
-rwxr-xr-xtest/ral/type/exec.rb2
-rwxr-xr-xtest/ral/type/file.rb2
-rwxr-xr-xtest/util/settings.rb8
11 files changed, 15 insertions, 15 deletions
diff --git a/lib/puppet/provider/file/posix.rb b/lib/puppet/provider/file/posix.rb
index 6d6e2312b..43b745d37 100644
--- a/lib/puppet/provider/file/posix.rb
+++ b/lib/puppet/provider/file/posix.rb
@@ -42,7 +42,7 @@ Puppet::Type.type(:file).provide :posix do
return true if uid == current
end
- unless Puppet::Util::SUIDManager.uid == 0
+ unless Puppet.features.root?
warnonce "Cannot manage ownership unless running as root"
return true
end
diff --git a/lib/puppet/provider/file/win32.rb b/lib/puppet/provider/file/win32.rb
index 8eeef4415..b19bd0c5a 100644
--- a/lib/puppet/provider/file/win32.rb
+++ b/lib/puppet/provider/file/win32.rb
@@ -29,7 +29,7 @@ Puppet::Type.type(:file).provide :win32 do
return true if uid == current
end
- unless Puppet::Util::SUIDManager.uid == 0
+ unless Puppet.features.root?
warnonce "Cannot manage ownership unless running as root"
return true
end
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index cf861a0df..aaf91695c 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -104,7 +104,7 @@ module Puppet
# if a value has not already been provided.
[:owner, :mode, :group, :checksum].each do |metadata_method|
param_name = (metadata_method == :checksum) ? :content : metadata_method
- next if metadata_method == :owner and Puppet::Util::SUIDManager.uid != 0
+ next if metadata_method == :owner and !Puppet.features.root?
next if metadata_method == :checksum and metadata.ftype == "directory"
if resource[param_name].nil? or resource[param_name] == :absent
diff --git a/spec/unit/indirector/ldap.rb b/spec/unit/indirector/ldap.rb
index 2c4060c4d..44df2b5bb 100755
--- a/spec/unit/indirector/ldap.rb
+++ b/spec/unit/indirector/ldap.rb
@@ -136,7 +136,7 @@ describe Puppet::Indirector::Ldap do
end
describe "when reconnecting to ldap" do
- confine "Not running on culain as root" => (Puppet::Util::SUIDManager.uid == 0 and Facter.value("hostname") == "culain")
+ confine "Not running on culain as root" => (Puppet.features.root? and Facter.value("hostname") == "culain")
it "should reconnect to ldap when connections are lost"
end
diff --git a/spec/unit/type/file/source.rb b/spec/unit/type/file/source.rb
index b9bb22240..536cb63b0 100755
--- a/spec/unit/type/file/source.rb
+++ b/spec/unit/type/file/source.rb
@@ -148,7 +148,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
end
it "should copy the metadata's owner, group, checksum, and mode to the resource if they are not set on the resource" do
- Puppet::Util::SUIDManager.expects(:uid).returns 0
+ Puppet.features.expects(:root?).returns true
@source.copy_source_values
@@ -176,7 +176,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
describe "and puppet is not running as root" do
it "should not try to set the owner" do
- Puppet::Util::SUIDManager.expects(:uid).returns 100
+ Puppet.features.expects(:root?).returns false
@source.copy_source_values
@resource[:owner].should be_nil
diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb
index d53c23217..bab6644d2 100755
--- a/test/puppet/defaults.rb
+++ b/test/puppet/defaults.rb
@@ -40,7 +40,7 @@ class TestPuppetDefaults < Test::Unit::TestCase
# we don't want user defaults in /, or root defaults in ~
def testDefaultsInCorrectRoots
notval = nil
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
notval = Regexp.new(File.expand_path("~"))
else
notval = /^\/var|^\/etc/
diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb
index 8e62d7b1e..cedbf137c 100755
--- a/test/ral/providers/group.rb
+++ b/test/ral/providers/group.rb
@@ -179,7 +179,7 @@ class TestGroupProvider < Test::Unit::TestCase
}
end
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
def test_mkgroup
gobj = nil
comp = nil
diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb
index 03e3ec892..9abf850ad 100755
--- a/test/ral/providers/user.rb
+++ b/test/ral/providers/user.rb
@@ -418,7 +418,7 @@ class TestUserProvider < Test::Unit::TestCase
assert_equal(main.sort, list.sort, "Group list is not equal")
end
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
def test_simpleuser
name = "pptest"
diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb
index 27a3de4d1..98d111444 100755
--- a/test/ral/type/exec.rb
+++ b/test/ral/type/exec.rb
@@ -294,7 +294,7 @@ class TestExec < Test::Unit::TestCase
assert_events([:executed_command], comp)
end
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
# Verify that we can execute commands as a special user
def mknverify(file, user, group = nil, id = true)
File.umask(0022)
diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb
index 462e8f8eb..431a302ab 100755
--- a/test/ral/type/file.rb
+++ b/test/ral/type/file.rb
@@ -109,7 +109,7 @@ class TestFile < Test::Unit::TestCase
end
end
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
def test_createasuser
dir = tmpdir()
diff --git a/test/util/settings.rb b/test/util/settings.rb
index e94778e2a..272ced9f5 100755
--- a/test/util/settings.rb
+++ b/test/util/settings.rb
@@ -359,7 +359,7 @@ yay = /a/path
user = nonrootuser()
group = nonrootgroup()
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
args[:owner] = user.name
args[:group] = group.name
end
@@ -375,7 +375,7 @@ yay = /a/path
assert_equal(mode, filemode(path), "Modes are not equal")
# OS X is broken in how it chgrps files
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
assert_equal(user.uid, File.stat(path).uid, "UIDS are not equal")
case Facter["operatingsystem"].value
@@ -399,7 +399,7 @@ yay = /a/path
user = nonrootuser()
group = nonrootgroup()
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
args[:owner] = user.name
args[:group] = group.name
end
@@ -414,7 +414,7 @@ yay = /a/path
# OS X and *BSD is broken in how it chgrps files
- if Puppet::Util::SUIDManager.uid == 0
+ if Puppet.features.root?
assert_equal(user.uid, File.stat(path).uid, "UIDS are not equal")
case Facter["operatingsystem"].value