Fixing #430 (I hope) -- execs now autorequire the specified user
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2442 980ebf18-57e1-0310-9a29-db15c13687c0
This commit is contained in:
Родитель
483c25e043
Коммит
80ec4943a9
|
@ -1,3 +1,6 @@
|
|||
Execs now autorequire the user they run as, as long as the user
|
||||
is specified by name. (#430)
|
||||
|
||||
Files on the local machine but not on the remote server during
|
||||
a source copy are now purged if purge => true. (#594)
|
||||
|
||||
|
|
|
@ -156,11 +156,13 @@ module Puppet
|
|||
newparam(:user) do
|
||||
desc "The user to run the command as. Note that if you
|
||||
use this then any error output is not currently captured. This
|
||||
is because of a bug within Ruby."
|
||||
is because of a bug within Ruby. If you are using Puppet to
|
||||
create this user, the exec will automatically require the user,
|
||||
as long as it is specified by name."
|
||||
|
||||
# Most validation is handled by the SUIDManager class.
|
||||
validate do |user|
|
||||
unless Puppet::Util::SUIDManager.uid == 0
|
||||
unless Puppet.features.root?
|
||||
self.fail "Only root can execute commands as other users"
|
||||
end
|
||||
end
|
||||
|
@ -434,6 +436,13 @@ module Puppet
|
|||
reqs
|
||||
end
|
||||
|
||||
autorequire(:user) do
|
||||
# Autorequire users if they are specified by name
|
||||
if user = self[:user] and user !~ /^\d+$/
|
||||
user
|
||||
end
|
||||
end
|
||||
|
||||
def self.list
|
||||
self.collect { |i| i }
|
||||
end
|
||||
|
|
|
@ -208,7 +208,7 @@ class TestExec < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
# Verify that we auto-require any managed scripts.
|
||||
def test_autorequire
|
||||
def test_autorequire_files
|
||||
exe = tempfile()
|
||||
oexe = tempfile()
|
||||
sh = %x{which sh}
|
||||
|
@ -713,6 +713,19 @@ and stuff"
|
|||
assert(FileTest.exists?(refresher), "refresh param was ignored")
|
||||
assert(! FileTest.exists?(maker), "refresh param also ran command")
|
||||
end
|
||||
|
||||
if Puppet.features.root?
|
||||
def test_autorequire_user
|
||||
user = Puppet::Type.type(:user).create(:name => "yay")
|
||||
exec = Puppet::Type.type(:exec).create(:command => "/bin/echo fun", :user => "yay")
|
||||
|
||||
rels = nil
|
||||
assert_nothing_raised("Could not evaluate autorequire") do
|
||||
rels = exec.autorequire
|
||||
end
|
||||
assert(rels.find { |r| r.source == user and r.target == exec }, "Exec did not autorequire user")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# $Id$
|
||||
|
|
Загрузка…
Ссылка в новой задаче