diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-30 19:42:58 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-30 19:42:58 +0000 |
| commit | 80ec4943a9db1272fb405a459a763f8b8a6abd52 (patch) | |
| tree | 6e117abe234ecc9b9301344a2f95fcb68756be09 | |
| parent | 483c25e04314f66e48290c9e3141000872b23145 (diff) | |
| download | puppet-80ec4943a9db1272fb405a459a763f8b8a6abd52.tar.gz puppet-80ec4943a9db1272fb405a459a763f8b8a6abd52.tar.xz puppet-80ec4943a9db1272fb405a459a763f8b8a6abd52.zip | |
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
| -rw-r--r-- | CHANGELOG | 3 | ||||
| -rwxr-xr-x | lib/puppet/type/exec.rb | 13 | ||||
| -rwxr-xr-x | test/ral/types/exec.rb | 15 |
3 files changed, 28 insertions, 3 deletions
@@ -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) diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index ad33c755a..5a045f630 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -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 diff --git a/test/ral/types/exec.rb b/test/ral/types/exec.rb index e36316031..ede6361cd 100755 --- a/test/ral/types/exec.rb +++ b/test/ral/types/exec.rb @@ -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$ |
