summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
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