summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-05-04 15:57:08 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commite82f5de7e66a54712421d96288cc6a2614f53dd7 (patch)
tree029e21d1e7767ccb3369c762cc99a8a199d130c8 /lib
parent44f1465e937c0d7157de0caf7d2e6af9a38f09d8 (diff)
downloadpuppet-e82f5de7e66a54712421d96288cc6a2614f53dd7.tar.gz
puppet-e82f5de7e66a54712421d96288cc6a2614f53dd7.tar.xz
puppet-e82f5de7e66a54712421d96288cc6a2614f53dd7.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.
Diffstat (limited to 'lib')
-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)