From 910a5e2f39d2fefab28768f2a2d3d02de7abd54d Mon Sep 17 00:00:00 2001 From: Ricky Zhou Date: Sat, 11 Jul 2009 01:57:52 -0400 Subject: Fix #1963 - Failing to read /proc/mounts for selinux kills file downloads This works around a linux kernel bug that causes a select() on /proc/mounts to hang. --- lib/puppet/util/selinux.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index 7be119c6f..fdd40a66f 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -152,9 +152,15 @@ module Puppet::Util::SELinux # Internal helper function to read and parse /proc/mounts def read_mounts + mounts = "" begin - mountfh = File.open("/proc/mounts", File::NONBLOCK) - mounts = mountfh.read + 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) + end + rescue EOFError mountfh.close rescue return nil -- cgit