+1 for the testing branch, anyway.

Obviously a potentially large change so needs plenty of testing.

On May 4, 2010, at 4:10 PM, Markus Roberts wrote:

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.

Signed-off-by: Markus Roberts <[email protected]>
---
lib/puppet/util.rb |   21 ++++-----------------
1 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 503c02b..73ff6bb 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -285,28 +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)
+                Kernel.exec(*command)
                end
            rescue => detail
                puts detail.to_s
--
1.6.4

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected] . For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en .



--
Never regret. If it's good, it's wonderful. If it's bad, it's
experience. -- Victoria Holt
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199

--
You received this message because you are subscribed to the Google Groups "Puppet 
Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to