summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-07 23:12:33 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-07 23:12:33 +0000
commitb98e65f1fd858a1d0af415554db49a121a76232c (patch)
tree728f94dd17f88902c6bdf21ff6b17486babb08af /lib/puppet/util.rb
parentf1ffc34c0927840beeb21e1e2d864ce14de5d15e (diff)
downloadpuppet-b98e65f1fd858a1d0af415554db49a121a76232c.tar.gz
puppet-b98e65f1fd858a1d0af415554db49a121a76232c.tar.xz
puppet-b98e65f1fd858a1d0af415554db49a121a76232c.zip
There is now full support for configuration files, and the entire system has been modified to expect their new behaviour. I have not yet run the test across all test hosts, though.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@873 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/util.rb')
-rw-r--r--lib/puppet/util.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 669e8310a..6e74ca602 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -85,6 +85,53 @@ module Util
return retval
end
+ # Change the process to a different user
+ def self.chuser
+ if group = Puppet[:group]
+ if group =~ /^\d+$/
+ group = Integer(group)
+ else
+ begin
+ g = Etc.getgrnam(group)
+ rescue ArgumentError
+ $stderr.puts "Could not find group %s" % group
+ end
+ group = g.gid
+ end
+ unless Process.gid == group
+ begin
+ Process.egid = group
+ Process.gid = group
+ rescue
+ $stderr.puts "could not change to group %s" % group
+ exit(74)
+ end
+ end
+ end
+
+ if user = Puppet[:user]
+ if user =~ /^\d+$/
+ user = Integer(user)
+ else
+ begin
+ u = Etc.getpwnam(user)
+ rescue ArgumentError
+ $stderr.puts "Could not find user %s" % user
+ end
+ user = u.uid
+ end
+ unless Process.uid == user
+ begin
+ Process.euid = user
+ Process.uid = user
+ rescue
+ $stderr.puts "could not change to user %s" % user
+ exit(74)
+ end
+ end
+ end
+ end
+
# Create a lock file while something is happening
def self.lock(*opts)
lock = opts[0] + ".lock"