summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-05-04 15:57:08 -0700
committerJames Turnbull <james@lovedthanlost.net>2010-05-18 14:44:32 +1000
commit3d7168bef36b36b4d399eeefd7dccaec75fd8bc9 (patch)
tree74aa61872eb9c604f9c5474fcd99eb6c44a65f80
parent57160281fd1bfb1d66288c8ff2bee1abd6a954d2 (diff)
downloadpuppet-3d7168bef36b36b4d399eeefd7dccaec75fd8bc9.tar.gz
puppet-3d7168bef36b36b4d399eeefd7dccaec75fd8bc9.tar.xz
puppet-3d7168bef36b36b4d399eeefd7dccaec75fd8bc9.zip
Fix for #3107 Changing users on AIX
There are several issues with changing the real, effective, and saved group and user ids in different environments (which methods to call, in what order, etc). While the code being replaced by this patch appeared to work for Linux, Solaris, and (with a special case test) Darwin; it was failing under AIX and may have had edge-case problems under the others. Ruby back to 1.8.1 has supported a higher level interface that deals with the problem and captures a broader range of OSes; it's a single call for group and one for user--the details of rid/eid/svid, etc ordering are handled internally. Switching to that simplifies our code and should improve/unify our support of various OSes.
-rw-r--r--lib/puppet/util.rb22
1 files changed, 4 insertions, 18 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 503c02b36..e06d6e6c5 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -285,29 +285,15 @@ module Util
# Child process executes this
Process.setsid
begin
- if arguments[:stdinfile]
- $stdin.reopen(arguments[:stdinfile])
- else
- $stdin.reopen("/dev/null")
- end
+ $stdin.reopen(arguments[:stdinfile] || "/dev/null")
$stdout.reopen(output_file)
$stderr.reopen(error_file)
3.upto(256){|fd| IO::new(fd).close rescue nil}
- if arguments[:gid]
- Process.egid = arguments[:gid]
- Process.gid = arguments[:gid] unless @@os == "Darwin"
- end
- if arguments[:uid]
- Process.euid = arguments[:uid]
- Process.uid = arguments[:uid] unless @@os == "Darwin"
- end
+ Process::GID.change_privilege arguments[:gid] if arguments[:gid]
+ Process::UID.change_privilege arguments[:uid] if arguments[:uid]
ENV['LANG'] = ENV['LC_ALL'] = ENV['LC_MESSAGES'] = ENV['LANGUAGE'] = 'C'
- if command.is_a?(Array)
- Kernel.exec(*command)
- else
- Kernel.exec(command)
- end
+ Kernel.exec(*command)
rescue => detail
puts detail.to_s
exit!(1)