[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5

James Turnbull james at lovedthanlost.net
Tue Oct 27 17:04:52 UTC 2009


The following commit has been merged in the upstream branch:
commit 40cd6d413257e840b357ddd243499b8c441b0ff0
Author: Markus Roberts <Markus at reality.com>
Date:   Tue Sep 8 13:33:33 2009 -0700

    Fix for #2605 by falling back to alternative solution to #1963
    
    Two solutions were proposed and tested for #1963; both worked but one
    (the read_nonblock solution) was used for performance reasons.  This
    solution does not work on older ruby implementations (1.8.1) because
    read_nonblock is not available.  This patch implements the alternative
    fix (IO.popen) as a fallback to handles such cases.
    
    Signed-off-by: Markus Roberts <Markus at reality.com>

diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb
index fdd40a6..348eab7 100644
--- a/lib/puppet/util/selinux.rb
+++ b/lib/puppet/util/selinux.rb
@@ -154,14 +154,21 @@ module Puppet::Util::SELinux
     def read_mounts
         mounts = ""
         begin
-            mountfh = File.open("/proc/mounts")
-            # We use read_nonblock() in a loop rather than read() to work-around
-            # a linux kernel bug.  See ticket #1963 for details.
-            while true
-                mounts += mountfh.read_nonblock(1024)
+            if File.instance_methods.include? "read_nonblock"
+                # If possible we use read_nonblock() in a loop rather than read() to work-
+                # a linux kernel bug.  See ticket #1963 for details.
+                mountfh = File.open("/proc/mounts")
+                mounts += mountfh.read_nonblock(1024) while true
+                end
+            else
+                # Otherwise we shell out and let cat do it for us
+                mountfh = IO.popen("/bin/cat /proc/mounts")
+                mounts = mountfh.read
             end
-        rescue EOFError
+        ensure        
             mountfh.close
+        rescue EOFError
+            # that's expected
         rescue
             return nil
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list