summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-04-30 19:42:58 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-04-30 19:42:58 +0000
commit80ec4943a9db1272fb405a459a763f8b8a6abd52 (patch)
tree6e117abe234ecc9b9301344a2f95fcb68756be09 /lib
parent483c25e04314f66e48290c9e3141000872b23145 (diff)
downloadpuppet-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
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/type/exec.rb13
1 files changed, 11 insertions, 2 deletions
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